AddHeader (HttpRequest subroutine): Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{Template: | {{Template:HttpRequest:AddHeader subtitle}} | ||
This method lets you add an HTTP request header | This method lets you add an HTTP request header | ||
to the HTTP request that will be sent to the HTTP server. | to the HTTP request that will be sent to the HTTP server. | ||
==Syntax== | ==Syntax== | ||
{{Template: | {{Template:HttpRequest:AddHeader syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
Line 11: | Line 11: | ||
</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;ldquo;accept-encoding.&amp;rdquo; Header names are case insensitive. | <td>A string expression that names an HTTP request header such as &amp;amp;ldquo;accept-encoding.&amp;amp;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;ldquo;content-length&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. | 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;ldquo;content-length&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. | ||
</td></tr> | </td></tr> | ||
<tr><th>value</th> | <tr><th>value</th> | ||
Line 21: | Line 21: | ||
<ul> | <ul> | ||
<li>For HTTP Version 1.1 mode only, | <li>For HTTP Version 1.1 mode only, | ||
the HTTP Request header &amp;ldquo;connection: close&amp;rdquo; is automatically | the HTTP Request header &amp;amp;ldquo;connection: close&amp;amp;rdquo; is automatically | ||
sent on GETs and POSTs to ensure that the server closes the | sent on GETs and POSTs to ensure that the server closes the | ||
connection with the client when the HTTP Request completes. | connection with the client when the HTTP Request completes. | ||
Line 35: | Line 35: | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template: | {{Template:HttpRequest:AddHeader footer}} |
Revision as of 20:16, 16 June 2011
Add a request header (HttpRequest class)
This 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
%httpreq | A previously defined and instantiated HTTPRequest object. |
---|---|
header | A string expression that names an HTTP request header such as &amp;ldquo;accept-encoding.&amp;rdquo; Header names are case insensitive.
Passing multiple occurrences is allowed: if a same-named header is already present, an additional occurrence is added. |
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 &amp;ldquo;connection: close&amp;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 HTTP Helper does not support persistent connections.
If you try to set a "connection" header using
AddHeader, any value
except
close
results in request cancellation.
Note: If you explicitly set "connection" toclose
, the automatic generation of "Connection: close" is suppressed to ensure that an extra connection header is not sent.