Class: ActionDispatch::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/action_dispatch/request.rb

Instance Method Summary collapse

Instance Method Details

#original_headersObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/core_ext/action_dispatch/request.rb', line 7

def original_headers
  # prefix content-type and content-length with `HTTP_` too,
  # just for uniformity. apparently the rack specification
  # requires content length and content type headers to not
  # have the `HTTP_` prefix.
  # see https://github.com/rack/rack/blob/main/SPEC.rdoc
  #
  @original_headers ||=
    begin
      original = {
        "HTTP_CONTENT_LENGTH" => get_header("CONTENT_LENGTH"),
        "HTTP_CONTENT_TYPE" => get_header("CONTENT_TYPE")
      }

      each_header do |header, value|
        next unless header.start_with?("HTTP_")

        original[header] = value
      end

      original.freeze
    end
end