Server IP : 66.29.132.122 / Your IP : 3.148.113.180 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/alt/ruby18/lib64/ruby/gems/1.8/doc/rack-1.6.1/rdoc/files/lib/rack/ |
Upload File : |
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>File: utils.rb</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ function popupCode( url ) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } function toggleCode( id ) { if ( document.getElementById ) elem = document.getElementById( id ); else if ( document.all ) elem = eval( "document.all." + id ); else return false; elemStyle = elem.style; if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { elemStyle.display = "none" } return true; } // Make codeblocks hidden by default document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) // ]]> </script> </head> <body> <div id="fileHeader"> <h1>utils.rb</h1> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Path:</strong></td> <td>lib/rack/utils.rb </td> </tr> <tr class="top-aligned-row"> <td><strong>Last Update:</strong></td> <td>Thu Dec 05 17:13:57 -0500 2019</td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="requires-list"> <h3 class="section-bar">Required files</h3> <div class="name-list"> fileutils set tempfile rack/multipart time rack/backports/uri/common_18 rack/backports/uri/common_192 rack/backports/uri/common_193 uri/common </div> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000006">best_q_match</a> <a href="#M000004">build_nested_query</a> <a href="#M000003">build_query</a> <a href="#M000015">byte_ranges</a> <a href="#M000012">bytesize</a> <a href="#M000011">bytesize</a> <a href="#M000018">clean_path_info</a> <a href="#M000010">delete_cookie_header!</a> <a href="#M000007">escape_html</a> <a href="#M000001">normalize_params</a> <a href="#M000002">params_hash_type?</a> <a href="#M000005">q_values</a> <a href="#M000014">rfc2109</a> <a href="#M000013">rfc2822</a> <a href="#M000016">secure_compare</a> <a href="#M000008">select_best_encoding</a> <a href="#M000009">set_cookie_header!</a> <a href="#M000017">status_code</a> </div> </div> </div> <!-- if includes --> <div id="section"> <div id="constants-list"> <h3 class="section-bar">Constants</h3> <div class="name-list"> <table summary="Constants"> <tr class="top-aligned-row context-row"> <td class="context-item-name">ESCAPE_HTML</td> <td>=</td> <td class="context-item-value">{ "&" => "&amp;", "<" => "&lt;", ">" => "&gt;", "'" => "&#x27;", '"' => "&quot;", "/" => "&#x2F;"</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">ESCAPE_HTML_PATTERN</td> <td>=</td> <td class="context-item-value">Regexp.union(*ESCAPE_HTML.keys)</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">ESCAPE_HTML_PATTERN</td> <td>=</td> <td class="context-item-value">/#{Regexp.union(*ESCAPE_HTML.keys)}/n</td> <td width="3em"> </td> <td class="context-item-desc"> 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? </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">HTTP_STATUS_CODES</td> <td>=</td> <td class="context-item-value">{ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 208 => 'Already Reported', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Payload Too Large', 414 => 'URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', 510 => 'Not Extended', 511 => 'Network Authentication Required'</td> <td width="3em"> </td> <td class="context-item-desc"> 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> | # ruby -ne ‘m = /^(\d{3}),(?!Unassigned|\(Unused\))([^,]+)/.match($_) and # puts "#{m[1]} => \x27#{m[2].strip}\x27,"’ </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">STATUS_WITH_NO_ENTITY_BODY</td> <td>=</td> <td class="context-item-value">Set.new((100..199).to_a << 204 << 205 << 304)</td> <td width="3em"> </td> <td class="context-item-desc"> Responses with HTTP status codes that should not have an entity body </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">SYMBOL_TO_STATUS_CODE</td> <td>=</td> <td class="context-item-value">Hash[*HTTP_STATUS_CODES.map { |code, message| [message.downcase.gsub(/\s|-|'/, '_').to_sym, code]</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">Multipart</td> <td>=</td> <td class="context-item-value">Rack::Multipart</td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">PATH_SEPS</td> <td>=</td> <td class="context-item-value">Regexp.union(*[::File::SEPARATOR, ::File::ALT_SEPARATOR].compact)</td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000006" class="method-detail"> <a name="M000006"></a> <div class="method-heading"> <a href="utils_rb.src/M000006.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000006.html');return false;"> <span class="method-name">best_q_match</span><span class="method-args">(q_value_header, available_mimes)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000004" class="method-detail"> <a name="M000004"></a> <div class="method-heading"> <a href="utils_rb.src/M000004.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000004.html');return false;"> <span class="method-name">build_nested_query</span><span class="method-args">(value, prefix = nil)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000003" class="method-detail"> <a name="M000003"></a> <div class="method-heading"> <a href="utils_rb.src/M000003.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000003.html');return false;"> <span class="method-name">build_query</span><span class="method-args">(params)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000015" class="method-detail"> <a name="M000015"></a> <div class="method-heading"> <a href="utils_rb.src/M000015.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000015.html');return false;"> <span class="method-name">byte_ranges</span><span class="method-args">(env, size)</span> </a> </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> </div> <div id="method-M000012" class="method-detail"> <a name="M000012"></a> <div class="method-heading"> <a href="utils_rb.src/M000012.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000012.html');return false;"> <span class="method-name">bytesize</span><span class="method-args">(string)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000011" class="method-detail"> <a name="M000011"></a> <div class="method-heading"> <a href="utils_rb.src/M000011.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000011.html');return false;"> <span class="method-name">bytesize</span><span class="method-args">(string)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000018" class="method-detail"> <a name="M000018"></a> <div class="method-heading"> <a href="utils_rb.src/M000018.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000018.html');return false;"> <span class="method-name">clean_path_info</span><span class="method-args">(path_info)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000010" class="method-detail"> <a name="M000010"></a> <div class="method-heading"> <a href="utils_rb.src/M000010.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000010.html');return false;"> <span class="method-name">delete_cookie_header!</span><span class="method-args">(header, key, value = {})</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000007" class="method-detail"> <a name="M000007"></a> <div class="method-heading"> <a href="utils_rb.src/M000007.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000007.html');return false;"> <span class="method-name">escape_html</span><span class="method-args">(string)</span> </a> </div> <div class="method-description"> <p> Escape ampersands, brackets and quotes to their HTML/XML entities. </p> </div> </div> <div id="method-M000001" class="method-detail"> <a name="M000001"></a> <div class="method-heading"> <a href="utils_rb.src/M000001.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000001.html');return false;"> <span class="method-name">normalize_params</span><span class="method-args">(params, name, v = nil)</span> </a> </div> <div class="method-description"> <p> <a href="utils_rb.html#M000001">normalize_params</a> recursively expands parameters into structural types. If the structural types represented by two different parameter names are in conflict, a ParameterTypeError is raised. </p> </div> </div> <div id="method-M000002" class="method-detail"> <a name="M000002"></a> <div class="method-heading"> <a href="utils_rb.src/M000002.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000002.html');return false;"> <span class="method-name">params_hash_type?</span><span class="method-args">(obj)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000005" class="method-detail"> <a name="M000005"></a> <div class="method-heading"> <a href="utils_rb.src/M000005.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000005.html');return false;"> <span class="method-name">q_values</span><span class="method-args">(q_value_header)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000014" class="method-detail"> <a name="M000014"></a> <div class="method-heading"> <a href="utils_rb.src/M000014.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000014.html');return false;"> <span class="method-name">rfc2109</span><span class="method-args">(time)</span> </a> </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> </div> <div id="method-M000013" class="method-detail"> <a name="M000013"></a> <div class="method-heading"> <a href="utils_rb.src/M000013.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000013.html');return false;"> <span class="method-name">rfc2822</span><span class="method-args">(time)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000016" class="method-detail"> <a name="M000016"></a> <div class="method-heading"> <a href="utils_rb.src/M000016.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000016.html');return false;"> <span class="method-name">secure_compare</span><span class="method-args">(a, b)</span> </a> </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> </div> <div id="method-M000008" class="method-detail"> <a name="M000008"></a> <div class="method-heading"> <a href="utils_rb.src/M000008.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000008.html');return false;"> <span class="method-name">select_best_encoding</span><span class="method-args">(available_encodings, accept_encoding)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000009" class="method-detail"> <a name="M000009"></a> <div class="method-heading"> <a href="utils_rb.src/M000009.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000009.html');return false;"> <span class="method-name">set_cookie_header!</span><span class="method-args">(header, key, value)</span> </a> </div> <div class="method-description"> </div> </div> <div id="method-M000017" class="method-detail"> <a name="M000017"></a> <div class="method-heading"> <a href="utils_rb.src/M000017.html" target="Code" class="method-signature" onclick="popupCode('utils_rb.src/M000017.html');return false;"> <span class="method-name">status_code</span><span class="method-args">(status)</span> </a> </div> <div class="method-description"> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>