Adds one or more HTTP request headers to the HTTP request handle.
Syntax
BOOL HttpAddRequestHeaders( IN HINTERNET hConnect, IN LPCTSTR lpszHeaders, IN DWORD dwHeadersLength, IN DWORD dwModifiers );The actual syntax of this function varies between its ANSI and Unicode implementations. For more information, see Win32 Internet Functions Syntax.
Parameters
- hConnect
- HINTERNET handle returned by a call to the HttpOpenRequest function.
- lpszHeaders
- Address of a string variable containing the headers to append to the request. Each header must be terminated by a CR/LF (carriage return/line feed) pair.
- dwHeadersLength
- Unsigned long integer value that contains the length, in TCHAR, of lpszHeaders. If this parameter is -1L, the function assumes that lpszHeaders is zero-terminated (ASCIIZ), and the length is computed.
- dwModifiers
- Unsigned long integer value that contains the flags used to modify the semantics of this function. Can be a combination of the following values:
- HTTP_ADDREQ_FLAG_ADD
- Adds the header if it does not exist. Used with HTTP_ADDREQ_FLAG_REPLACE.
- HTTP_ADDREQ_FLAG_ADD_IF_NEW
- Adds the header only if it does not already exist; otherwise, an error is returned.
- HTTP_ADDREQ_FLAG_COALESCE
- Coalesces headers of the same name.
- HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
- Coalesces headers of the same name. For example, adding "Accept: text/*" followed by "Accept: audio/*" with this flag results in the formation of the single header "Accept: text/*, audio/*". This causes the first header found to be coalesced. It is up to the calling application to ensure a cohesive scheme with respect to coalesced/separate headers.
- HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
- Coalesces headers of the same name using a semicolon.
- HTTP_ADDREQ_FLAG_REPLACE
- Replaces or removes a header. If the header value is empty and the header is found, it is removed. If not empty, the header value is replaced.
Return Value
Returns TRUE if successful, or FALSE otherwise. To get extended error information, call GetLastError.
Remarks
HttpAddRequestHeaders appends additional, free-format headers to the HTTP request handle and is intended for use by sophisticated clients that need detailed control over the exact request sent to the HTTP server.
Note that for basic HttpAddRequestHeaders, the application can pass in multiple headers in a single buffer. If the application is trying to remove or replace a header, only one header can be supplied in lpszHeaders.
Function Information
Windows NT Use version 4.0. Implemented as ANSI and Unicode functions. Windows Use Windows 95 and later. Implemented as ANSI and Unicode functions. Header Wininet.h Import library Wininet.lib Minimum availability Internet Explorer 3.0 (ANSI only), 5 (ANSI and Unicode)
Windows CE
Windows CE Use version 2.12 and later. Implemented as ANSI and Unicode functions. Minimum availability Internet Explorer 4.0
See Also
Microsoft Win32 Internet Functions Overview, HTTP Sessions, Microsoft Win32 Internet Functions Reference, HTTP Functions