Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sends the specified request to the HTTP server.

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. See note in Remarks.

dwHeadersLength

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

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 Value

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

Remarks

There are two versions of this function HttpSendRequestAis used with ANSI builds and HttpSendRequestWis used with Unicode builds. If the value of dwHeadersLengthis -1L and the value of lpszHeadersis not NULL, when HttpSendRequestAis called, the function assumes that lpszHeadersis zero-terminated (ASCIIZ), and the length is calculated. When HttpSendRequestWis called with these values, the function fails with ERROR_INVALID_PARAMETER.

This function 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.

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 HttpQueryInfofunction.

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.

In offline mode, HttpSendRequestreturns ERROR_FILE_NOT_FOUND if the resource is not found in the Internet cache. This function sends the specified request to the HTTP server and allows the client to specify additional headers to send along with the request.

Requirements

Header wininet.h
Library wininet.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also