Sha256: e60f3f92f9457fed85af1228872fecf313e1bf858206a169458077cee29184e0

Contents?: true

Size: 859 Bytes

Versions: 4

Compression:

Stored size: 859 Bytes

Contents

# typed: true
# frozen_string_literal: true

module ActionDispatch
  class Request
    sig { returns(T::Hash[String, T.untyped]) }
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vigiles-0.1.5 lib/core_ext/action_dispatch/request.rb
vigiles-0.1.4 lib/core_ext/action_dispatch/request.rb
vigiles-0.1.3 lib/core_ext/action_dispatch/request.rb
vigiles-0.1.2 lib/core_ext/action_dispatch/request.rb