Class: Rack::Request
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | lib/rack/request.rb |
Overview
Constant Summary
-
ALLOWED_SCHEMES =
# File 'lib/rack/request.rb', line 60%w(https http wss ws).freeze
Helpers
- Included
AUTHORITY, DEFAULT_PORTS, FORM_DATA_MEDIA_TYPES, FORWARDED_SCHEME_HEADERS, HTTP_FORWARDED, HTTP_X_FORWARDED_FOR, HTTP_X_FORWARDED_HOST, HTTP_X_FORWARDED_PORT, HTTP_X_FORWARDED_PROTO, HTTP_X_FORWARDED_SCHEME, HTTP_X_FORWARDED_SSL, PARSEABLE_DATA_MEDIA_TYPES
Class Attribute Summary
-
.forwarded_priority
rw
The priority when checking forwarded headers.
- .ip_filter rw
-
.x_forwarded_proto_priority
rw
The priority when checking either the
X-Forwarded-Proto
orX-Forwarded-Scheme
header for the forwarded protocol.
Class Method Summary
- .new(env) ⇒ Request constructor
Instance Attribute Summary
Helpers
- Included
#delete? | Checks the HTTP request method (or verb) to see if it was of type DELETE. |
#form_data? | Determine whether the request body contains form-data by checking the request content-type for one of the media-types: “application/x-www-form-urlencoded” or “multipart/form-data”. |
#get? | Checks the HTTP request method (or verb) to see if it was of type GET. |
#head? | Checks the HTTP request method (or verb) to see if it was of type HEAD. |
#link? | Checks the HTTP request method (or verb) to see if it was of type LINK. |
#options? | Checks the HTTP request method (or verb) to see if it was of type OPTIONS. |
#parseable_data? | Determine whether the request body contains data by checking the request media_type against registered parse-data media-types. |
#patch? | Checks the HTTP request method (or verb) to see if it was of type PATCH. |
#path_info, #path_info=, | |
#post? | Checks the HTTP request method (or verb) to see if it was of type POST. |
#put? | Checks the HTTP request method (or verb) to see if it was of type PUT. |
#script_name, #script_name=, #ssl?, | |
#trace? | Checks the HTTP request method (or verb) to see if it was of type TRACE. |
#unlink? | Checks the HTTP request method (or verb) to see if it was of type UNLINK. |
#xhr? |
Env
- Included
#env | The environment of the request. |
Instance Method Summary
Helpers
- Included
#accept_encoding, #accept_language, | |
#authority | The authority of the incoming request as defined by RFC3976. |
#base_url, #body, | |
#content_charset | The character set of the request body if a “charset” media type parameter was given, or nil if no “charset” was specified. |
#content_length, #content_type, #cookies, | |
#delete_param | |
#forwarded_authority, #forwarded_for, #forwarded_port, #fullpath, | |
#GET | Returns the data received in the query string. |
#host | Returns a formatted host, suitable for being used in a URI. |
#host_authority | The HTTP_HOST header. |
#host_with_port, | |
#hostname | Returns an address suitable for being to resolve to an address. |
#ip, #logger, | |
#media_type | The media type (type/subtype) portion of the CONTENT_TYPE header without any media type parameters. |
#media_type_params | The media type parameters provided in CONTENT_TYPE as a Hash, or an empty Hash if no CONTENT_TYPE or media-type parameters were provided. |
#params | |
#path, #port, | |
#POST | Returns the data received in the request body. |
#query_string, | |
#referer | the referer of the client. |
#referrer | Alias for Helpers#referer. |
#request_method, #scheme, | |
#server_authority | The authority as defined by the SERVER_NAME and SERVER_PORT variables. |
#server_name, #server_port, #session, #session_options, #trusted_proxy?, | |
#update_param | |
#url | Tries to return a remake of the original request URL as a string. |
#user_agent, #allowed_scheme, #default_session, #expand_param_pairs, #forwarded_priority, #forwarded_scheme, | |
#get_http_forwarded | Get an array of values set in the RFC 7239 |
#parse_http_accept_header, #parse_multipart, #parse_query, #query_parser, #reject_trusted_ip_addresses, #split_authority, #split_header, | |
#wrap_ipv6 | Assist with compatibility when processing |
#x_forwarded_proto_priority |
Env
- Included
#add_header | Add a header that may have multiple values. |
#delete_header | Delete a request specific value for |
#each_header | Loops through each key / value pair in the request specific data. |
#fetch_header | If a block is given, it yields to the block if the value hasn’t been set on the request. |
#get_header | Get a request specific value for |
#has_header? | Predicate method to test to see if |
#initialize, #initialize_copy, | |
#set_header | Set a request specific value for |
Constructor Details
.new(env) ⇒ Request
# File 'lib/rack/request.rb', line 62
def initialize(env) @env = env @params = nil end
Class Attribute Details
.forwarded_priority (rw)
The priority when checking forwarded headers. The default is [:forwarded, :x_forwarded]
, which means, check the Forwarded
header first, followed by the appropriate X-Forwarded-*
header. You can revert the priority by reversing the priority, or remove checking of either or both headers by removing elements from the array.
This should be set as appropriate in your environment based on what reverse proxies are in use. If you are not using reverse proxies, you should probably use an empty array.
# File 'lib/rack/request.rb', line 31
attr_accessor :forwarded_priority
.ip_filter (rw)
[ GitHub ]# File 'lib/rack/request.rb', line 18
attr_accessor :ip_filter
.x_forwarded_proto_priority (rw)
The priority when checking either the X-Forwarded-Proto
or X-Forwarded-Scheme
header for the forwarded protocol. The default is [:proto, :scheme]
, to try the X-Forwarded-Proto
header before the X-Forwarded-Scheme
header. ::Rack
2 had behavior similar to [:scheme, :proto]
. You can remove either or both of the entries in array to ignore that respective header.
# File 'lib/rack/request.rb', line 40
attr_accessor :x_forwarded_proto_priority
Instance Method Details
#delete_param(k)
[ GitHub ]# File 'lib/rack/request.rb', line 76
def delete_param(k) v = super @params = nil v end
#params
[ GitHub ]# File 'lib/rack/request.rb', line 67
def params @params ||= super end
#update_param(k, v)
[ GitHub ]# File 'lib/rack/request.rb', line 71
def update_param(k, v) super @params = nil end