Partager via


HttpSendRequest

A version of this page is also available for

Windows Embedded CE 6.0 R3

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

  • 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 lpszHeaders is not NULL, the function assumes that lpszHeaders is 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 HttpSendRequestA is used with ANSI builds and HttpSendRequestW is used with Unicode builds. If the value of dwHeadersLength is -1L and the value of lpszHeaders is not NULL, when HttpSendRequestA is called, the function assumes that lpszHeaders is zero-terminated (ASCIIZ), and the length is calculated. When HttpSendRequestW is 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 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.

In offline mode, HttpSendRequest returns 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

Reference

HttpOpenRequest
HttpQueryInfo
InternetReadFile
WinInet Functions