MaxRedirects (HttpRequest property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:HTTPRequest:MaxRedirects subtitle}}
{{Template:HttpRequest:MaxRedirects subtitle}}
The <var>MaxRedirects</var> method lets you request automatic handling of redirects that a <var>[[Get (HttpRequest function)|Get]]</var>, <var>[[Post (HttpRequest function)|Post]]</var>, or <var>[[Send (HttpRequest function)|Send]]</var> method call receives from the server.  Since redirects may be chained, that is, the location to which a redirect leads can also return a redirect, <var>MaxRedirects</var> specifies the maximum number of times a redirect is followed when it is returned from a web server.


This method lets you request automatic handling of redirects that a
<var>[[Get (HTTPRequest function)|Get]]</var>, <var>[[Post (HTTPRequest function)|Post]]</var>,
or <var>[[Send (HTTPRequest function)|Send]]</var> method call receives from the server.
Since redirects may be chained, that is, the location to which a redirect
leads can also return a redirect, <var>MaxRedirects</var> specifies the maximum number of
times a redirect is followed when it is returned from a web server.
==Syntax==
==Syntax==
{{Template:HTTPRequest:MaxRedirects syntax}}
{{Template:HttpRequest:MaxRedirects syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%httpreq</th>
<tr><th>currentNumber</th>
<td>An instantiated <var>HTTPRequest</var> object.
<td>A numeric variable to contain the returned value of <var>MaxRedirects</var>.</td></tr>
</td></tr>
<tr><th>httpRequest</th>
<tr><th>value</th>
<td>A previously defined and instantiated <var>HttpRequest</var> object.</td></tr>
<td>A numeric expression that evaluates to an integer from 0 through 100, which indicates the maximum number of times a redirect is followed on ''one'' Get, Post, or Send call.
<tr><th>newNumber</th>
If an invalid or out of range value is specified, the request is canceled. A value of 0 (the default) means redirects are not automatically handled.
<td>A numeric expression, that evaluates to an integer from 0 through 100, which indicates the maximum number of times a redirect is followed on ''one'' <var>[[Get (HttpRequest function)|Get]]</var>, <var>[[Post (HttpRequest function)|Post]]</var>, or <var>[[Send (HttpRequest function)|Send]]</var> call.
</td></tr>
<p>If an invalid, or out of range value is specified, the request is canceled. A value of 0 (the default) means redirects are not automatically handled.</p></td></tr>
<tr><th>%curr</th>
</table>
<td>The numeric variable for the assignment of the current value of MaxRedirects.


</td></tr></table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>
<li>
An HTTP server may return an indication that a page has
An HTTP server may return an indication that a page has moved and that the client process should fetch it from a new location. A server indicates this case by returning a response code in the 300s and by returning a response header named &ldquo;location&rdquo; that indicates the new location of the page or resource. The <var class="product">HTTP Helper</var> returns such a response code to the application and takes no further action.
moved and that the client process should fetch it from a new location.
<li>If the maximum number of redirections have been followed, and the last response is still a redirection response code, the last redirection response code is returned to the <var class="product">HTTP Helper</var>
A server indicates this case by returning a response code in the 300s and
by returning a response header named &amp;amp;ldquo;location&amp;amp;rdquo; that indicates the new
location of the page or resource.
The <var class="product">HTTP Helper</var> returns such a response code
to the application and takes no further action.
<li>If the maximum number of redirections have
been followed, and the last response is still a redirection response
code, the last redirection response code is returned to the <var class="product">HTTP Helper</var>
application.
application.
<li>When <var>MaxRedirects</var> is set to a value greater than zero, the following
<li>When <var>MaxRedirects</var> is set to a value greater than zero, the following HTTP redirection response codes are automatically handled:
HTTP redirection response codes are automatically handled:
<dl>
<dl>
<dt>301
<dt>301<dd>Moved Permanently
<dd>Moved Permanently
<dt>302<dd>Found
<dt>302
<dt>303<dd>See Other
<dd>Found
<dt>307<dd>Temporary Redirect
<dt>303
<dd>See Other
<dt>307
<dd>Temporary Redirect
</dl>
</dl>


For more details concerning HTTP Response codes,
For more details concerning HTTP response codes, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
<li>To facilitate working with redirects, the <var>HTTPResponse</var> <var>[[URL_(HttpResponse_function)|URL]]</var> method returns the actual URL from which a response was obtained.
<li>To facilitate working with redirects, the <var>[[Url (HTTPRequest property)|Url]]</var>
method of the <var>HTTPResponse</var> object
returns the actual URL from which a response was obtained.
</ul>
</ul>
==See also==
==See also==
{{Template:HTTPRequest:MaxRedirects footer}}
{{Template:HttpRequest:MaxRedirects footer}}

Latest revision as of 20:14, 21 June 2011

Automatically handle redirects (HttpRequest class)

The MaxRedirects method lets you request automatic handling of redirects that a Get, Post, or Send method call receives from the server. Since redirects may be chained, that is, the location to which a redirect leads can also return a redirect, MaxRedirects specifies the maximum number of times a redirect is followed when it is returned from a web server.

Syntax

%currentNumber = httpRequest:MaxRedirects httpRequest:MaxRedirects = newNumber

Syntax terms

currentNumber A numeric variable to contain the returned value of MaxRedirects.
httpRequest A previously defined and instantiated HttpRequest object.
newNumber A numeric expression, that evaluates to an integer from 0 through 100, which indicates the maximum number of times a redirect is followed on one Get, Post, or Send call.

If an invalid, or out of range value is specified, the request is canceled. A value of 0 (the default) means redirects are not automatically handled.

Usage notes

  • An HTTP server may return an indication that a page has moved and that the client process should fetch it from a new location. A server indicates this case by returning a response code in the 300s and by returning a response header named “location” that indicates the new location of the page or resource. The HTTP Helper returns such a response code to the application and takes no further action.
  • If the maximum number of redirections have been followed, and the last response is still a redirection response code, the last redirection response code is returned to the HTTP Helper application.
  • When MaxRedirects is set to a value greater than zero, the following HTTP redirection response codes are automatically handled:
    301
    Moved Permanently
    302
    Found
    303
    See Other
    307
    Temporary Redirect

    For more details concerning HTTP response codes, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.

  • To facilitate working with redirects, the HTTPResponse URL method returns the actual URL from which a response was obtained.

See also