AddHeader (HttpRequest subroutine)

From m204wiki
Jump to: navigation, search

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