AddHeader (HttpRequest subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:HttpRequest:AddHeader subtitle}}
{{Template:HttpRequest:AddHeader subtitle}}
The <var>AddHeader</var> method lets you add an HTTP request header to the HTTP request that will be sent to the HTTP server.


This method lets you add an HTTP request header
to the HTTP request that will be sent to the HTTP server.
==Syntax==
==Syntax==
{{Template:HttpRequest:AddHeader syntax}}
{{Template:HttpRequest:AddHeader syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%httpreq</th>
<tr><th>httpRequest</th>
<td>A previously defined and instantiated <var>HttpRequest</var> object.
<td>A previously defined and instantiated <var>HttpRequest</var> object.
</td></tr>
</td></tr>
<tr><th>header</th>
<tr><th>header</th>
<td>A string expression that names an HTTP request header such as &amp;amp;amp;amp;ldquo;accept-encoding.&amp;amp;amp;amp;rdquo; Header names are case insensitive.
<td>A string expression that names an HTTP request header such as &ldquo;accept-encoding.&rdquo; Header names are case insensitive.
Passing multiple occurrences is allowed: if a same-named header is already present, an additional occurrence is added. <br>'''Note:''' Do not specify &amp;amp;amp;amp;ldquo;content-length&amp;amp;amp;amp;rdquo;; an attempt to do so results in cancellation of the request. The HTTP Helper automatically calculates the number of bytes in the non-header data, and it inserts a Content-Length header on Post calls.
<p>Passing multiple occurrences is allowed; if a same-named header is already present, an additional occurrence is added.</p>
<p>'''Note:''' Do not specify <code>content-length</code>; an attempt to do so results in cancellation of the request. The <var class="product">HTTP Helper</var> automatically calculates the number of bytes in the non-header data, and it inserts a Content-Length header on <var>Post</var> calls.</p>
</td></tr>
</td></tr>
<tr><th>value</th>
<tr><th>value</th>
<td>A string expression that yields a value for the request header.
<td>A string expression that yields a value for the request header.
</td></tr></table>


</td></tr></table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>For HTTP Version 1.1 mode only,
<li>For HTTP Version 1.1 mode only, the HTTP request header &ldquo;connection: close&rdquo; is automatically sent on GETs and POSTs to ensure that the server closes the connection with the client when the HTTP request completes. The <var class="product">HTTP Helper</var> does '''not''' support persistent connections.<p>'''Note:''' If you explicitly set "connection" to <code>close</code>, the automatic generation of "connection: close" is suppressed to ensure that an extra connection header is not sent.</p>
the HTTP Request header &amp;amp;amp;amp;ldquo;connection: close&amp;amp;amp;amp;rdquo; is automatically
<li>If you try to set a "connection" header using <var>AddHeader</var>, any value except <code>close</code> results in request cancellation.
sent on GETs and POSTs to ensure that the server closes the
</ul>
connection with the client when the HTTP Request completes.
The HTTP Helper does '''not''' support persistent connections.


If you try to set a "connection" header using
<var>AddHeader</var>, any value
except <code>close</code> results in request cancellation.
<br>'''Note:'''
If you explicitly set "connection" to <code>close</code>, the automatic
generation of "Connection: close"
is suppressed to ensure that an extra connection header is not sent.
</ul>
==See also==
==See also==
{{Template:HttpRequest:AddHeader footer}}
{{Template:HttpRequest:AddHeader footer}}

Latest revision as of 16:20, 21 June 2011

Add a request header (HttpRequest class)

The AddHeader method lets you add an HTTP request header to the HTTP request that will be sent to the HTTP server.

Syntax

httpRequest:AddHeader( header, value)

Syntax terms

httpRequest A previously defined and instantiated HttpRequest object.
header A string expression that names an HTTP request header such as “accept-encoding.” Header names are case insensitive.

Passing multiple occurrences is allowed; if a same-named header is already present, an additional occurrence is added.

Note: Do not specify content-length; an attempt to do so results in cancellation of the request. The HTTP Helper automatically calculates the number of bytes in the non-header data, and it inserts a Content-Length header on Post calls.

value A string expression that yields a value for the request header.

Usage notes

  • For HTTP Version 1.1 mode only, the HTTP request header “connection: close” is automatically sent on GETs and POSTs to ensure that the server closes the connection with the client when the HTTP request completes. The HTTP Helper does not support persistent connections.

    Note: If you explicitly set "connection" to close, the automatic generation of "connection: close" is suppressed to ensure that an extra connection header is not sent.

  • If you try to set a "connection" header using AddHeader, any value except close results in request cancellation.

See also