HttpSendRequest

This function sends the specified request to the HTTP server.

At a Glance

Header file: Wininet.h
Windows CE versions: 2.0 and later

Syntax

BOOL WINAPI HttpSendRequest(HINTERNET hRequest, LPCTSTR lpszHeaders ,  DWORD dwHeadersLength, LPVOID lpOptional,  DWORD dwOptionalLength);

Parameters

hRequest

[in] Open HTTP request handle returned by HttpOpenRequest.

lpszHeaders

[in] Long pointer to null-terminated strings that contain additional headers to be appended to the request. This parameter can be NULL if there are no additional headers to append.

dwHeadersLength

[in] Specifies the length, in characters, of the additional headers. If this parameter is -1L and lpszHeaders is not NULL, the function assumes that lpszHeaders is zero-terminated (ASCIIZ), and the length is calculated.

lpOptional

[in] Long pointer to any optional data to send immediately after the request headers. This parameter is generally used for POST and PUT operations. The optional data can be the resource or information being posted to the server. This parameter can be NULL if there is no optional data to send.

dwOptionalLength

[in] Specifies the length, in bytes, of the optional data. This parameter can be zero if there is no optional data to send.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError.

Remarks

HttpSendRequest sends the specified request to the HTTP server and allows the client to specify additional headers to send along with the request.

The function also lets the client specify optional data to send to the HTTP server immediately following the request headers. This feature is generally used for "write" operations such as PUT and POST. When using optional data, be aware of the following caveat: the size of the optional data buffer, specified with the dwOptionalLength parameter, must be either less than 32 bytes or greater than approximately 150 bytes. Otherwise, the HttpSendRequest function fails.

Another caveat requires that the optional data buffer begin with '/r/n'. This ensures that header and buffer is separated by '/r/n/r/n' as required by RFC 2068.

After the request is sent, the status code and response headers from the HTTP server are read. These headers are maintained internally and are available to client applications through the HttpQueryInfo function.

An application can use the same HTTP request handle in multiple calls to HttpSendRequest, but the application must read all data returned from the previous call before calling the function again.

See Also

InternetReadFile