class Headers
Ruby on Rails 7.1.6
Since v3.0.20Action Dispatch HTTP Headers
Provides access to the request’s HTTP headers from the environment.
env = { "CONTENT_TYPE" => "text/plain", "HTTP_USER_AGENT" => "curl/7.43.0" } headers = ActionDispatch::Http::Headers.from_hash(env) headers["Content-Type"] # => "text/plain" headers["User-Agent"] # => "curl/7.43.0"
Also note that when headers are mapped to CGI-like variables by the Rack server, both dashes and underscores are converted to underscores. This ambiguity cannot be resolved at this stage anymore. Both underscores and dashes have to be interpreted as if they were originally sent as dashes.
# GET / HTTP/1.1 # ... # User-Agent: curl/7.43.0 # X_Custom_Header: token headers["X_Custom_Header"] # => nil headers["X-Custom-Header"] # => "token"
Inherits from
Includes
Constants
Methods (defined here)
Private methods
(1)
Implementation detail — not part of the public API.
- # env_name
Methods (inherited)
From Enumerable (14)
- # compact_blank
- # exclude?
- # excluding
- # in_order_of
- # including
- # index_by
- # index_with
- # many?
- # maximum
- # minimum
- # pick
- # pluck
- # sole
- # without
From Object (17)
- # acts_like?
- # blank?
- # deep_dup
- # duplicable?
- # html_safe?
- # in?
- # instance_values
- # instance_variable_names
- # presence
- # presence_in
- # present?
- # to_param
- # to_query
- # try
- # try!
- # with
- # with_options