Class: HttpStub::Server::Request::Headers

Inherits:
Hash
  • Object
show all
Includes:
Extensions::Core::Hash::Formatted, Extensions::Core::Hash::IndifferentAndInsensitiveAccess
Defined in:
lib/http_stub/server/request/headers.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions::Core::Hash::Formatted

#to_s

Methods included from Extensions::Core::Hash::IndifferentAndInsensitiveAccess

#[]

Constructor Details

#initialize(header_hash = {}) ⇒ Headers

Returns a new instance of Headers.


16
17
18
# File 'lib/http_stub/server/request/headers.rb', line 16

def initialize(header_hash={})
  super(header_hash, ":")
end

Class Method Details

.create(rack_request) ⇒ Object


9
10
11
12
13
14
# File 'lib/http_stub/server/request/headers.rb', line 9

def self.create(rack_request)
  rack_request.env.each_with_object(self.new) do |(name, value), result|
    match = name.match(/^(?:HTTP_)?([A-Z0-9_]+)$/)
    result[match[1]] = value if match
  end
end