ok
Direktori : /opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Request/ |
Current File : //opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Request/Helpers.html |
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>module Rack::Request::Helpers - rack-2.2.8 Documentation</title> <script type="text/javascript"> var rdoc_rel_prefix = "../../"; var index_rel_prefix = "../../"; </script> <script src="../../js/navigation.js" defer></script> <script src="../../js/search.js" defer></script> <script src="../../js/search_index.js" defer></script> <script src="../../js/searcher.js" defer></script> <script src="../../js/darkfish.js" defer></script> <link href="../../css/fonts.css" rel="stylesheet"> <link href="../../css/rdoc.css" rel="stylesheet"> <body id="top" role="document" class="module"> <nav role="navigation"> <div id="project-navigation"> <div id="home-section" role="region" title="Quick navigation" class="nav-section"> <h2> <a href="../../index.html" rel="home">Home</a> </h2> <div id="table-of-contents-navigation"> <a href="../../table_of_contents.html#pages">Pages</a> <a href="../../table_of_contents.html#classes">Classes</a> <a href="../../table_of_contents.html#methods">Methods</a> </div> </div> <div id="search-section" role="search" class="project-section initially-hidden"> <form action="#" method="get" accept-charset="utf-8"> <div id="search-field-wrapper"> <input id="search-field" role="combobox" aria-label="Search" aria-autocomplete="list" aria-controls="search-results" type="text" name="search" placeholder="Search" spellcheck="false" title="Type to search, Up and Down to navigate, Enter to load"> </div> <ul id="search-results" aria-label="Search Results" aria-busy="false" aria-expanded="false" aria-atomic="false" class="initially-hidden"></ul> </form> </div> </div> <div id="class-metadata"> <!-- Method Quickref --> <div id="method-list-section" class="nav-section"> <h3>Methods</h3> <ul class="link-list" role="directory"> <li ><a href="#method-i-GET">#GET</a> <li ><a href="#method-i-POST">#POST</a> <li ><a href="#method-i-5B-5D">#[]</a> <li ><a href="#method-i-5B-5D-3D">#[]=</a> <li ><a href="#method-i-accept_encoding">#accept_encoding</a> <li ><a href="#method-i-accept_language">#accept_language</a> <li ><a href="#method-i-allowed_scheme">#allowed_scheme</a> <li ><a href="#method-i-authority">#authority</a> <li ><a href="#method-i-base_url">#base_url</a> <li ><a href="#method-i-body">#body</a> <li ><a href="#method-i-content_charset">#content_charset</a> <li ><a href="#method-i-content_length">#content_length</a> <li ><a href="#method-i-content_type">#content_type</a> <li ><a href="#method-i-cookies">#cookies</a> <li ><a href="#method-i-default_session">#default_session</a> <li ><a href="#method-i-delete-3F">#delete?</a> <li ><a href="#method-i-delete_param">#delete_param</a> <li ><a href="#method-i-extract_proto_header">#extract_proto_header</a> <li ><a href="#method-i-form_data-3F">#form_data?</a> <li ><a href="#method-i-forwarded_authority">#forwarded_authority</a> <li ><a href="#method-i-forwarded_for">#forwarded_for</a> <li ><a href="#method-i-forwarded_port">#forwarded_port</a> <li ><a href="#method-i-forwarded_scheme">#forwarded_scheme</a> <li ><a href="#method-i-fullpath">#fullpath</a> <li ><a href="#method-i-get-3F">#get?</a> <li ><a href="#method-i-head-3F">#head?</a> <li ><a href="#method-i-host">#host</a> <li ><a href="#method-i-host_authority">#host_authority</a> <li ><a href="#method-i-host_with_port">#host_with_port</a> <li ><a href="#method-i-hostname">#hostname</a> <li ><a href="#method-i-ip">#ip</a> <li ><a href="#method-i-link-3F">#link?</a> <li ><a href="#method-i-logger">#logger</a> <li ><a href="#method-i-media_type">#media_type</a> <li ><a href="#method-i-media_type_params">#media_type_params</a> <li ><a href="#method-i-multithread-3F">#multithread?</a> <li ><a href="#method-i-options-3F">#options?</a> <li ><a href="#method-i-params">#params</a> <li ><a href="#method-i-parse_http_accept_header">#parse_http_accept_header</a> <li ><a href="#method-i-parse_multipart">#parse_multipart</a> <li ><a href="#method-i-parse_query">#parse_query</a> <li ><a href="#method-i-parseable_data-3F">#parseable_data?</a> <li ><a href="#method-i-patch-3F">#patch?</a> <li ><a href="#method-i-path">#path</a> <li ><a href="#method-i-path_info">#path_info</a> <li ><a href="#method-i-path_info-3D">#path_info=</a> <li ><a href="#method-i-port">#port</a> <li ><a href="#method-i-post-3F">#post?</a> <li ><a href="#method-i-put-3F">#put?</a> <li ><a href="#method-i-query_parser">#query_parser</a> <li ><a href="#method-i-query_string">#query_string</a> <li ><a href="#method-i-referer">#referer</a> <li ><a href="#method-i-referrer">#referrer</a> <li ><a href="#method-i-reject_trusted_ip_addresses">#reject_trusted_ip_addresses</a> <li ><a href="#method-i-request_method">#request_method</a> <li ><a href="#method-i-scheme">#scheme</a> <li ><a href="#method-i-script_name">#script_name</a> <li ><a href="#method-i-script_name-3D">#script_name=</a> <li ><a href="#method-i-server_authority">#server_authority</a> <li ><a href="#method-i-server_name">#server_name</a> <li ><a href="#method-i-server_port">#server_port</a> <li ><a href="#method-i-session">#session</a> <li ><a href="#method-i-session_options">#session_options</a> <li ><a href="#method-i-split_authority">#split_authority</a> <li ><a href="#method-i-split_header">#split_header</a> <li ><a href="#method-i-ssl-3F">#ssl?</a> <li ><a href="#method-i-trace-3F">#trace?</a> <li ><a href="#method-i-trusted_proxy-3F">#trusted_proxy?</a> <li ><a href="#method-i-unlink-3F">#unlink?</a> <li ><a href="#method-i-update_param">#update_param</a> <li ><a href="#method-i-url">#url</a> <li ><a href="#method-i-user_agent">#user_agent</a> <li ><a href="#method-i-values_at">#values_at</a> <li ><a href="#method-i-wrap_ipv6">#wrap_ipv6</a> <li ><a href="#method-i-xhr-3F">#xhr?</a> </ul> </div> </div> </nav> <main role="main" aria-labelledby="module-Rack::Request::Helpers"> <h1 id="module-Rack::Request::Helpers" class="module"> module Rack::Request::Helpers </h1> <section class="description"> </section> <section id="5Buntitled-5D" class="documentation-section"> <section class="constants-list"> <header> <h3>Constants</h3> </header> <dl> <dt id="AUTHORITY">AUTHORITY <dd> <dt id="DEFAULT_PORTS">DEFAULT_PORTS <dd><p>Default ports depending on scheme. Used to decide whether or not to include the port in a generated URI.</p> <dt id="FORM_DATA_MEDIA_TYPES">FORM_DATA_MEDIA_TYPES <dd><p>The set of form-data media-types. Requests that do not indicate one of the media types present in this list will not be eligible for form-data / param parsing.</p> <dt id="HTTP_X_FORWARDED_FOR">HTTP_X_FORWARDED_FOR <dd><p>The address of the client which connected to the proxy.</p> <dt id="HTTP_X_FORWARDED_HOST">HTTP_X_FORWARDED_HOST <dd><p>The contents of the host/:authority header sent to the proxy.</p> <dt id="HTTP_X_FORWARDED_PORT">HTTP_X_FORWARDED_PORT <dd><p>The port used to connect to the proxy.</p> <dt id="HTTP_X_FORWARDED_PROTO">HTTP_X_FORWARDED_PROTO <dd><p>The protocol used to connect to the proxy.</p> <dt id="HTTP_X_FORWARDED_SCHEME">HTTP_X_FORWARDED_SCHEME <dd><p>The value of the scheme sent to the proxy.</p> <dt id="HTTP_X_FORWARDED_SSL">HTTP_X_FORWARDED_SSL <dd><p>Another way for specifing https scheme was used.</p> <dt id="PARSEABLE_DATA_MEDIA_TYPES">PARSEABLE_DATA_MEDIA_TYPES <dd><p>The set of media-types. Requests that do not indicate one of the media types present in this list will not be eligible for param parsing like soap attachments or generic multiparts</p> </dl> </section> <section id="public-instance-5Buntitled-5D-method-details" class="method-section"> <header> <h3>Public Instance Methods</h3> </header> <div id="method-i-GET" class="method-detail "> <div class="method-heading"> <span class="method-name">GET</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Returns the data received in the query string.</p> <div class="method-source-code" id="GET-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 426</span> <span class="ruby-keyword">def</span> <span class="ruby-constant">GET</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier ruby-title">get_header</span>(<span class="ruby-constant">RACK_REQUEST_QUERY_STRING</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">query_string</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_REQUEST_QUERY_HASH</span>) <span class="ruby-keyword">else</span> <span class="ruby-identifier">query_hash</span> = <span class="ruby-identifier">parse_query</span>(<span class="ruby-identifier">query_string</span>, <span class="ruby-string">'&;'</span>) <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">RACK_REQUEST_QUERY_STRING</span>, <span class="ruby-identifier">query_string</span>) <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">RACK_REQUEST_QUERY_HASH</span>, <span class="ruby-identifier">query_hash</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-POST" class="method-detail "> <div class="method-heading"> <span class="method-name">POST</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Returns the data received in the request body.</p> <p>This method support both application/x-www-form-urlencoded and multipart/form-data.</p> <div class="method-source-code" id="POST-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 440</span> <span class="ruby-keyword">def</span> <span class="ruby-constant">POST</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier ruby-title">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>).<span class="ruby-identifier">nil?</span> <span class="ruby-identifier">raise</span> <span class="ruby-string">"Missing rack.input"</span> <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_REQUEST_FORM_INPUT</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>) <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_REQUEST_FORM_HASH</span>) <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">form_data?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">parseable_data?</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">RACK_REQUEST_FORM_HASH</span>, <span class="ruby-identifier">parse_multipart</span>) <span class="ruby-identifier">form_vars</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>).<span class="ruby-identifier">read</span> <span class="ruby-comment"># Fix for Safari Ajax postings that always append \0</span> <span class="ruby-comment"># form_vars.sub!(/\0\z/, '') # performance replacement:</span> <span class="ruby-identifier">form_vars</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">-1</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">form_vars</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">"\0"</span>) <span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_REQUEST_FORM_VARS</span>, <span class="ruby-identifier">form_vars</span> <span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_REQUEST_FORM_HASH</span>, <span class="ruby-identifier">parse_query</span>(<span class="ruby-identifier">form_vars</span>, <span class="ruby-string">'&'</span>) <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>).<span class="ruby-identifier">rewind</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_REQUEST_FORM_INPUT</span>, <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>) <span class="ruby-identifier">get_header</span> <span class="ruby-constant">RACK_REQUEST_FORM_HASH</span> <span class="ruby-keyword">else</span> {} <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-5B-5D" class="method-detail "> <div class="method-heading"> <span class="method-name">[]</span><span class="method-args">(key)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>shortcut for <code>request.params[key]</code></p> <div class="method-source-code" id="5B-5D-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 532</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">key</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">$VERBOSE</span> <span class="ruby-identifier">warn</span>(<span class="ruby-string">"Request#[] is deprecated and will be removed in a future version of Rack. Please use request.params[] instead"</span>) <span class="ruby-keyword">end</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-5B-5D-3D" class="method-detail "> <div class="method-heading"> <span class="method-name">[]=</span><span class="method-args">(key, value)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>shortcut for <code>request.params[key] = value</code></p> <p>Note that modifications will not be persisted in the env. Use <a href="Helpers.html#method-i-update_param"><code>update_param</code></a> or <a href="Helpers.html#method-i-delete_param"><code>delete_param</code></a> if you want to destructively modify params.</p> <div class="method-source-code" id="5B-5D-3D-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 543</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">$VERBOSE</span> <span class="ruby-identifier">warn</span>(<span class="ruby-string">"Request#[]= is deprecated and will be removed in a future version of Rack. Please use request.params[]= instead"</span>) <span class="ruby-keyword">end</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-accept_encoding" class="method-detail "> <div class="method-heading"> <span class="method-name">accept_encoding</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="accept_encoding-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 519</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">accept_encoding</span> <span class="ruby-identifier">parse_http_accept_header</span>(<span class="ruby-identifier">get_header</span>(<span class="ruby-string">"HTTP_ACCEPT_ENCODING"</span>)) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-accept_language" class="method-detail "> <div class="method-heading"> <span class="method-name">accept_language</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="accept_language-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 523</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">accept_language</span> <span class="ruby-identifier">parse_http_accept_header</span>(<span class="ruby-identifier">get_header</span>(<span class="ruby-string">"HTTP_ACCEPT_LANGUAGE"</span>)) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-authority" class="method-detail "> <div class="method-heading"> <span class="method-name">authority</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The authority of the incoming request as defined by RFC3976. <a href="https://tools.ietf.org/html/rfc3986#section-3.2">tools.ietf.org/html/rfc3986#section-3.2</a></p> <p>In HTTP/1, this is the `host` header. In HTTP/2, this is the `:authority` pseudo-header.</p> <div class="method-source-code" id="authority-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 227</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">authority</span> <span class="ruby-identifier">forwarded_authority</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">host_authority</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">server_authority</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-base_url" class="method-detail "> <div class="method-heading"> <span class="method-name">base_url</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="base_url-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 502</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">base_url</span> <span class="ruby-node">"#{scheme}://#{host_with_port}"</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-body" class="method-detail "> <div class="method-heading"> <span class="method-name">body</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="body-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 150</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">body</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_INPUT</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-content_charset" class="method-detail "> <div class="method-heading"> <span class="method-name">content_charset</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The character set of the request body if a “charset” media type parameter was given, or nil if no “charset” was specified. Note that, per RFC2616, text/* media types that specify no explicit charset are to be considered ISO-8859-1.</p> <div class="method-source-code" id="content_charset-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 400</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">content_charset</span> <span class="ruby-identifier">media_type_params</span>[<span class="ruby-string">'charset'</span>] <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-content_length" class="method-detail "> <div class="method-heading"> <span class="method-name">content_length</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="content_length-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 159</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">content_length</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-string">'CONTENT_LENGTH'</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-content_type" class="method-detail "> <div class="method-heading"> <span class="method-name">content_type</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="content_type-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 271</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">content_type</span> <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-string">'CONTENT_TYPE'</span>) <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">content_type</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-cookies" class="method-detail "> <div class="method-heading"> <span class="method-name">cookies</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="cookies-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 256</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">cookies</span> <span class="ruby-identifier">hash</span> = <span class="ruby-identifier">fetch_header</span>(<span class="ruby-constant">RACK_REQUEST_COOKIE_HASH</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">set_header</span>(<span class="ruby-identifier">key</span>, {}) <span class="ruby-keyword">end</span> <span class="ruby-identifier">string</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_COOKIE</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">string</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_REQUEST_COOKIE_STRING</span>) <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">replace</span> <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_cookies_header</span>(<span class="ruby-identifier">string</span>) <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">RACK_REQUEST_COOKIE_STRING</span>, <span class="ruby-identifier">string</span>) <span class="ruby-keyword">end</span> <span class="ruby-identifier">hash</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-delete-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">delete?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type DELETE</p> <div class="method-source-code" id="delete-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 181</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">DELETE</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-delete_param" class="method-detail "> <div class="method-heading"> <span class="method-name">delete_param</span><span class="method-args">(k)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Destructively delete a parameter, whether it's in <a href="Helpers.html#method-i-GET"><code>GET</code></a> or <a href="Helpers.html#method-i-POST"><code>POST</code></a>. Returns the value of the deleted parameter.</p> <p>If the parameter is in both <a href="Helpers.html#method-i-GET"><code>GET</code></a> and <a href="Helpers.html#method-i-POST"><code>POST</code></a>, the <a href="Helpers.html#method-i-POST"><code>POST</code></a> value takes precedence since that's how <a href="Helpers.html#method-i-params"><code>params</code></a> works.</p> <p><code>env['rack.input']</code> is not touched.</p> <div class="method-source-code" id="delete_param-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 497</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_param</span>(<span class="ruby-identifier">k</span>) <span class="ruby-identifier">post_value</span>, <span class="ruby-identifier">get_value</span> = <span class="ruby-keyword">self</span>.<span class="ruby-constant">POST</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>), <span class="ruby-keyword">self</span>.<span class="ruby-constant">GET</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>) <span class="ruby-identifier">post_value</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">get_value</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-form_data-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">form_data?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>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”. The list of form-data media types can be modified through the <code>FORM_DATA_MEDIA_TYPES</code> array.</p> <p>A request body is also assumed to contain form-data when no Content-Type header is provided and the <a href="Helpers.html#method-i-request_method"><code>request_method</code></a> is <a href="Helpers.html#method-i-POST"><code>POST</code></a>.</p> <div class="method-source-code" id="form_data-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 412</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">form_data?</span> <span class="ruby-identifier">type</span> = <span class="ruby-identifier">media_type</span> <span class="ruby-identifier">meth</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_METHODOVERRIDE_ORIGINAL_METHOD</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">REQUEST_METHOD</span>) (<span class="ruby-identifier">meth</span> <span class="ruby-operator">==</span> <span class="ruby-constant">POST</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">type</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">FORM_DATA_MEDIA_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">type</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-forwarded_authority" class="method-detail "> <div class="method-heading"> <span class="method-name">forwarded_authority</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="forwarded_authority-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 344</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">forwarded_authority</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_HOST</span>) <span class="ruby-identifier">wrap_ipv6</span>(<span class="ruby-identifier">split_header</span>(<span class="ruby-identifier">value</span>).<span class="ruby-identifier">first</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-forwarded_for" class="method-detail "> <div class="method-heading"> <span class="method-name">forwarded_for</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="forwarded_for-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 330</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">forwarded_for</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_FOR</span>) <span class="ruby-identifier">split_header</span>(<span class="ruby-identifier">value</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">authority</span><span class="ruby-operator">|</span> <span class="ruby-identifier">split_authority</span>(<span class="ruby-identifier">wrap_ipv6</span>(<span class="ruby-identifier">authority</span>))[<span class="ruby-value">1</span>] <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-forwarded_port" class="method-detail "> <div class="method-heading"> <span class="method-name">forwarded_port</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="forwarded_port-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 338</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">forwarded_port</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_PORT</span>) <span class="ruby-identifier">split_header</span>(<span class="ruby-identifier">value</span>).<span class="ruby-identifier">map</span>(<span class="ruby-operator">&</span><span class="ruby-value">:to_i</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-fullpath" class="method-detail "> <div class="method-heading"> <span class="method-name">fullpath</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="fullpath-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 515</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fullpath</span> <span class="ruby-identifier">query_string</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">path</span> <span class="ruby-operator">:</span> <span class="ruby-node">"#{path}?#{query_string}"</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-get-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">get?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type <a href="Helpers.html#method-i-GET"><code>GET</code></a></p> <div class="method-source-code" id="get-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 184</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">GET</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-head-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">head?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type HEAD</p> <div class="method-source-code" id="head-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 187</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">head?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">HEAD</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-host" class="method-detail "> <div class="method-heading"> <span class="method-name">host</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Returns a formatted host, suitable for being used in a URI.</p> <div class="method-source-code" id="host-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 296</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">host</span> <span class="ruby-identifier">split_authority</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">authority</span>)[<span class="ruby-value">0</span>] <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-host_authority" class="method-detail "> <div class="method-heading"> <span class="method-name">host_authority</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The `HTTP_HOST` header.</p> <div class="method-source-code" id="host_authority-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 281</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">host_authority</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_HOST</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-host_with_port" class="method-detail "> <div class="method-heading"> <span class="method-name">host_with_port</span><span class="method-args">(authority = self.authority)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="host_with_port-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 285</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">host_with_port</span>(<span class="ruby-identifier">authority</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authority</span>) <span class="ruby-identifier">host</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">port</span> = <span class="ruby-identifier">split_authority</span>(<span class="ruby-identifier">authority</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span> <span class="ruby-operator">==</span> <span class="ruby-constant">DEFAULT_PORTS</span>[<span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span>] <span class="ruby-identifier">host</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">authority</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-hostname" class="method-detail "> <div class="method-heading"> <span class="method-name">hostname</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Returns an address suitable for being to resolve to an address. In the case of a domain name or IPv4 address, the result is the same as <code>host</code>. In the case of IPv6 or future address formats, the square brackets are removed.</p> <div class="method-source-code" id="hostname-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 304</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hostname</span> <span class="ruby-identifier">split_authority</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">authority</span>)[<span class="ruby-value">1</span>] <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-ip" class="method-detail "> <div class="method-heading"> <span class="method-name">ip</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="ip-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 354</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ip</span> <span class="ruby-identifier">remote_addresses</span> = <span class="ruby-identifier">split_header</span>(<span class="ruby-identifier">get_header</span>(<span class="ruby-string">'REMOTE_ADDR'</span>)) <span class="ruby-identifier">external_addresses</span> = <span class="ruby-identifier">reject_trusted_ip_addresses</span>(<span class="ruby-identifier">remote_addresses</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">external_addresses</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">external_addresses</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">forwarded_for</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">forwarded_for</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">forwarded_for</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-comment"># The forwarded for addresses are ordered: client, proxy1, proxy2.</span> <span class="ruby-comment"># So we reject all the trusted addresses (proxy*) and return the</span> <span class="ruby-comment"># last client. Or if we trust everyone, we just return the first</span> <span class="ruby-comment"># address.</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">reject_trusted_ip_addresses</span>(<span class="ruby-identifier">forwarded_for</span>).<span class="ruby-identifier">last</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">forwarded_for</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-comment"># If all the addresses are trusted, and we aren't forwarded, just return</span> <span class="ruby-comment"># the first remote address, which represents the source of the request.</span> <span class="ruby-identifier">remote_addresses</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-link-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">link?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type LINK</p> <div class="method-source-code" id="link-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 193</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">link?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">LINK</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-logger" class="method-detail "> <div class="method-heading"> <span class="method-name">logger</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="logger-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 160</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">logger</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_LOGGER</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-media_type" class="method-detail "> <div class="method-heading"> <span class="method-name">media_type</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The media type (type/subtype) portion of the CONTENT_TYPE header without any media type parameters. e.g., when CONTENT_TYPE is “text/plain;charset=utf-8”, the media-type is “text/plain”.</p> <p>For more information on the use of media types in HTTP, see: <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7">www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7</a></p> <div class="method-source-code" id="media_type-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 383</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">media_type</span> <span class="ruby-constant">MediaType</span>.<span class="ruby-identifier">type</span>(<span class="ruby-identifier">content_type</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-media_type_params" class="method-detail "> <div class="method-heading"> <span class="method-name">media_type_params</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>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. e.g., when the CONTENT_TYPE is “text/plain;charset=utf-8”, this method responds with the following Hash:</p> <pre class="ruby">{ <span class="ruby-string">'charset'</span> <span class="ruby-operator">=></span> <span class="ruby-string">'utf-8'</span> } </pre> <div class="method-source-code" id="media_type_params-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 392</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">media_type_params</span> <span class="ruby-constant">MediaType</span>.<span class="ruby-identifier">params</span>(<span class="ruby-identifier">content_type</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-multithread-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">multithread?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="multithread-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 162</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">multithread?</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_MULTITHREAD</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-options-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">options?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type OPTIONS</p> <div class="method-source-code" id="options-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 190</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">options?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">OPTIONS</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-params" class="method-detail "> <div class="method-heading"> <span class="method-name">params</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The union of <a href="Helpers.html#method-i-GET"><code>GET</code></a> and <a href="Helpers.html#method-i-POST"><code>POST</code></a> data.</p> <p>Note that modifications will not be persisted in the env. Use <a href="Helpers.html#method-i-update_param"><code>update_param</code></a> or <a href="Helpers.html#method-i-delete_param"><code>delete_param</code></a> if you want to destructively modify params.</p> <div class="method-source-code" id="params-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 468</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">params</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">GET</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-keyword">self</span>.<span class="ruby-constant">POST</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-parseable_data-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">parseable_data?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Determine whether the request body contains data by checking the request <a href="Helpers.html#method-i-media_type"><code>media_type</code></a> against registered parse-data media-types</p> <div class="method-source-code" id="parseable_data-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 421</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parseable_data?</span> <span class="ruby-constant">PARSEABLE_DATA_MEDIA_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">media_type</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-patch-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">patch?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type PATCH</p> <div class="method-source-code" id="patch-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 196</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">patch?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PATCH</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-path" class="method-detail "> <div class="method-heading"> <span class="method-name">path</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="path-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 511</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path</span> <span class="ruby-identifier">script_name</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">path_info</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-path_info" class="method-detail "> <div class="method-heading"> <span class="method-name">path_info</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="path_info-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 154</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path_info</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">PATH_INFO</span>).<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-path_info-3D" class="method-detail "> <div class="method-heading"> <span class="method-name">path_info=</span><span class="method-args">(s)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="path_info-3D-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 155</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path_info=</span>(<span class="ruby-identifier">s</span>); <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">PATH_INFO</span>, <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-port" class="method-detail "> <div class="method-heading"> <span class="method-name">port</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="port-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 308</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">port</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">authority</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">authority</span> <span class="ruby-identifier">_</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">port</span> = <span class="ruby-identifier">split_authority</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">authority</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">port</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">forwarded_port</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">forwarded_port</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">forwarded_port</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">scheme</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span> = <span class="ruby-constant">DEFAULT_PORTS</span>[<span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span>] <span class="ruby-keyword">return</span> <span class="ruby-identifier">port</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">server_port</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-post-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">post?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type <a href="Helpers.html#method-i-POST"><code>POST</code></a></p> <div class="method-source-code" id="post-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 199</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">post?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">POST</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-put-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">put?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type PUT</p> <div class="method-source-code" id="put-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 202</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">put?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PUT</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-query_string" class="method-detail "> <div class="method-heading"> <span class="method-name">query_string</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="query_string-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 158</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">query_string</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">QUERY_STRING</span>).<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-referer" class="method-detail "> <div class="method-heading"> <span class="method-name">referer</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>the referer of the client</p> <div class="method-source-code" id="referer-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 165</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">referer</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-string">'HTTP_REFERER'</span>) <span class="ruby-keyword">end</span></pre> </div> </div> <div class="aliases"> Also aliased as: <a href="Helpers.html#method-i-referrer">referrer</a> </div> </div> <div id="method-i-referrer" class="method-detail method-alias"> <div class="method-heading"> <span class="method-name">referrer</span><span class="method-args">()</span> </div> <div class="method-description"> </div> <div class="aliases"> Alias for: <a href="Helpers.html#method-i-referer">referer</a> </div> </div> <div id="method-i-request_method" class="method-detail "> <div class="method-heading"> <span class="method-name">request_method</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="request_method-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 157</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">request_method</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">REQUEST_METHOD</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-scheme" class="method-detail "> <div class="method-heading"> <span class="method-name">scheme</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="scheme-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 210</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">scheme</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTPS</span>) <span class="ruby-operator">==</span> <span class="ruby-string">'on'</span> <span class="ruby-string">'https'</span> <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_SSL</span>) <span class="ruby-operator">==</span> <span class="ruby-string">'on'</span> <span class="ruby-string">'https'</span> <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">forwarded_scheme</span> <span class="ruby-identifier">forwarded_scheme</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">RACK_URL_SCHEME</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-script_name" class="method-detail "> <div class="method-heading"> <span class="method-name">script_name</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="script_name-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 151</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">script_name</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">SCRIPT_NAME</span>).<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-script_name-3D" class="method-detail "> <div class="method-heading"> <span class="method-name">script_name=</span><span class="method-args">(s)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="script_name-3D-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 152</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">script_name=</span>(<span class="ruby-identifier">s</span>); <span class="ruby-identifier">set_header</span>(<span class="ruby-constant">SCRIPT_NAME</span>, <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-server_authority" class="method-detail "> <div class="method-heading"> <span class="method-name">server_authority</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>The authority as defined by the `SERVER_NAME` and `SERVER_PORT` variables.</p> <div class="method-source-code" id="server_authority-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 233</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">server_authority</span> <span class="ruby-identifier">host</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">server_name</span> <span class="ruby-identifier">port</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">server_port</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">host</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span> <span class="ruby-node">"#{host}:#{port}"</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">host</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-server_name" class="method-detail "> <div class="method-heading"> <span class="method-name">server_name</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="server_name-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 246</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">server_name</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">SERVER_NAME</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-server_port" class="method-detail "> <div class="method-heading"> <span class="method-name">server_port</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="server_port-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 250</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">server_port</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">port</span> = <span class="ruby-identifier">get_header</span>(<span class="ruby-constant">SERVER_PORT</span>) <span class="ruby-constant">Integer</span>(<span class="ruby-identifier">port</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-session" class="method-detail "> <div class="method-heading"> <span class="method-name">session</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="session-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 168</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session</span> <span class="ruby-identifier">fetch_header</span>(<span class="ruby-constant">RACK_SESSION</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_SESSION</span>, <span class="ruby-identifier">default_session</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-session_options" class="method-detail "> <div class="method-heading"> <span class="method-name">session_options</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="session_options-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 174</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">session_options</span> <span class="ruby-identifier">fetch_header</span>(<span class="ruby-constant">RACK_SESSION_OPTIONS</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">set_header</span> <span class="ruby-constant">RACK_SESSION_OPTIONS</span>, {} <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-ssl-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">ssl?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="ssl-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 350</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ssl?</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-string">'https'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">==</span> <span class="ruby-string">'wss'</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-trace-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">trace?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type TRACE</p> <div class="method-source-code" id="trace-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 205</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">trace?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">TRACE</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-trusted_proxy-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">trusted_proxy?</span><span class="method-args">(ip)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="trusted_proxy-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 527</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">trusted_proxy?</span>(<span class="ruby-identifier">ip</span>) <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">ip_filter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">ip</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-unlink-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">unlink?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Checks the HTTP request method (or verb) to see if it was of type UNLINK</p> <div class="method-source-code" id="unlink-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 208</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unlink?</span>; <span class="ruby-identifier">request_method</span> <span class="ruby-operator">==</span> <span class="ruby-constant">UNLINK</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-update_param" class="method-detail "> <div class="method-heading"> <span class="method-name">update_param</span><span class="method-args">(k, v)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Destructively update a parameter, whether it's in <a href="Helpers.html#method-i-GET"><code>GET</code></a> and/or <a href="Helpers.html#method-i-POST"><code>POST</code></a>. Returns nil.</p> <p>The parameter is updated wherever it was previous defined, so <a href="Helpers.html#method-i-GET"><code>GET</code></a>, <a href="Helpers.html#method-i-POST"><code>POST</code></a>, or both. If it wasn't previously defined, it's inserted into <a href="Helpers.html#method-i-GET"><code>GET</code></a>.</p> <p><code>env['rack.input']</code> is not touched.</p> <div class="method-source-code" id="update_param-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 477</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update_param</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>) <span class="ruby-identifier">found</span> = <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">GET</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-identifier">found</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">GET</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">POST</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-identifier">found</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">POST</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">found</span> <span class="ruby-keyword">self</span>.<span class="ruby-constant">GET</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-url" class="method-detail "> <div class="method-heading"> <span class="method-name">url</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Tries to return a remake of the original request URL as a string.</p> <div class="method-source-code" id="url-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 507</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">url</span> <span class="ruby-identifier">base_url</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">fullpath</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-user_agent" class="method-detail "> <div class="method-heading"> <span class="method-name">user_agent</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="user_agent-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 161</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">user_agent</span>; <span class="ruby-identifier">get_header</span>(<span class="ruby-string">'HTTP_USER_AGENT'</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-values_at" class="method-detail "> <div class="method-heading"> <span class="method-name">values_at</span><span class="method-args">(*keys)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>like Hash#values_at</p> <div class="method-source-code" id="values_at-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 552</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">values_at</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">keys</span>) <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">key</span>] } <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-xhr-3F" class="method-detail "> <div class="method-heading"> <span class="method-name">xhr?</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="xhr-3F-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 276</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">xhr?</span> <span class="ruby-identifier">get_header</span>(<span class="ruby-string">"HTTP_X_REQUESTED_WITH"</span>) <span class="ruby-operator">==</span> <span class="ruby-string">"XMLHttpRequest"</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> </section> <section id="private-instance-5Buntitled-5D-method-details" class="method-section"> <header> <h3>Private Instance Methods</h3> </header> <div id="method-i-allowed_scheme" class="method-detail "> <div class="method-heading"> <span class="method-name">allowed_scheme</span><span class="method-args">(header)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="allowed_scheme-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 641</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">allowed_scheme</span>(<span class="ruby-identifier">header</span>) <span class="ruby-identifier">header</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">ALLOWED_SCHEMES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">header</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-default_session" class="method-detail "> <div class="method-heading"> <span class="method-name">default_session</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="default_session-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 558</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">default_session</span>; {}; <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-extract_proto_header" class="method-detail "> <div class="method-heading"> <span class="method-name">extract_proto_header</span><span class="method-args">(header)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="extract_proto_header-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 645</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">extract_proto_header</span>(<span class="ruby-identifier">header</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">header</span> <span class="ruby-keyword">if</span> (<span class="ruby-identifier">comma_index</span> = <span class="ruby-identifier">header</span>.<span class="ruby-identifier">index</span>(<span class="ruby-string">','</span>)) <span class="ruby-identifier">header</span>[<span class="ruby-value">0</span>, <span class="ruby-identifier">comma_index</span>] <span class="ruby-keyword">else</span> <span class="ruby-identifier">header</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-forwarded_scheme" class="method-detail "> <div class="method-heading"> <span class="method-name">forwarded_scheme</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="forwarded_scheme-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 636</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">forwarded_scheme</span> <span class="ruby-identifier">allowed_scheme</span>(<span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_SCHEME</span>)) <span class="ruby-operator">||</span> <span class="ruby-identifier">allowed_scheme</span>(<span class="ruby-identifier">extract_proto_header</span>(<span class="ruby-identifier">get_header</span>(<span class="ruby-constant">HTTP_X_FORWARDED_PROTO</span>))) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-parse_http_accept_header" class="method-detail "> <div class="method-heading"> <span class="method-name">parse_http_accept_header</span><span class="method-args">(header)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="parse_http_accept_header-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 574</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_http_accept_header</span>(<span class="ruby-identifier">header</span>) <span class="ruby-identifier">header</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">","</span>).<span class="ruby-identifier">each</span>(<span class="ruby-operator">&</span><span class="ruby-value">:strip!</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span> <span class="ruby-identifier">attribute</span>, <span class="ruby-identifier">parameters</span> = <span class="ruby-identifier">part</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">";"</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">each</span>(<span class="ruby-operator">&</span><span class="ruby-value">:strip!</span>) <span class="ruby-identifier">quality</span> = <span class="ruby-value">1.0</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parameters</span> <span class="ruby-keyword">and</span> <span class="ruby-regexp">/\Aq=([\d.]+)/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">parameters</span> <span class="ruby-identifier">quality</span> = <span class="ruby-node">$1</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-keyword">end</span> [<span class="ruby-identifier">attribute</span>, <span class="ruby-identifier">quality</span>] <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-parse_multipart" class="method-detail "> <div class="method-heading"> <span class="method-name">parse_multipart</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="parse_multipart-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 593</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_multipart</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Multipart</span>.<span class="ruby-identifier">extract_multipart</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">query_parser</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-parse_query" class="method-detail "> <div class="method-heading"> <span class="method-name">parse_query</span><span class="method-args">(qs, d = '&')</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="parse_query-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 589</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">d</span> = <span class="ruby-string">'&'</span>) <span class="ruby-identifier">query_parser</span>.<span class="ruby-identifier">parse_nested_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">d</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-query_parser" class="method-detail "> <div class="method-heading"> <span class="method-name">query_parser</span><span class="method-args">()</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="query_parser-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 585</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">query_parser</span> <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">default_query_parser</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-reject_trusted_ip_addresses" class="method-detail "> <div class="method-heading"> <span class="method-name">reject_trusted_ip_addresses</span><span class="method-args">(ip_addresses)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="reject_trusted_ip_addresses-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 632</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">reject_trusted_ip_addresses</span>(<span class="ruby-identifier">ip_addresses</span>) <span class="ruby-identifier">ip_addresses</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">ip</span><span class="ruby-operator">|</span> <span class="ruby-identifier">trusted_proxy?</span>(<span class="ruby-identifier">ip</span>) } <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-split_authority" class="method-detail "> <div class="method-heading"> <span class="method-name">split_authority</span><span class="method-args">(authority)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="split_authority-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 619</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_authority</span>(<span class="ruby-identifier">authority</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">match</span> = <span class="ruby-constant">AUTHORITY</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">authority</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">address</span> = <span class="ruby-identifier">match</span>[<span class="ruby-value">:ip6</span>] <span class="ruby-keyword">return</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">:host</span>], <span class="ruby-identifier">address</span>, <span class="ruby-identifier">match</span>[<span class="ruby-value">:port</span>]&.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword">else</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">match</span>[<span class="ruby-value">:host</span>], <span class="ruby-identifier">match</span>[<span class="ruby-value">:host</span>], <span class="ruby-identifier">match</span>[<span class="ruby-value">:port</span>]&.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-comment"># Give up!</span> <span class="ruby-keyword">return</span> <span class="ruby-identifier">authority</span>, <span class="ruby-identifier">authority</span>, <span class="ruby-keyword">nil</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-split_header" class="method-detail "> <div class="method-heading"> <span class="method-name">split_header</span><span class="method-args">(value)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="split_header-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 597</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_header</span>(<span class="ruby-identifier">value</span>) <span class="ruby-identifier">value</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/[,\s]+/</span>) <span class="ruby-operator">:</span> [] <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-wrap_ipv6" class="method-detail "> <div class="method-heading"> <span class="method-name">wrap_ipv6</span><span class="method-args">(host)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Assist with compatibility when processing `X-Forwarded-For`.</p> <div class="method-source-code" id="wrap_ipv6-source"> <pre><span class="ruby-comment"># File lib/rack/request.rb, line 561</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">wrap_ipv6</span>(<span class="ruby-identifier">host</span>) <span class="ruby-comment"># Even thought IPv6 addresses should be wrapped in square brackets,</span> <span class="ruby-comment"># sometimes this is not done in various legacy/underspecified headers.</span> <span class="ruby-comment"># So we try to fix this situation for compatibility reasons.</span> <span class="ruby-comment"># Try to detect IPv6 addresses which aren't escaped yet:</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">host</span>.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">'['</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">count</span>(<span class="ruby-string">':'</span>) <span class="ruby-operator">></span> <span class="ruby-value">1</span> <span class="ruby-node">"[#{host}]"</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">host</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> </section> </section> </main> <footer id="validator-badges" role="contentinfo"> <p><a href="https://validator.w3.org/check/referer">Validate</a> <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1. <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>. </footer>