Server IP : 66.29.132.122 / Your IP : 3.137.189.226 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/proc/thread-self/root/opt/alt/ruby19/lib64/ruby/gems/1.9.1/doc/rack-1.6.4/rdoc/Rack/ |
Upload File : |
<?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>Class: Rack::MockRequest</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="class"> <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/mock_rb.html?TB_iframe=true&height=550&width=785" class="thickbox" title="lib/rack/mock.rb">lib/rack/mock.rb</a></li> </ul> </div> </div> </div> <div id="class-metadata"> <!-- Parent Class --> <div id="parent-class-section" class="section"> <h3 class="section-header">Parent</h3> <p class="link"><a href="../Object.html">Object</a></p> </div> <!-- Namespace Contents --> <div id="namespace-list-section" class="section"> <h3 class="section-header">Namespace</h3> <ul class="link-list"> <li><span class="type">CLASS</span> <a href="MockRequest/FatalWarner.html">Rack::MockRequest::FatalWarner</a></li> <li><span class="type">CLASS</span> <a href="MockRequest/FatalWarning.html">Rack::MockRequest::FatalWarning</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-env_for">::env_for</a></li> <li><a href="#method-c-new">::new</a></li> <li><a href="#method-c-parse_uri_rfc2396">::parse_uri_rfc2396</a></li> <li><a href="#method-i-delete">#delete</a></li> <li><a href="#method-i-get">#get</a></li> <li><a href="#method-i-head">#head</a></li> <li><a href="#method-i-options">#options</a></li> <li><a href="#method-i-patch">#patch</a></li> <li><a href="#method-i-post">#post</a></li> <li><a href="#method-i-put">#put</a></li> <li><a href="#method-i-request">#request</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="class">Rack::MockRequest</h1> <div id="description" class="description"> <p><a href="MockRequest.html">Rack::MockRequest</a> helps testing your <a href="../Rack.html">Rack</a> application without actually using HTTP.</p> <p>After performing a request on a URL with get/post/put/patch/delete, it returns a <a href="MockResponse.html">MockResponse</a> with useful helper methods for effective testing.</p> <p>You can pass a hash with additional configuration to the get/post/put/patch/delete.</p> <table class="rdoc-list"><tr><td class="rdoc-term"><p><tt>:input</tt></p></td> <td> <p>A String or IO-like to be used as rack.input.</p> </td></tr><tr><td class="rdoc-term"><p><tt>:fatal</tt></p></td> <td> <p>Raise a <a href="MockRequest/FatalWarning.html">FatalWarning</a> if the app writes to rack.errors.</p> </td></tr><tr><td class="rdoc-term"><p><tt>:lint</tt></p></td> <td> <p>If true, wrap the application in a <a href="Lint.html">Rack::Lint</a>.</p> </td></tr></table> </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_ENV">DEFAULT_ENV</a></dt> <dd class="description"></dd> </dl> </div> <!-- Methods --> <div id="public-class-method-details" class="method-section section"> <h3 class="section-header">Public Class Methods</h3> <div id="env_for-method" class="method-detail "> <a name="method-c-env_for"></a> <div class="method-heading"> <span class="method-name">env_for</span><span class="method-args">(uri="", opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Return the <a href="../Rack.html">Rack</a> environment used for a request to <tt>uri</tt>.</p> <div class="method-source-code" id="env_for-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 88</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">env_for</span>(<span class="ruby-identifier">uri</span>=<span class="ruby-string">""</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">parse_uri_rfc2396</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> = <span class="ruby-node">"/#{uri.path}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">//</span> <span class="ruby-identifier">env</span> = <span class="ruby-constant">DEFAULT_ENV</span>.<span class="ruby-identifier">dup</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">REQUEST_METHOD</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:method</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:method</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span> <span class="ruby-operator">:</span> <span class="ruby-string">"GET"</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"SERVER_NAME"</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">||</span> <span class="ruby-string">"example.org"</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"SERVER_PORT"</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-string">"80"</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">PATH_INFO</span>] = (<span class="ruby-operator">!</span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-string">"/"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.url_scheme"</span>] = <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">||</span> <span class="ruby-string">"http"</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"HTTPS"</span>] = <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.url_scheme"</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"https"</span> <span class="ruby-operator">?</span> <span class="ruby-string">"on"</span> <span class="ruby-operator">:</span> <span class="ruby-string">"off"</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">SCRIPT_NAME</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:script_name</span>] <span class="ruby-operator">||</span> <span class="ruby-string">""</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:fatal</span>] <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.errors"</span>] = <span class="ruby-constant">FatalWarner</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.errors"</span>] = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:params</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">REQUEST_METHOD</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"GET"</span> <span class="ruby-identifier">params</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-identifier">params</span>.<span class="ruby-identifier">update</span>(<span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_nested_query</span>(<span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>])) <span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>] = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:input</span>) <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_TYPE"</span>] = <span class="ruby-string">"application/x-www-form-urlencoded"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> = <span class="ruby-constant">Utils</span><span class="ruby-operator">::</span><span class="ruby-constant">Multipart</span>.<span class="ruby-identifier">build_multipart</span>(<span class="ruby-identifier">params</span>) <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-identifier">data</span> <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_LENGTH"</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_TYPE"</span>] = <span class="ruby-node">"multipart/form-data; boundary=#{Utils::Multipart::MULTIPART_BOUNDARY}"</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-identifier">params</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">empty_str</span> = <span class="ruby-string">""</span> <span class="ruby-identifier">empty_str</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">"ASCII-8BIT"</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">empty_str</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-value">:force_encoding</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">empty_str</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-identifier">rack_input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>]) <span class="ruby-keyword">else</span> <span class="ruby-identifier">rack_input</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-keyword">end</span> <span class="ruby-identifier">rack_input</span>.<span class="ruby-identifier">set_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">BINARY</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rack_input</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:set_encoding</span>) <span class="ruby-identifier">env</span>[<span class="ruby-string">'rack.input'</span>] = <span class="ruby-identifier">rack_input</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"CONTENT_LENGTH"</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.input"</span>].<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">field</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">env</span>[<span class="ruby-identifier">field</span>] = <span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">field</span> } <span class="ruby-identifier">env</span> <span class="ruby-keyword">end</span></pre> </div><!-- env_for-source --> </div> </div><!-- env_for-method --> <div id="new-method" class="method-detail "> <a name="method-c-new"></a> <div class="method-heading"> <span class="method-name">new</span><span class="method-args">(app)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="new-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 52</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>) <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span> <span class="ruby-keyword">end</span></pre> </div><!-- new-source --> </div> </div><!-- new-method --> <div id="parse_uri_rfc2396-method" class="method-detail "> <a name="method-c-parse_uri_rfc2396"></a> <div class="method-heading"> <span class="method-name">parse_uri_rfc2396</span><span class="method-args">(uri)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>For historical reasons, we're pinning to RFC 2396. It's easier for users and we get support from ruby 1.8 to 2.2 using this method.</p> <div class="method-source-code" id="parse_uri_rfc2396-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 82</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parse_uri_rfc2396</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-ivar">@parser</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2396_Parser</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">RFC2396_Parser</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">:</span> <span class="ruby-constant">URI</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-keyword">end</span></pre> </div><!-- parse_uri_rfc2396-source --> </div> </div><!-- parse_uri_rfc2396-method --> </div><!-- public-class-method-details --> <div id="public-instance-method-details" class="method-section section"> <h3 class="section-header">Public Instance Methods</h3> <div id="delete-method" class="method-detail "> <a name="method-i-delete"></a> <div class="method-heading"> <span class="method-name">delete</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="delete-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 60</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"DELETE"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- delete-source --> </div> </div><!-- delete-method --> <div id="get-method" class="method-detail "> <a name="method-i-get"></a> <div class="method-heading"> <span class="method-name">get</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="get-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 56</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"GET"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- get-source --> </div> </div><!-- get-method --> <div id="head-method" class="method-detail "> <a name="method-i-head"></a> <div class="method-heading"> <span class="method-name">head</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="head-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 61</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">head</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"HEAD"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- head-source --> </div> </div><!-- head-method --> <div id="options-method" class="method-detail "> <a name="method-i-options"></a> <div class="method-heading"> <span class="method-name">options</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="options-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 62</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">options</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"OPTIONS"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- options-source --> </div> </div><!-- options-method --> <div id="patch-method" class="method-detail "> <a name="method-i-patch"></a> <div class="method-heading"> <span class="method-name">patch</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="patch-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 59</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">patch</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"PATCH"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- patch-source --> </div> </div><!-- patch-method --> <div id="post-method" class="method-detail "> <a name="method-i-post"></a> <div class="method-heading"> <span class="method-name">post</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="post-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 57</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"POST"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- post-source --> </div> </div><!-- post-method --> <div id="put-method" class="method-detail "> <a name="method-i-put"></a> <div class="method-heading"> <span class="method-name">put</span><span class="method-args">(uri, opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="put-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 58</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">request</span>(<span class="ruby-string">"PUT"</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div><!-- put-source --> </div> </div><!-- put-method --> <div id="request-method" class="method-detail "> <a name="method-i-request"></a> <div class="method-heading"> <span class="method-name">request</span><span class="method-args">(method="GET", uri="", opts={})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="request-source"> <pre> <span class="ruby-comment"># File lib/rack/mock.rb, line 64</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier">request</span>(<span class="ruby-identifier">method</span>=<span class="ruby-string">"GET"</span>, <span class="ruby-identifier">uri</span>=<span class="ruby-string">""</span>, <span class="ruby-identifier">opts</span>={}) <span class="ruby-identifier">env</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">env_for</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">:method</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">method</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:lint</span>] <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app</span>) <span class="ruby-keyword">else</span> <span class="ruby-identifier">app</span> = <span class="ruby-ivar">@app</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">errors</span> = <span class="ruby-identifier">env</span>[<span class="ruby-string">"rack.errors"</span>] <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-constant">MockResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">errors</span>) <span class="ruby-keyword">ensure</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:close</span>) <span class="ruby-keyword">end</span></pre> </div><!-- request-source --> </div> </div><!-- request-method --> </div><!-- public-instance-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>