Hacked By AnonymousFox

Current Path : /proc/thread-self/root/opt/alt/ruby19/lib64/ruby/gems/1.9.1/doc/rack-1.6.4/rdoc/Rack/
Upload File :
Current File : //proc/thread-self/root/opt/alt/ruby19/lib64/ruby/gems/1.9.1/doc/rack-1.6.4/rdoc/Rack/Utils.html

<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta content="text/html; charset=US-ASCII" http-equiv="Content-Type" />

  <title>Module: Rack::Utils</title>

  <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />

  <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>

</head>
<body id="top" class="module">

  <div id="metadata">
    <div id="home-metadata">
      <div id="home-section" class="section">
        <h3 class="section-header">
          <a href="../index.html">Home</a>
          <a href="../index.html#classes">Classes</a>
          <a href="../index.html#methods">Methods</a>
        </h3>
      </div>
    </div>

    <div id="file-metadata">
      <div id="file-list-section" class="section">
        <h3 class="section-header">In Files</h3>
        <div class="section-body">
          <ul>
          
            <li><a href="../lib/rack_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="lib/rack.rb">lib/rack.rb</a></li>
          
            <li><a href="../lib/rack/utils_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
              class="thickbox" title="lib/rack/utils.rb">lib/rack/utils.rb</a></li>
          
          </ul>
        </div>
      </div>

      
    </div>

    <div id="class-metadata">
      

      

      
      <!-- Namespace Contents -->
      <div id="namespace-list-section" class="section">
        <h3 class="section-header">Namespace</h3>
        <ul class="link-list">
          
          <li><span class="type">MODULE</span> <a href="Multipart.html">Rack::Utils::Multipart</a></li>
          
          <li><span class="type">MODULE</span> <a href="Utils/OkJson.html">Rack::Utils::OkJson</a></li>
          
          <li><span class="type">CLASS</span> <a href="Utils/Context.html">Rack::Utils::Context</a></li>
          
          <li><span class="type">CLASS</span> <a href="Utils/HeaderHash.html">Rack::Utils::HeaderHash</a></li>
          
          <li><span class="type">CLASS</span> <a href="Utils/InvalidParameterError.html">Rack::Utils::InvalidParameterError</a></li>
          
          <li><span class="type">CLASS</span> <a href="Utils/KeySpaceConstrainedParams.html">Rack::Utils::KeySpaceConstrainedParams</a></li>
          
          <li><span class="type">CLASS</span> <a href="Utils/ParameterTypeError.html">Rack::Utils::ParameterTypeError</a></li>
          
        </ul>
      </div>
      

      
      <!-- Method Quickref -->
      <div id="method-list-section" class="section">
        <h3 class="section-header">Methods</h3>
        <ul class="link-list">
          
          <li><a href="#method-c-best_q_match">::best_q_match</a></li>
          
          <li><a href="#method-c-build_nested_query">::build_nested_query</a></li>
          
          <li><a href="#method-c-build_query">::build_query</a></li>
          
          <li><a href="#method-c-byte_ranges">::byte_ranges</a></li>
          
          <li><a href="#method-c-bytesize">::bytesize</a></li>
          
          <li><a href="#method-c-clean_path_info">::clean_path_info</a></li>
          
          <li><a href="#method-c-delete_cookie_header-21">::delete_cookie_header!</a></li>
          
          <li><a href="#method-c-escape">::escape</a></li>
          
          <li><a href="#method-c-escape_html">::escape_html</a></li>
          
          <li><a href="#method-c-escape_path">::escape_path</a></li>
          
          <li><a href="#method-c-normalize_params">::normalize_params</a></li>
          
          <li><a href="#method-c-params_hash_type-3F">::params_hash_type?</a></li>
          
          <li><a href="#method-c-parse_nested_query">::parse_nested_query</a></li>
          
          <li><a href="#method-c-parse_query">::parse_query</a></li>
          
          <li><a href="#method-c-q_values">::q_values</a></li>
          
          <li><a href="#method-c-rfc2109">::rfc2109</a></li>
          
          <li><a href="#method-c-rfc2822">::rfc2822</a></li>
          
          <li><a href="#method-c-secure_compare">::secure_compare</a></li>
          
          <li><a href="#method-c-select_best_encoding">::select_best_encoding</a></li>
          
          <li><a href="#method-c-set_cookie_header-21">::set_cookie_header!</a></li>
          
          <li><a href="#method-c-status_code">::status_code</a></li>
          
          <li><a href="#method-c-unescape">::unescape</a></li>
          
        </ul>
      </div>
      

      
    </div>

    <div id="project-metadata">
      
      
      <div id="fileindex-section" class="section project-section">
        <h3 class="section-header">Files</h3>
        <ul>
        
          <li class="file"><a href="../KNOWN-ISSUES.html">KNOWN-ISSUES</a></li>
        
        </ul>
      </div>
      

      <div id="classindex-section" class="section project-section">
        <h3 class="section-header">Class/Module Index
          <span class="search-toggle"><img src="../images/find.png"
            height="16" width="16" alt="[+]"
            title="show/hide quicksearch" /></span></h3>
        <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
        <fieldset>
          <legend>Quicksearch</legend>
          <input type="text" name="quicksearch" value=""
            class="quicksearch-field" />
        </fieldset>
        </form>

        <ul class="link-list">
        
          <li><a href="../Rack.html">Rack</a></li>
        
          <li><a href="../Rack/Auth.html">Rack::Auth</a></li>
        
          <li><a href="../Rack/Auth/AbstractHandler.html">Rack::Auth::AbstractHandler</a></li>
        
          <li><a href="../Rack/Auth/AbstractRequest.html">Rack::Auth::AbstractRequest</a></li>
        
          <li><a href="../Rack/Auth/Basic.html">Rack::Auth::Basic</a></li>
        
          <li><a href="../Rack/Auth/Basic/Request.html">Rack::Auth::Basic::Request</a></li>
        
          <li><a href="../Rack/Auth/Digest.html">Rack::Auth::Digest</a></li>
        
          <li><a href="../Rack/Auth/Digest/MD5.html">Rack::Auth::Digest::MD5</a></li>
        
          <li><a href="../Rack/Auth/Digest/Nonce.html">Rack::Auth::Digest::Nonce</a></li>
        
          <li><a href="../Rack/Auth/Digest/Params.html">Rack::Auth::Digest::Params</a></li>
        
          <li><a href="../Rack/Auth/Digest/Request.html">Rack::Auth::Digest::Request</a></li>
        
          <li><a href="../Rack/BodyProxy.html">Rack::BodyProxy</a></li>
        
          <li><a href="../Rack/Builder.html">Rack::Builder</a></li>
        
          <li><a href="../Rack/Cascade.html">Rack::Cascade</a></li>
        
          <li><a href="../Rack/Chunked.html">Rack::Chunked</a></li>
        
          <li><a href="../Rack/Chunked/Body.html">Rack::Chunked::Body</a></li>
        
          <li><a href="../Rack/CommonLogger.html">Rack::CommonLogger</a></li>
        
          <li><a href="../Rack/ConditionalGet.html">Rack::ConditionalGet</a></li>
        
          <li><a href="../Rack/Config.html">Rack::Config</a></li>
        
          <li><a href="../Rack/ContentLength.html">Rack::ContentLength</a></li>
        
          <li><a href="../Rack/ContentType.html">Rack::ContentType</a></li>
        
          <li><a href="../Rack/Deflater.html">Rack::Deflater</a></li>
        
          <li><a href="../Rack/Deflater/DeflateStream.html">Rack::Deflater::DeflateStream</a></li>
        
          <li><a href="../Rack/Deflater/GzipStream.html">Rack::Deflater::GzipStream</a></li>
        
          <li><a href="../Rack/Directory.html">Rack::Directory</a></li>
        
          <li><a href="../Rack/ETag.html">Rack::ETag</a></li>
        
          <li><a href="../Rack/File.html">Rack::File</a></li>
        
          <li><a href="../Rack/ForwardRequest.html">Rack::ForwardRequest</a></li>
        
          <li><a href="../Rack/Handler.html">Rack::Handler</a></li>
        
          <li><a href="../Rack/Handler/CGI.html">Rack::Handler::CGI</a></li>
        
          <li><a href="../Rack/Handler/EventedMongrel.html">Rack::Handler::EventedMongrel</a></li>
        
          <li><a href="../Rack/Handler/FastCGI.html">Rack::Handler::FastCGI</a></li>
        
          <li><a href="../Rack/Handler/LSWS.html">Rack::Handler::LSWS</a></li>
        
          <li><a href="../Rack/Handler/Mongrel.html">Rack::Handler::Mongrel</a></li>
        
          <li><a href="../Rack/Handler/SCGI.html">Rack::Handler::SCGI</a></li>
        
          <li><a href="../Rack/Handler/SwiftipliedMongrel.html">Rack::Handler::SwiftipliedMongrel</a></li>
        
          <li><a href="../Rack/Handler/Thin.html">Rack::Handler::Thin</a></li>
        
          <li><a href="../Rack/Handler/WEBrick.html">Rack::Handler::WEBrick</a></li>
        
          <li><a href="../Rack/Head.html">Rack::Head</a></li>
        
          <li><a href="../Rack/Lint.html">Rack::Lint</a></li>
        
          <li><a href="../Rack/Lobster.html">Rack::Lobster</a></li>
        
          <li><a href="../Rack/Lock.html">Rack::Lock</a></li>
        
          <li><a href="../Rack/Logger.html">Rack::Logger</a></li>
        
          <li><a href="../Rack/MethodOverride.html">Rack::MethodOverride</a></li>
        
          <li><a href="../Rack/Mime.html">Rack::Mime</a></li>
        
          <li><a href="../Rack/MockRequest.html">Rack::MockRequest</a></li>
        
          <li><a href="../Rack/MockRequest/FatalWarner.html">Rack::MockRequest::FatalWarner</a></li>
        
          <li><a href="../Rack/MockRequest/FatalWarning.html">Rack::MockRequest::FatalWarning</a></li>
        
          <li><a href="../Rack/MockResponse.html">Rack::MockResponse</a></li>
        
          <li><a href="../Rack/Multipart.html">Rack::Multipart</a></li>
        
          <li><a href="../Rack/Multipart/Generator.html">Rack::Multipart::Generator</a></li>
        
          <li><a href="../Rack/Multipart/MultipartPartLimitError.html">Rack::Multipart::MultipartPartLimitError</a></li>
        
          <li><a href="../Rack/Multipart/Parser.html">Rack::Multipart::Parser</a></li>
        
          <li><a href="../Rack/Multipart/UploadedFile.html">Rack::Multipart::UploadedFile</a></li>
        
          <li><a href="../Rack/NullLogger.html">Rack::NullLogger</a></li>
        
          <li><a href="../Rack/Recursive.html">Rack::Recursive</a></li>
        
          <li><a href="../Rack/Reloader.html">Rack::Reloader</a></li>
        
          <li><a href="../Rack/Reloader/Stat.html">Rack::Reloader::Stat</a></li>
        
          <li><a href="../Rack/Request.html">Rack::Request</a></li>
        
          <li><a href="../Rack/Response.html">Rack::Response</a></li>
        
          <li><a href="../Rack/Response/Helpers.html">Rack::Response::Helpers</a></li>
        
          <li><a href="../Rack/RewindableInput.html">Rack::RewindableInput</a></li>
        
          <li><a href="../Rack/RewindableInput/Tempfile.html">Rack::RewindableInput::Tempfile</a></li>
        
          <li><a href="../Rack/Runtime.html">Rack::Runtime</a></li>
        
          <li><a href="../Rack/Sendfile.html">Rack::Sendfile</a></li>
        
          <li><a href="../Rack/Server.html">Rack::Server</a></li>
        
          <li><a href="../Rack/Server/Options.html">Rack::Server::Options</a></li>
        
          <li><a href="../Rack/Session.html">Rack::Session</a></li>
        
          <li><a href="../Rack/Session/Abstract.html">Rack::Session::Abstract</a></li>
        
          <li><a href="../Rack/Session/Abstract/ID.html">Rack::Session::Abstract::ID</a></li>
        
          <li><a href="../Rack/Session/Abstract/SessionHash.html">Rack::Session::Abstract::SessionHash</a></li>
        
          <li><a href="../Rack/Session/Cookie.html">Rack::Session::Cookie</a></li>
        
          <li><a href="../Rack/Session/Cookie/Base64.html">Rack::Session::Cookie::Base64</a></li>
        
          <li><a href="../Rack/Session/Cookie/Base64/JSON.html">Rack::Session::Cookie::Base64::JSON</a></li>
        
          <li><a href="../Rack/Session/Cookie/Base64/Marshal.html">Rack::Session::Cookie::Base64::Marshal</a></li>
        
          <li><a href="../Rack/Session/Cookie/Base64/ZipJSON.html">Rack::Session::Cookie::Base64::ZipJSON</a></li>
        
          <li><a href="../Rack/Session/Cookie/Identity.html">Rack::Session::Cookie::Identity</a></li>
        
          <li><a href="../Rack/Session/Memcache.html">Rack::Session::Memcache</a></li>
        
          <li><a href="../Rack/Session/Pool.html">Rack::Session::Pool</a></li>
        
          <li><a href="../Rack/ShowExceptions.html">Rack::ShowExceptions</a></li>
        
          <li><a href="../Rack/ShowStatus.html">Rack::ShowStatus</a></li>
        
          <li><a href="../Rack/Static.html">Rack::Static</a></li>
        
          <li><a href="../Rack/TempfileReaper.html">Rack::TempfileReaper</a></li>
        
          <li><a href="../Rack/URLMap.html">Rack::URLMap</a></li>
        
          <li><a href="../Rack/Utils.html">Rack::Utils</a></li>
        
          <li><a href="../Rack/Utils/Context.html">Rack::Utils::Context</a></li>
        
          <li><a href="../Rack/Utils/HeaderHash.html">Rack::Utils::HeaderHash</a></li>
        
          <li><a href="../Rack/Utils/InvalidParameterError.html">Rack::Utils::InvalidParameterError</a></li>
        
          <li><a href="../Rack/Utils/KeySpaceConstrainedParams.html">Rack::Utils::KeySpaceConstrainedParams</a></li>
        
          <li><a href="../Rack/Multipart.html">Rack::Utils::Multipart</a></li>
        
          <li><a href="../Rack/Utils/OkJson.html">Rack::Utils::OkJson</a></li>
        
          <li><a href="../Rack/Utils/OkJson/Error.html">Rack::Utils::OkJson::Error</a></li>
        
          <li><a href="../Rack/Utils/OkJson/Utf8Error.html">Rack::Utils::OkJson::Utf8Error</a></li>
        
          <li><a href="../Rack/Utils/ParameterTypeError.html">Rack::Utils::ParameterTypeError</a></li>
        
          <li><a href="../FCGI.html">FCGI</a></li>
        
          <li><a href="../FCGI/Stream.html">FCGI::Stream</a></li>
        
          <li><a href="../WEBrick.html">WEBrick</a></li>
        
          <li><a href="../WEBrick/HTTPResponse.html">WEBrick::HTTPResponse</a></li>
        
          <li><a href="../Object.html">Object</a></li>
        
        </ul>
        <div id="no-class-search-results" style="display: none;">No matching classes.</div>
      </div>

      
    </div>
  </div>

  <div id="documentation">
    <h1 class="module">Rack::Utils</h1>

    <div id="description" class="description">
      
<p><a href="Utils.html">Rack::Utils</a> contains a grab-bag of useful methods
for writing web applications adopted from all kinds of Ruby libraries.</p>

    </div><!-- description -->

    
    
    
    <div id="5Buntitled-5D" class="documentation-section">
      

      

      
      <!-- Constants -->
      <div id="constants-list" class="section">
        <h3 class="section-header">Constants</h3>
        <dl>
        
          <dt><a name="DEFAULT_SEP">DEFAULT_SEP</a></dt>
          
          <dd class="description"></dd>
          
        
          <dt><a name="ESCAPE_HTML">ESCAPE_HTML</a></dt>
          
          <dd class="description"></dd>
          
        
          <dt><a name="ESCAPE_HTML_PATTERN">ESCAPE_HTML_PATTERN</a></dt>
          
          <dd class="description"><p>On 1.8, there is a kcode = 'u' bug that allows for XSS otherwise TODO
doesn't apply to jruby, so a better condition above might be preferable?</p></dd>
          
        
          <dt><a name="HTTP_STATUS_CODES">HTTP_STATUS_CODES</a></dt>
          
          <dd class="description"><p>Every standard HTTP code mapped to the appropriate message. Generated with:
curl -s <a
href="https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv">www.iana.org/assignments/http-status-codes/http-status-codes-1.csv</a>
| \</p>

<pre>ruby -ne 'm = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and \
          puts &quot;#{m[1]} =&gt; \x27#{m[2].strip}\x27,&quot;'</pre></dd>
          
        
          <dt><a name="Multipart">Multipart</a></dt>
          
          <dd class="description"></dd>
          
        
          <dt><a name="PATH_SEPS">PATH_SEPS</a></dt>
          
          <dd class="description"></dd>
          
        
          <dt><a name="STATUS_WITH_NO_ENTITY_BODY">STATUS_WITH_NO_ENTITY_BODY</a></dt>
          
          <dd class="description"><p>Responses with HTTP status codes that should not have an entity body</p></dd>
          
        
          <dt><a name="SYMBOL_TO_STATUS_CODE">SYMBOL_TO_STATUS_CODE</a></dt>
          
          <dd class="description"></dd>
          
        
        </dl>
      </div>
      

      
      <!-- Attributes -->
      <div id="attribute-method-details" class="method-section section">
        <h3 class="section-header">Attributes</h3>

        
        <div id="key_space_limit-attribute-method" class="method-detail">
          <a name="key_space_limit"></a>
          
          <a name="key_space_limit="></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">key_space_limit</span><span
              class="attribute-access-type">[RW]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
        <div id="multipart_part_limit-attribute-method" class="method-detail">
          <a name="multipart_part_limit"></a>
          
          <a name="multipart_part_limit="></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">multipart_part_limit</span><span
              class="attribute-access-type">[RW]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
        <div id="param_depth_limit-attribute-method" class="method-detail">
          <a name="param_depth_limit"></a>
          
          <a name="param_depth_limit="></a>
          
          <div class="method-heading attribute-method-heading">
            <span class="method-name">param_depth_limit</span><span
              class="attribute-access-type">[RW]</span>
          </div>

          <div class="method-description">
          
          
          
          </div>
        </div>
        
      </div><!-- attribute-method-details -->
      

      <!-- Methods -->
      
      <div id="public-class-method-details" class="method-section section">
        <h3 class="section-header">Public Class Methods</h3>

      
        <div id="best_q_match-method" class="method-detail ">
          <a name="method-c-best_q_match"></a>

          
          <div class="method-heading">
            <span class="method-name">best_q_match</span><span
              class="method-args">(q_value_header, available_mimes)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="best_q_match-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 216</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">best_q_match</span>(<span class="ruby-identifier">q_value_header</span>, <span class="ruby-identifier">available_mimes</span>)
  <span class="ruby-identifier">values</span> = <span class="ruby-identifier">q_values</span>(<span class="ruby-identifier">q_value_header</span>)

  <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">values</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">req_mime</span>, <span class="ruby-identifier">quality</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">match</span> = <span class="ruby-identifier">available_mimes</span>.<span class="ruby-identifier">find</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">am</span><span class="ruby-operator">|</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Mime</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">am</span>, <span class="ruby-identifier">req_mime</span>) }
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">match</span>
    [<span class="ruby-identifier">match</span>, <span class="ruby-identifier">quality</span>]
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">sort_by</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">match</span>, <span class="ruby-identifier">quality</span><span class="ruby-operator">|</span>
    (<span class="ruby-identifier">match</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'/'</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">count</span>(<span class="ruby-string">'*'</span>) * <span class="ruby-value">-10</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">quality</span>
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">last</span>
  <span class="ruby-identifier">matches</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">first</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- best_q_match-source -->
            
          </div>

          

          
        </div><!-- best_q_match-method -->

      
        <div id="build_nested_query-method" class="method-detail ">
          <a name="method-c-build_nested_query"></a>

          
          <div class="method-heading">
            <span class="method-name">build_nested_query</span><span
              class="method-args">(value, prefix = nil)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="build_nested_query-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 185</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">prefix</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">v</span>, <span class="ruby-node">&quot;#{prefix}[]&quot;</span>)
    }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;&amp;&quot;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Hash</span>
    <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">prefix</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{prefix}[#{escape(k)}]&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">k</span>))
    }.<span class="ruby-identifier">reject</span>(&amp;<span class="ruby-value">:empty?</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">'&amp;'</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">prefix</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;value must be a Hash&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-node">&quot;#{prefix}=#{escape(value)}&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- build_nested_query-source -->
            
          </div>

          

          
        </div><!-- build_nested_query-method -->

      
        <div id="build_query-method" class="method-detail ">
          <a name="method-c-build_query"></a>

          
          <div class="method-heading">
            <span class="method-name">build_query</span><span
              class="method-args">(params)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="build_query-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 174</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">build_query</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-identifier">params</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
      <span class="ruby-identifier">build_query</span>(<span class="ruby-identifier">v</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">k</span>, <span class="ruby-identifier">x</span>] })
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">k</span>) <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{escape(k)}=#{escape(v)}&quot;</span>
    <span class="ruby-keyword">end</span>
  }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;&amp;&quot;</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- build_query-source -->
            
          </div>

          

          
        </div><!-- build_query-method -->

      
        <div id="byte_ranges-method" class="method-detail ">
          <a name="method-c-byte_ranges"></a>

          
          <div class="method-heading">
            <span class="method-name">byte_ranges</span><span
              class="method-args">(env, size)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Parses the "Range:" header, if present, into an array of Range objects.
Returns nil if the header is missing or syntactically invalid. Returns an
empty array if none of the ranges are satisfiable.</p>
            

            
            <div class="method-source-code" id="byte_ranges-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 401</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">byte_ranges</span>(<span class="ruby-identifier">env</span>, <span class="ruby-identifier">size</span>)
  <span class="ruby-comment"># See &lt;http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35&gt;</span>
  <span class="ruby-identifier">http_range</span> = <span class="ruby-identifier">env</span>[<span class="ruby-string">'HTTP_RANGE'</span>]
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">http_range</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">http_range</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/bytes=([^;]+)/</span>
  <span class="ruby-identifier">ranges</span> = []
  <span class="ruby-node">$1</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/,\s*/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">range_spec</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">range_spec</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/(\d*)-(\d*)/</span>
    <span class="ruby-identifier">r0</span>,<span class="ruby-identifier">r1</span> = <span class="ruby-node">$1</span>, <span class="ruby-node">$2</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">r0</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r1</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-comment"># suffix-byte-range-spec, represents trailing suffix of file</span>
      <span class="ruby-identifier">r0</span> = <span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">r1</span>.<span class="ruby-identifier">to_i</span>
      <span class="ruby-identifier">r0</span> = <span class="ruby-value">0</span>  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r0</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
      <span class="ruby-identifier">r1</span> = <span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">r0</span> = <span class="ruby-identifier">r0</span>.<span class="ruby-identifier">to_i</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">r1</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">r1</span> = <span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">r1</span> = <span class="ruby-identifier">r1</span>.<span class="ruby-identifier">to_i</span>
        <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r1</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">r0</span>  <span class="ruby-comment"># backwards range is syntactically invalid</span>
        <span class="ruby-identifier">r1</span> = <span class="ruby-identifier">size</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r1</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">size</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">ranges</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">r0</span><span class="ruby-operator">..</span><span class="ruby-identifier">r1</span>)  <span class="ruby-keyword">if</span> <span class="ruby-identifier">r0</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">r1</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ranges</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- byte_ranges-source -->
            
          </div>

          

          
        </div><!-- byte_ranges-method -->

      
        <div id="bytesize-method" class="method-detail ">
          <a name="method-c-bytesize"></a>

          
          <div class="method-heading">
            <span class="method-name">bytesize</span><span
              class="method-args">(string)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="bytesize-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 367</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">bytesize</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">bytesize</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- bytesize-source -->
            
          </div>

          

          
        </div><!-- bytesize-method -->

      
        <div id="clean_path_info-method" class="method-detail ">
          <a name="method-c-clean_path_info"></a>

          
          <div class="method-heading">
            <span class="method-name">clean_path_info</span><span
              class="method-args">(path_info)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="clean_path_info-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 666</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">clean_path_info</span>(<span class="ruby-identifier">path_info</span>)
  <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">path_info</span>.<span class="ruby-identifier">split</span> <span class="ruby-constant">PATH_SEPS</span>

  <span class="ruby-identifier">clean</span> = []

  <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">each</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-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">part</span> <span class="ruby-operator">==</span> <span class="ruby-string">'.'</span>
    <span class="ruby-identifier">part</span> <span class="ruby-operator">==</span> <span class="ruby-string">'..'</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">clean</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">clean</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">part</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">clean</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-string">'/'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(*<span class="ruby-identifier">clean</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- clean_path_info-source -->
            
          </div>

          

          
        </div><!-- clean_path_info-method -->

      
        <div id="delete_cookie_header-21-method" class="method-detail ">
          <a name="method-c-delete_cookie_header-21"></a>

          
          <div class="method-heading">
            <span class="method-name">delete_cookie_header!</span><span
              class="method-args">(header, key, value = {})</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="delete_cookie_header-21-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 333</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">delete_cookie_header!</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span> = {})
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>]
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">''</span>
    <span class="ruby-identifier">cookies</span> = []
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
    <span class="ruby-identifier">cookies</span> = <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\n&quot;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-identifier">cookies</span> = <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>]
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">cookies</span>.<span class="ruby-identifier">reject!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">cookie</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:domain</span>]
      <span class="ruby-identifier">cookie</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\A#{escape(key)}=.*domain=#{value[:domain]}/</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:path</span>]
      <span class="ruby-identifier">cookie</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\A#{escape(key)}=.*path=#{value[:path]}/</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">cookie</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\A#{escape(key)}=/</span>
    <span class="ruby-keyword">end</span>
  }

  <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>] = <span class="ruby-identifier">cookies</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)

  <span class="ruby-identifier">set_cookie_header!</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">key</span>,
             {<span class="ruby-value">:value</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">''</span>, <span class="ruby-value">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">:domain</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>,
               <span class="ruby-value">:max_age</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">'0'</span>,
               <span class="ruby-value">:expires</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">at</span>(<span class="ruby-value">0</span>) }.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">value</span>))

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- delete_cookie_header-21-source -->
            
          </div>

          

          
        </div><!-- delete_cookie_header-21-method -->

      
        <div id="escape-method" class="method-detail ">
          <a name="method-c-escape"></a>

          
          <div class="method-heading">
            <span class="method-name">escape</span><span
              class="method-args">(s)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>URI escapes. (CGI style space to +)</p>
            

            
            <div class="method-source-code" id="escape-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">s</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- escape-source -->
            
          </div>

          

          
        </div><!-- escape-method -->

      
        <div id="escape_html-method" class="method-detail ">
          <a name="method-c-escape_html"></a>

          
          <div class="method-heading">
            <span class="method-name">escape_html</span><span
              class="method-args">(string)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Escape ampersands, brackets and quotes to their HTML/XML entities.</p>
            

            
            <div class="method-source-code" id="escape_html-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 247</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">escape_html</span>(<span class="ruby-identifier">string</span>)
  <span class="ruby-identifier">string</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">ESCAPE_HTML_PATTERN</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-constant">ESCAPE_HTML</span>[<span class="ruby-identifier">c</span>] }
<span class="ruby-keyword">end</span></pre>
            </div><!-- escape_html-source -->
            
          </div>

          

          
        </div><!-- escape_html-method -->

      
        <div id="escape_path-method" class="method-detail ">
          <a name="method-c-escape_path"></a>

          
          <div class="method-heading">
            <span class="method-name">escape_path</span><span
              class="method-args">(s)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Like URI escaping, but with %20 instead of +. Strictly speaking this is
true URI escaping.</p>
            

            
            <div class="method-source-code" id="escape_path-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">escape_path</span>(<span class="ruby-identifier">s</span>)
  <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">s</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'+'</span>, <span class="ruby-string">'%20'</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- escape_path-source -->
            
          </div>

          

          
        </div><!-- escape_path-method -->

      
        <div id="normalize_params-method" class="method-detail ">
          <a name="method-c-normalize_params"></a>

          
          <div class="method-heading">
            <span class="method-name">normalize_params</span><span
              class="method-args">(params, name, v = nil, depth = Utils.param_depth_limit)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p><a href="Utils.html#method-c-normalize_params">normalize_params</a>
recursively expands parameters into structural types. If the structural
types represented by two different parameter names are in conflict, a <a
href="Utils/ParameterTypeError.html">ParameterTypeError</a> is raised.</p>
            

            
            <div class="method-source-code" id="normalize_params-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 133</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">normalize_params</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">v</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">depth</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">param_depth_limit</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">RangeError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">depth</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>

  <span class="ruby-identifier">name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%(\A[\[\]]*([^\[\]]+)\]*)</span>
  <span class="ruby-identifier">k</span> = <span class="ruby-node">$1</span> <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
  <span class="ruby-identifier">after</span> = <span class="ruby-node">$'</span> <span class="ruby-operator">||</span> <span class="ruby-string">''</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">after</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">after</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;[&quot;</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">after</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;[]&quot;</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">||=</span> []
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParameterTypeError</span>, <span class="ruby-node">&quot;expected Array (got #{params[k].class.name}) for param `#{k}'&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">after</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%(^\[\]\[([^\[\]]+)\]$)</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">after</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">%(^\[\](.+)$)</span>
    <span class="ruby-identifier">child_key</span> = <span class="ruby-node">$1</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">||=</span> []
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParameterTypeError</span>, <span class="ruby-node">&quot;expected Array (got #{params[k].class.name}) for param `#{k}'&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">params_hash_type?</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">last</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">last</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">child_key</span>)
      <span class="ruby-identifier">normalize_params</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>].<span class="ruby-identifier">last</span>, <span class="ruby-identifier">child_key</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">depth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">normalize_params</span>(<span class="ruby-identifier">params</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>, <span class="ruby-identifier">child_key</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">depth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParameterTypeError</span>, <span class="ruby-node">&quot;expected Hash (got #{params[k].class.name}) for param `#{k}'&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params_hash_type?</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>])
    <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">normalize_params</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>], <span class="ruby-identifier">after</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">depth</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">params</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- normalize_params-source -->
            
          </div>

          

          
        </div><!-- normalize_params-method -->

      
        <div id="params_hash_type-3F-method" class="method-detail ">
          <a name="method-c-params_hash_type-3F"></a>

          
          <div class="method-heading">
            <span class="method-name">params_hash_type?</span><span
              class="method-args">(obj)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="params_hash_type-3F-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 169</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">params_hash_type?</span>(<span class="ruby-identifier">obj</span>)
  <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">KeySpaceConstrainedParams</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- params_hash_type-3F-source -->
            
          </div>

          

          
        </div><!-- params_hash_type-3F-method -->

      
        <div id="parse_nested_query-method" class="method-detail ">
          <a name="method-c-parse_nested_query"></a>

          
          <div class="method-heading">
            <span class="method-name">parse_nested_query</span><span
              class="method-args">(qs, d = nil)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p><a href="Utils.html#method-c-parse_nested_query">parse_nested_query</a>
expands a query string into structural types. Supported types are Arrays,
Hashes and basic value types. It is possible to supply query strings with
parameters of conflicting types, in this case a <a
href="Utils/ParameterTypeError.html">ParameterTypeError</a> is raised.
Users are encouraged to return a 400 in this case.</p>
            

            
            <div class="method-source-code" id="parse_nested_query-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 115</span>
<span class="ruby-keyword">def</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">nil</span>)
  <span class="ruby-identifier">params</span> = <span class="ruby-constant">KeySpaceConstrainedParams</span>.<span class="ruby-identifier">new</span>

  (<span class="ruby-identifier">qs</span> <span class="ruby-operator">||</span> <span class="ruby-string">''</span>).<span class="ruby-identifier">split</span>(<span class="ruby-identifier">d</span> <span class="ruby-operator">?</span> <span class="ruby-node">/[#{d}] */</span> <span class="ruby-operator">:</span> <span class="ruby-constant">DEFAULT_SEP</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">s</span>) }

    <span class="ruby-identifier">normalize_params</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">to_params_hash</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">ArgumentError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidParameterError</span>, <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- parse_nested_query-source -->
            
          </div>

          

          
        </div><!-- parse_nested_query-method -->

      
        <div id="parse_query-method" class="method-detail ">
          <a name="method-c-parse_query"></a>

          
          <div class="method-heading">
            <span class="method-name">parse_query</span><span
              class="method-args">(qs, d = nil, &unescaper)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Stolen from Mongrel, with some small modifications: Parses a query string
by breaking it up at the '&amp;' and ';' characters.  You can also use this
to parse cookies by changing the characters used in the second parameter
(which defaults to '&amp;;').</p>
            

            
            <div class="method-source-code" id="parse_query-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 86</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">d</span> = <span class="ruby-keyword">nil</span>, &amp;<span class="ruby-identifier">unescaper</span>)
  <span class="ruby-identifier">unescaper</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">method</span>(<span class="ruby-value">:unescape</span>)

  <span class="ruby-identifier">params</span> = <span class="ruby-constant">KeySpaceConstrainedParams</span>.<span class="ruby-identifier">new</span>

  (<span class="ruby-identifier">qs</span> <span class="ruby-operator">||</span> <span class="ruby-string">''</span>).<span class="ruby-identifier">split</span>(<span class="ruby-identifier">d</span> <span class="ruby-operator">?</span> <span class="ruby-node">/[#{d}] */</span> <span class="ruby-operator">:</span> <span class="ruby-constant">DEFAULT_SEP</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">map</span>(&amp;<span class="ruby-identifier">unescaper</span>)

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">cur</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>]
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">cur</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
        <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">params</span>[<span class="ruby-identifier">k</span>] = [<span class="ruby-identifier">cur</span>, <span class="ruby-identifier">v</span>]
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">params</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>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">to_params_hash</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- parse_query-source -->
            
          </div>

          

          
        </div><!-- parse_query-method -->

      
        <div id="q_values-method" class="method-detail ">
          <a name="method-c-q_values"></a>

          
          <div class="method-heading">
            <span class="method-name">q_values</span><span
              class="method-args">(q_value_header)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="q_values-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 204</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">q_values</span>(<span class="ruby-identifier">q_value_header</span>)
  <span class="ruby-identifier">q_value_header</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s*,\s*/</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">value</span>, <span class="ruby-identifier">parameters</span> = <span class="ruby-identifier">part</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s*;\s*/</span>, <span class="ruby-value">2</span>)
    <span class="ruby-identifier">quality</span> = <span class="ruby-value">1.0</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">md</span> = <span class="ruby-regexp">/\Aq=([\d.]+)/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">parameters</span>)
      <span class="ruby-identifier">quality</span> = <span class="ruby-identifier">md</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_f</span>
    <span class="ruby-keyword">end</span>
    [<span class="ruby-identifier">value</span>, <span class="ruby-identifier">quality</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- q_values-source -->
            
          </div>

          

          
        </div><!-- q_values-method -->

      
        <div id="rfc2109-method" class="method-detail ">
          <a name="method-c-rfc2109"></a>

          
          <div class="method-heading">
            <span class="method-name">rfc2109</span><span
              class="method-args">(time)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Modified version of stdlib time.rb Time#rfc2822 to use '%d-%b-%Y' instead
of '% %b %Y'. It assumes that the time is in GMT to comply to the RFC 2109.</p>

<p>NOTE: I'm not sure the RFC says it requires GMT, but is ambiguous enough
that I'm certain someone implemented only that option. Do not use %a and %b
from Time.strptime, it would use localized names for weekday and month.</p>
            

            
            <div class="method-source-code" id="rfc2109-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 391</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">rfc2109</span>(<span class="ruby-identifier">time</span>)
  <span class="ruby-identifier">wday</span> = <span class="ruby-constant">Time</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2822_DAY_NAME</span>[<span class="ruby-identifier">time</span>.<span class="ruby-identifier">wday</span>]
  <span class="ruby-identifier">mon</span> = <span class="ruby-constant">Time</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2822_MONTH_NAME</span>[<span class="ruby-identifier">time</span>.<span class="ruby-identifier">mon</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-node">&quot;#{wday}, %d-#{mon}-%Y %H:%M:%S GMT&quot;</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- rfc2109-source -->
            
          </div>

          

          
        </div><!-- rfc2109-method -->

      
        <div id="rfc2822-method" class="method-detail ">
          <a name="method-c-rfc2822"></a>

          
          <div class="method-heading">
            <span class="method-name">rfc2822</span><span
              class="method-args">(time)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="rfc2822-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 377</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">rfc2822</span>(<span class="ruby-identifier">time</span>)
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">rfc2822</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- rfc2822-source -->
            
          </div>

          

          
        </div><!-- rfc2822-method -->

      
        <div id="secure_compare-method" class="method-detail ">
          <a name="method-c-secure_compare"></a>

          
          <div class="method-heading">
            <span class="method-name">secure_compare</span><span
              class="method-args">(a, b)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            <p>Constant time string comparison.</p>

<p>NOTE: the values compared should be of fixed length, such as strings that
have already been processed by HMAC. This should not be used on variable
length plaintext strings because it could leak length info via timing
attacks.</p>
            

            
            <div class="method-source-code" id="secure_compare-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 437</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">secure_compare</span>(<span class="ruby-identifier">a</span>, <span class="ruby-identifier">b</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">bytesize</span>(<span class="ruby-identifier">a</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">bytesize</span>(<span class="ruby-identifier">b</span>)

  <span class="ruby-identifier">l</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-string">&quot;C*&quot;</span>)

  <span class="ruby-identifier">r</span>, <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>, <span class="ruby-value">-1</span>
  <span class="ruby-identifier">b</span>.<span class="ruby-identifier">each_byte</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">|=</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">^</span> <span class="ruby-identifier">l</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">+=</span><span class="ruby-value">1</span>] }
  <span class="ruby-identifier">r</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- secure_compare-source -->
            
          </div>

          

          
        </div><!-- secure_compare-method -->

      
        <div id="select_best_encoding-method" class="method-detail ">
          <a name="method-c-select_best_encoding"></a>

          
          <div class="method-heading">
            <span class="method-name">select_best_encoding</span><span
              class="method-args">(available_encodings, accept_encoding)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="select_best_encoding-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 252</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select_best_encoding</span>(<span class="ruby-identifier">available_encodings</span>, <span class="ruby-identifier">accept_encoding</span>)
  <span class="ruby-comment"># http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html</span>

  <span class="ruby-identifier">expanded_accept_encoding</span> =
    <span class="ruby-identifier">accept_encoding</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">q</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;*&quot;</span>
        (<span class="ruby-identifier">available_encodings</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">accept_encoding</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m2</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m2</span> }).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m2</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">m2</span>, <span class="ruby-identifier">q</span>] }
      <span class="ruby-keyword">else</span>
        [[<span class="ruby-identifier">m</span>, <span class="ruby-identifier">q</span>]]
      <span class="ruby-keyword">end</span>
    }.<span class="ruby-identifier">inject</span>([]) { <span class="ruby-operator">|</span><span class="ruby-identifier">mem</span>, <span class="ruby-identifier">list</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">mem</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">list</span>
    }

  <span class="ruby-identifier">encoding_candidates</span> = <span class="ruby-identifier">expanded_accept_encoding</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">q</span><span class="ruby-operator">|</span> <span class="ruby-operator">-</span><span class="ruby-identifier">q</span> }.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> }

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">encoding_candidates</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;identity&quot;</span>)
    <span class="ruby-identifier">encoding_candidates</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&quot;identity&quot;</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">expanded_accept_encoding</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">q</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">encoding_candidates</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">m</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">q</span> <span class="ruby-operator">==</span> <span class="ruby-value">0.0</span>
  }

  <span class="ruby-keyword">return</span> (<span class="ruby-identifier">encoding_candidates</span> &amp; <span class="ruby-identifier">available_encodings</span>)[<span class="ruby-value">0</span>]
<span class="ruby-keyword">end</span></pre>
            </div><!-- select_best_encoding-source -->
            
          </div>

          

          
        </div><!-- select_best_encoding-method -->

      
        <div id="set_cookie_header-21-method" class="method-detail ">
          <a name="method-c-set_cookie_header-21"></a>

          
          <div class="method-heading">
            <span class="method-name">set_cookie_header!</span><span
              class="method-args">(header, key, value)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="set_cookie_header-21-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 280</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set_cookie_header!</span>(<span class="ruby-identifier">header</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Hash</span>
    <span class="ruby-identifier">domain</span>  = <span class="ruby-string">&quot;; domain=&quot;</span>  <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:domain</span>]       <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:domain</span>]
    <span class="ruby-identifier">path</span>    = <span class="ruby-string">&quot;; path=&quot;</span>    <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:path</span>]         <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:path</span>]
    <span class="ruby-identifier">max_age</span> = <span class="ruby-string">&quot;; max-age=&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:max_age</span>].<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:max_age</span>]
    <span class="ruby-comment"># There is an RFC mess in the area of date formatting for Cookies. Not</span>
    <span class="ruby-comment"># only are there contradicting RFCs and examples within RFC text, but</span>
    <span class="ruby-comment"># there are also numerous conflicting names of fields and partially</span>
    <span class="ruby-comment"># cross-applicable specifications.</span>
    <span class="ruby-comment">#</span>
    <span class="ruby-comment"># These are best described in RFC 2616 3.3.1. This RFC text also</span>
    <span class="ruby-comment"># specifies that RFC 822 as updated by RFC 1123 is preferred. That is a</span>
    <span class="ruby-comment"># fixed length format with space-date delimeted fields.</span>
    <span class="ruby-comment">#</span>
    <span class="ruby-comment"># See also RFC 1123 section 5.2.14.</span>
    <span class="ruby-comment">#</span>
    <span class="ruby-comment"># RFC 6265 also specifies &quot;sane-cookie-date&quot; as RFC 1123 date, defined</span>
    <span class="ruby-comment"># in RFC 2616 3.3.1. RFC 6265 also gives examples that clearly denote</span>
    <span class="ruby-comment"># the space delimited format. These formats are compliant with RFC 2822.</span>
    <span class="ruby-comment">#</span>
    <span class="ruby-comment"># For reference, all involved RFCs are:</span>
    <span class="ruby-comment"># RFC 822</span>
    <span class="ruby-comment"># RFC 1123</span>
    <span class="ruby-comment"># RFC 2109</span>
    <span class="ruby-comment"># RFC 2616</span>
    <span class="ruby-comment"># RFC 2822</span>
    <span class="ruby-comment"># RFC 2965</span>
    <span class="ruby-comment"># RFC 6265</span>
    <span class="ruby-identifier">expires</span> = <span class="ruby-string">&quot;; expires=&quot;</span> <span class="ruby-operator">+</span>
      <span class="ruby-identifier">rfc2822</span>(<span class="ruby-identifier">value</span>[<span class="ruby-value">:expires</span>].<span class="ruby-identifier">clone</span>.<span class="ruby-identifier">gmtime</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:expires</span>]
    <span class="ruby-identifier">secure</span> = <span class="ruby-string">&quot;; secure&quot;</span>  <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:secure</span>]
    <span class="ruby-identifier">httponly</span> = <span class="ruby-string">&quot;; HttpOnly&quot;</span> <span class="ruby-keyword">if</span> (<span class="ruby-identifier">value</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-value">:httponly</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:httponly</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>[<span class="ruby-value">:http_only</span>])
    <span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>[<span class="ruby-value">:value</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">value</span> = [<span class="ruby-identifier">value</span>] <span class="ruby-keyword">unless</span> <span class="ruby-constant">Array</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">value</span>
  <span class="ruby-identifier">cookie</span> = <span class="ruby-identifier">escape</span>(<span class="ruby-identifier">key</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot;=&quot;</span> <span class="ruby-operator">+</span>
    <span class="ruby-identifier">value</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">escape</span> <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;&amp;&quot;</span>) <span class="ruby-operator">+</span>
    <span class="ruby-node">&quot;#{domain}#{path}#{max_age}#{expires}#{secure}#{httponly}&quot;</span>

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>]
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">''</span>
    <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>] = <span class="ruby-identifier">cookie</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
    <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>] = [<span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>], <span class="ruby-identifier">cookie</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
    <span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>] = (<span class="ruby-identifier">header</span>[<span class="ruby-string">&quot;Set-Cookie&quot;</span>] <span class="ruby-operator">+</span> [<span class="ruby-identifier">cookie</span>]).<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- set_cookie_header-21-source -->
            
          </div>

          

          
        </div><!-- set_cookie_header-21-method -->

      
        <div id="status_code-method" class="method-detail ">
          <a name="method-c-status_code"></a>

          
          <div class="method-heading">
            <span class="method-name">status_code</span><span
              class="method-args">(status)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="status_code-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 653</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">status_code</span>(<span class="ruby-identifier">status</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">status</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>)
    <span class="ruby-constant">SYMBOL_TO_STATUS_CODE</span>[<span class="ruby-identifier">status</span>] <span class="ruby-operator">||</span> <span class="ruby-value">500</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">status</span>.<span class="ruby-identifier">to_i</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
            </div><!-- status_code-source -->
            
          </div>

          

          
        </div><!-- status_code-method -->

      
        <div id="unescape-method" class="method-detail ">
          <a name="method-c-unescape"></a>

          
          <div class="method-heading">
            <span class="method-name">unescape</span><span
              class="method-args">(s, encoding = Encoding::UTF_8)</span>
            <span class="method-click-advice">click to toggle source</span>
          </div>
          

          <div class="method-description">
            
            
            

            
            <div class="method-source-code" id="unescape-source">
<pre>
<span class="ruby-comment"># File lib/rack/utils.rb, line 49</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">encoding</span> = <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
  <span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form_component</span>(<span class="ruby-identifier">s</span>, <span class="ruby-identifier">encoding</span>)
<span class="ruby-keyword">end</span></pre>
            </div><!-- unescape-source -->
            
          </div>

          

          
        </div><!-- unescape-method -->

      
      </div><!-- public-class-method-details -->
    
    </div><!-- 5Buntitled-5D -->
  

  </div><!-- documentation -->

  <div id="validator-badges">
    <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
    <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
      Rdoc Generator</a> 2</small>.</p>
  </div>

</body>
</html>


Hacked By AnonymousFox1.0, Coded By AnonymousFox