Class: Puppet::CloudPack::HttpHeaders

Inherits:
Object
  • Object
show all
Includes:
Net::HTTPHeader
Defined in:
lib/puppet/cloudpack.rb

Overview

This is a utility class to provide access to the methods defined in the Net::HTTPHeader module (e.g. set_content_type, basic_auth, etc.). Additionally it overrides the to_hash method to return a hash of simple (String) values rather than a hash of Arrays so that the returned value is usable as input to Net::HTTP.get, Net::HTTP.post etc. family of methods (and consequently the Puppet::Network::HTTP::Connection.request method).

Instance Method Summary collapse

Constructor Details

#initialize(headers = nil) ⇒ HttpHeaders

Returns a new instance of HttpHeaders.



26
27
28
# File 'lib/puppet/cloudpack.rb', line 26

def initialize(headers = nil)
  initialize_http_header(headers)
end

Instance Method Details

#to_hashObject



30
31
32
33
34
35
36
# File 'lib/puppet/cloudpack.rb', line 30

def to_hash
  hash = {}
  each do |k, v|
    hash[k] = v
  end
  hash
end