Class: ActionDispatch::Http::Headers
- Defined in:
- runtime/action_dispatch/headers.rbs,
runtime/action_dispatch/headers.rb
Constant Summary collapse
- CGI_VARIABLES =
The env keys that are CGI variables rather than
HTTP_-prefixed header keys.Content-TypeandContent-Lengthare the two request headers in this set. %w[ AUTH_TYPE CONTENT_LENGTH CONTENT_TYPE GATEWAY_INTERFACE HTTPS PATH_INFO PATH_TRANSLATED QUERY_STRING REMOTE_ADDR REMOTE_HOST REMOTE_IDENT REMOTE_USER REQUEST_METHOD SCRIPT_NAME SERVER_NAME SERVER_PORT SERVER_PROTOCOL SERVER_SOFTWARE ].freeze
- HTTP_HEADER =
A lookup key that is only letters, digits, and dashes is an HTTP header name; an underscore means the caller already named an env key.
/\A[A-Za-z0-9-]+\z/- DEFAULT =
The sentinel that tells
fetch"no default was given". Object.new
Class Method Summary collapse
-
.env_key(name) ⇒ String
the env key for a wire header name.
Instance Method Summary collapse
-
#[](key) ⇒ untyped
the header value, or nil when absent.
-
#each_header {|name, value| ... } ⇒ void
yield each request header as a name and value.
-
#fetch(key, default = DEFAULT) ⇒ untyped
the header value; without a default, raises KeyError when absent.
-
#has_key?(key) ⇒ Boolean
whether the header is present.
-
#initialize(env) ⇒ Headers
constructor
wrap the request's env hash.
-
#to_h ⇒ Hash{String => untyped}
every request header as a Hash keyed by normalized name.
Constructor Details
#initialize(env) ⇒ Headers
wrap the request's env hash. The hash is read live, so a view created once sees the request's current headers.
29 |
# File 'runtime/action_dispatch/headers.rb', line 29
def initialize: (Hash[String, untyped] env) -> void
|
Class Method Details
.env_key(name) ⇒ String
the env key for a wire header name. The dispatcher uses this when copying parsed headers into the request's env hash.
102 |
# File 'runtime/action_dispatch/headers.rb', line 102
def self.env_key: (String name) -> String
|
Instance Method Details
#[](key) ⇒ untyped
the header value, or nil when absent. Accepts both an HTTP header name
(Authorization) and an env key (HTTP_AUTHORIZATION, CONTENT_TYPE).
40 |
# File 'runtime/action_dispatch/headers.rb', line 40
def []: (String key) -> untyped
|
#each_header {|name, value| ... } ⇒ void
yield each request header as a name and value. Names are normalized to
lowercase with dashes (authorization, content-type). Only header
keys are yielded; env scratch keys are skipped.
78 |
# File 'runtime/action_dispatch/headers.rb', line 78
def each_header: () { (String name, untyped value) -> void } -> void
|
#fetch(key, default = DEFAULT) ⇒ untyped
the header value; without a default, raises KeyError when absent. An empty header value is present, so it answers "" rather than the default.
53 |
# File 'runtime/action_dispatch/headers.rb', line 53
def fetch: (String key, ?untyped default) -> untyped
|
#has_key?(key) ⇒ Boolean
whether the header is present. An empty value is present; only an absent key answers false.
67 |
# File 'runtime/action_dispatch/headers.rb', line 67
def has_key?: (String key) -> bool
|