<?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>Class: ActionController::Integration::Session</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="classHeader"> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Class</strong></td> <td class="class-name-in-header">ActionController::Integration::Session</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../../../files/lib/action_controller/integration_rb.html"> lib/action_controller/integration.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> <a href="../../Object.html"> Object </a> </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="description"> <p> An integration <a href="Session.html">Session</a> instance represents a set of requests and responses performed sequentially by some virtual user. Because you can instantiate multiple sessions and run them side-by-side, you can also mimic (to some limited extent) multiple simultaneous users interacting with your system. </p> <p> Typically, you will instantiate a <a href="Session.html#M000098">new</a> session using IntegrationTest#open_session, rather than instantiating <a href="Session.html">Integration::Session</a> directly. </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000113">delete</a> <a href="#M000108">delete_via_redirect</a> <a href="#M000103">follow_redirect!</a> <a href="#M000110">get</a> <a href="#M000105">get_via_redirect</a> <a href="#M000114">head</a> <a href="#M000102">host!</a> <a href="#M000100">https!</a> <a href="#M000101">https?</a> <a href="#M000098">new</a> <a href="#M000111">post</a> <a href="#M000106">post_via_redirect</a> <a href="#M000112">put</a> <a href="#M000107">put_via_redirect</a> <a href="#M000109">redirect?</a> <a href="#M000104">request_via_redirect</a> <a href="#M000099">reset!</a> <a href="#M000117">url_for</a> <a href="#M000116">xhr</a> <a href="#M000115">xml_http_request</a> </div> </div> </div> <!-- if includes --> <div id="includes"> <h3 class="section-bar">Included Modules</h3> <div id="includes-list"> <span class="include-name">Test::Unit::Assertions</span> <span class="include-name"><a href="../TestCase/Assertions.html">ActionController::TestCase::Assertions</a></span> <span class="include-name"><a href="../TestProcess.html">ActionController::TestProcess</a></span> </div> </div> <div id="section"> <div id="class-list"> <h3 class="section-bar">Classes and Modules</h3> Class <a href="Session/MultiPartNeededException.html" class="link">ActionController::Integration::Session::MultiPartNeededException</a><br /> </div> <div id="attribute-list"> <h3 class="section-bar">Attributes</h3> <div class="name-list"> <table> <tr class="top-aligned-row context-row"> <td class="context-item-name">accept</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> The Accept header to send. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">application</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> Rack application to use </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">body</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> The body of the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">controller</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> A reference to the controller instance used by the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">cookies</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> A map of the cookies returned by the last response, and which will be sent with the next request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">headers</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> A map of the headers returned by the last response. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">host</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> The hostname used in the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">path</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> The URI of the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">remote_addr</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> The remote_addr used in the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">request</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> A reference to the request instance used by the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">request_count</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"> A running counter of the number of requests processed. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">response</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> A reference to the response instance used by the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">status</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> The integer HTTP status code of the last request. </td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">status_message</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"> The status message that accompanied the status code of the last request. </td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000098" class="method-detail"> <a name="M000098"></a> <div class="method-heading"> <a href="Session.src/M000098.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000098.html');return false;"> <span class="method-name">new</span><span class="method-args">(app = nil)</span> </a> </div> <div class="method-description"> <p> Create and initialize a <a href="Session.html#M000098">new</a> <a href="Session.html">Session</a> instance. </p> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000113" class="method-detail"> <a name="M000113"></a> <div class="method-heading"> <a href="Session.src/M000113.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000113.html');return false;"> <span class="method-name">delete</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a DELETE request with the given parameters. See <a href="Session.html#M000110">get</a>() for more details. </p> </div> </div> <div id="method-M000108" class="method-detail"> <a name="M000108"></a> <div class="method-heading"> <a href="Session.src/M000108.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000108.html');return false;"> <span class="method-name">delete_via_redirect</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a DELETE request, following any subsequent redirect. See <tt><a href="Session.html#M000104">request_via_redirect</a></tt> for more information. </p> </div> </div> <div id="method-M000103" class="method-detail"> <a name="M000103"></a> <div class="method-heading"> <a href="Session.src/M000103.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000103.html');return false;"> <span class="method-name">follow_redirect!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Follow a single redirect response. If the last response was not a redirect, an exception will be raised. Otherwise, the redirect is performed on the location header. </p> </div> </div> <div id="method-M000110" class="method-detail"> <a name="M000110"></a> <div class="method-heading"> <a href="Session.src/M000110.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000110.html');return false;"> <span class="method-name">get</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a GET request with the given parameters. </p> <ul> <li><tt>path</tt>: The URI (as a String) on which you want to perform a GET request. </li> <li><tt>parameters</tt>: The HTTP parameters that you want to pass. This may be <tt>nil</tt>, a Hash, or a String that is appropriately encoded (<tt>application/x-www-form-urlencoded</tt> or <tt>multipart/form-data</tt>). </li> <li><tt>headers</tt>: Additional HTTP headers to pass, as a Hash. The keys will automatically be upcased, with the prefix ‘HTTP_’ added if needed. </li> </ul> <p> This method returns an <a href="../Response.html">Response</a> object, which one can use to inspect the details of the response. Furthermore, if this method was called from an <a href="../IntegrationTest.html">ActionController::IntegrationTest</a> object, then that object‘s <tt>@response</tt> instance variable will point to the same response object. </p> <p> You can also perform POST, PUT, DELETE, and HEAD requests with <tt><a href="Session.html#M000111">post</a></tt>, <tt><a href="Session.html#M000112">put</a></tt>, <tt><a href="Session.html#M000113">delete</a></tt>, and <tt><a href="Session.html#M000114">head</a></tt>. </p> </div> </div> <div id="method-M000105" class="method-detail"> <a name="M000105"></a> <div class="method-heading"> <a href="Session.src/M000105.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000105.html');return false;"> <span class="method-name">get_via_redirect</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a GET request, following any subsequent redirect. See <tt><a href="Session.html#M000104">request_via_redirect</a></tt> for more information. </p> </div> </div> <div id="method-M000114" class="method-detail"> <a name="M000114"></a> <div class="method-heading"> <a href="Session.src/M000114.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000114.html');return false;"> <span class="method-name">head</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a HEAD request with the given parameters. See <a href="Session.html#M000110">get</a>() for more details. </p> </div> </div> <div id="method-M000102" class="method-detail"> <a name="M000102"></a> <div class="method-heading"> <a href="Session.src/M000102.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000102.html');return false;"> <span class="method-name">host!</span><span class="method-args">(name)</span> </a> </div> <div class="method-description"> <p> Set the host name to use in the next request. </p> <pre> session.host! "www.example.com" </pre> </div> </div> <div id="method-M000100" class="method-detail"> <a name="M000100"></a> <div class="method-heading"> <a href="Session.src/M000100.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000100.html');return false;"> <span class="method-name">https!</span><span class="method-args">(flag = true)</span> </a> </div> <div class="method-description"> <p> Specify whether or not the session should mimic a secure HTTPS request. </p> <pre> session.https! session.https!(false) </pre> </div> </div> <div id="method-M000101" class="method-detail"> <a name="M000101"></a> <div class="method-heading"> <a href="Session.src/M000101.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000101.html');return false;"> <span class="method-name">https?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Return <tt>true</tt> if the session is mimicking a secure HTTPS request. </p> <pre> if session.https? ... end </pre> </div> </div> <div id="method-M000111" class="method-detail"> <a name="M000111"></a> <div class="method-heading"> <a href="Session.src/M000111.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000111.html');return false;"> <span class="method-name">post</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a POST request with the given parameters. See <a href="Session.html#M000110">get</a>() for more details. </p> </div> </div> <div id="method-M000106" class="method-detail"> <a name="M000106"></a> <div class="method-heading"> <a href="Session.src/M000106.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000106.html');return false;"> <span class="method-name">post_via_redirect</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a POST request, following any subsequent redirect. See <tt><a href="Session.html#M000104">request_via_redirect</a></tt> for more information. </p> </div> </div> <div id="method-M000112" class="method-detail"> <a name="M000112"></a> <div class="method-heading"> <a href="Session.src/M000112.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000112.html');return false;"> <span class="method-name">put</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a PUT request with the given parameters. See <a href="Session.html#M000110">get</a>() for more details. </p> </div> </div> <div id="method-M000107" class="method-detail"> <a name="M000107"></a> <div class="method-heading"> <a href="Session.src/M000107.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000107.html');return false;"> <span class="method-name">put_via_redirect</span><span class="method-args">(path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a PUT request, following any subsequent redirect. See <tt><a href="Session.html#M000104">request_via_redirect</a></tt> for more information. </p> </div> </div> <div id="method-M000109" class="method-detail"> <a name="M000109"></a> <div class="method-heading"> <a href="Session.src/M000109.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000109.html');return false;"> <span class="method-name">redirect?</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Returns <tt>true</tt> if the last response was a redirect. </p> </div> </div> <div id="method-M000104" class="method-detail"> <a name="M000104"></a> <div class="method-heading"> <a href="Session.src/M000104.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000104.html');return false;"> <span class="method-name">request_via_redirect</span><span class="method-args">(http_method, path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs a request using the specified method, following any subsequent redirect. Note that the redirects are followed until the response is not a redirect—this means you may run into an infinite loop if your redirect loops back to itself. </p> </div> </div> <div id="method-M000099" class="method-detail"> <a name="M000099"></a> <div class="method-heading"> <a href="Session.src/M000099.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000099.html');return false;"> <span class="method-name">reset!</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> Resets the instance. This can be used to reset the state information in an existing session instance, so it can be used from a clean-slate condition. </p> <pre> session.reset! </pre> </div> </div> <div id="method-M000117" class="method-detail"> <a name="M000117"></a> <div class="method-heading"> <a href="Session.src/M000117.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000117.html');return false;"> <span class="method-name">url_for</span><span class="method-args">(options)</span> </a> </div> <div class="method-description"> <p> Returns the URL for the given options, according to the rules specified in the application‘s routes. </p> </div> </div> <div id="method-M000116" class="method-detail"> <a name="M000116"></a> <div class="method-heading"> <span class="method-name">xhr</span><span class="method-args">(request_method, path, parameters = nil, headers = nil)</span> </div> <div class="method-description"> <p> Alias for <a href="Session.html#M000115">xml_http_request</a> </p> </div> </div> <div id="method-M000115" class="method-detail"> <a name="M000115"></a> <div class="method-heading"> <a href="Session.src/M000115.html" target="Code" class="method-signature" onclick="popupCode('Session.src/M000115.html');return false;"> <span class="method-name">xml_http_request</span><span class="method-args">(request_method, path, parameters = nil, headers = nil)</span> </a> </div> <div class="method-description"> <p> Performs an XMLHttpRequest request with the given parameters, mirroring a request from the Prototype library. </p> <p> The request_method is :<a href="Session.html#M000110">get</a>, :<a href="Session.html#M000111">post</a>, :<a href="Session.html#M000112">put</a>, :<a href="Session.html#M000113">delete</a> or :<a href="Session.html#M000114">head</a>; the parameters are <tt>nil</tt>, a hash, or a url-encoded or multipart string; the headers are a hash. Keys are automatically upcased and prefixed with ‘HTTP_’ if not already. </p> </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>