Sha256: ff5418b678378df48d2336d5f2b10c4c1ab51e09ba4c6b874f97228d16c9ebf8

Contents?: true

Size: 692 Bytes

Versions: 71

Compression:

Stored size: 692 Bytes

Contents

require 'active_support/memoizable'

module ActionDispatch
  module Http
    class Headers < ::Hash
      extend ActiveSupport::Memoizable

      def initialize(*args)
        if args.size == 1 && args[0].is_a?(Hash)
          super()
          update(args[0])
        else
          super
        end
      end

      def [](header_name)
        if include?(header_name)
          super
        else
          super(env_name(header_name))
        end
      end

      private
        # Converts a HTTP header name to an environment variable name.
        def env_name(header_name)
          "HTTP_#{header_name.upcase.gsub(/-/, '_')}"
        end
        memoize :env_name
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
actionpack-3.1.12 lib/action_dispatch/http/headers.rb
actionpack-3.1.11 lib/action_dispatch/http/headers.rb
actionpack-3.0.20 lib/action_dispatch/http/headers.rb
actionpack-3.1.10 lib/action_dispatch/http/headers.rb
actionpack-3.0.19 lib/action_dispatch/http/headers.rb
actionpack-3.1.9 lib/action_dispatch/http/headers.rb
actionpack-3.0.18 lib/action_dispatch/http/headers.rb
actionpack-3.1.8 lib/action_dispatch/http/headers.rb
actionpack-3.0.17 lib/action_dispatch/http/headers.rb
actionpack-3.1.7 lib/action_dispatch/http/headers.rb
actionpack-3.0.16 lib/action_dispatch/http/headers.rb
actionpack-3.0.15 lib/action_dispatch/http/headers.rb
actionpack-3.1.6 lib/action_dispatch/http/headers.rb
actionpack-3.0.14 lib/action_dispatch/http/headers.rb
actionpack-3.1.5 lib/action_dispatch/http/headers.rb
actionpack-3.0.13 lib/action_dispatch/http/headers.rb
actionpack-3.1.5.rc1 lib/action_dispatch/http/headers.rb
actionpack-3.0.13.rc1 lib/action_dispatch/http/headers.rb
actionpack-3.1.4 lib/action_dispatch/http/headers.rb
actionpack-3.0.12 lib/action_dispatch/http/headers.rb