| BOOL WINAPI HttpAddRequestHeaders( |
| |
HCLIENT hClient, |
|
| |
LPCTSTR lpszHeaderList |
|
| ); |
The HttpAddRequestHeaders function adds one or more request
headers for the current client session.
Parameters
- hClient
- Handle to the client session.
- lpszHeaderList
- Points to a null-terminated string which specifies one or more
header values which should be set for the current client session.
This parameter cannot be NULL.
Return Value
If the function succeeds, the return value is non-zero. If the
client handle is invalid, the function returns a value of zero. To
get extended error information, call HttpGetLastError.
Remarks
The HttpAddRequestHeaders function enables your application
to set one or more header values by providing a list of name/value
pairs separated by a colon. Multiple header values may be provided by
separating them with a newline character. This function is similar to
calling the HttpSetRequestHeader function for each value. When
the list of header values is parsed, extraneous whitespace is ignored;
however, if the header list contains invalid text (for example, a
missing colon separating a header name from its value) the function
will fail and an error will be returned.
Exercise caution when providing a header list created directly from
user input, such as a list of values input using a textbox control.
Any header values which have been previously set by your application
can be overridden by this function and may yield unpredictable
results. If the service you are using requires a custom
authorization header, such as an API token or other user credentials,
allowing users to directly modify request header values this way can present a security risk.
Example
LPCTSTR lpszHeaderList = _T("X-API-Token: 99d2fe39-0246-4efa-98e0-4d775579fa5d\n") \
_T("X-API-UserId: someuser@domain.tld\n") \
_T("X-API-Version: 1.1\n")
if (!HttpAddRequestHeaders(hClient, lpszHeaderList))
{
return;
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cshtpv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
HttpGetFirstHeader,
HttpGetNextHeader,
HttpGetRequestHeader,
HttpGetResponseHeader,
HttpSetRequestHeader
|