Class: Common::Client::Middleware::Request::ImmutableHeaders

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/common/client/middleware/request/immutable_headers.rb

Constant Summary collapse

HTTP_PROTOCOL_HEADERS =
Set.new %w[
  Accept
  Accept-Charset
  Accept-Encoding
  Accept-Language
  Accept-Ranges
  Age
  Allow
  Authorization
  Cache-Control
  Connection
  Content-Encoding
  Content-Language
  Content-Length
  Content-Location
  Content-MD5
  Content-Range
  Content-Type
  Date
  ETag
  Expect
  Expires
  From
  Host
  If-Match
  If-Modified-Since
  If-None-Match
  If-Range
  If-Unmodified-Since
  Last-Modified
  Location
  Max-Forwards
  Pragma
  Proxy-Authenticate
  Proxy-Authorization
  Range
  Referer
  Retry-After
  Server
  TE
  Trailer
  Transfer-Encoding
  Upgrade
  User-Agent
  Vary
  Via
]

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/common/client/middleware/request/immutable_headers.rb', line 58

def call(env)
  headers = {}
  env.request_headers.each do |k, v|
    if HTTP_PROTOCOL_HEADERS.include?(k)
      headers[k] = v
    else
      headers[CoreExtensions::ImmutableString.new(k)] = v
    end
  end
  env.request_headers = headers
  @app.call(env)
end