WinINet Functions


HttpSendRequest Function

Sends the specified request to the HTTP server.

Syntax

C++
BOOL HttpSendRequest(
  __in  HINTERNET hRequest,
  __in  LPCTSTR lpszHeaders,
  __in  DWORD dwHeadersLength,
  __in  LPVOID lpOptional,
  __in  DWORD dwOptionalLength
);

Parameters

hRequest [in]

Handle returned by HttpOpenRequest.

lpszHeaders [in]

Pointer to a null-terminated string that contains the additional headers to be appended to the request. This parameter can be NULL if there are no additional headers to be appended.

dwHeadersLength [in]

Size of the additional headers, in TCHARs. 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 Remarks for specifics.

lpOptional [in]

Pointer to a buffer containing any optional data to be sent 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]

Size of the optional data, in bytes. This parameter can be zero if there is no optional data to send.

Return Value

Returns TRUE if successful, or FALSE otherwise. 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.

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.

There two versions of HttpSendRequest —HttpSendRequestA (used with ANSI builds) and HttpSendRequestW (used with Unicode builds). If dwHeadersLength is -1L and lpszHeaders is not NULL, the following will happen: If HttpSendRequestA is called, the function assumes that lpszHeaders is zero-terminated (ASCIIZ), and the length is calculated. If HttpSendRequestW is called, the function fails with ERROR_INVALID_PARAMETER.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
VersionInternet Explorer 3.0 or later
HeaderWininet.h
LibraryWininet.lib
DLLWininet.dll
Unicode and ANSI namesHttpSendRequestW (Unicode) and HttpSendRequestA (ANSI)

See Also

HTTP Sessions
WinINet Functions

Send comments about this topic to Microsoft

Build date: 11/19/2009

Tags : wininet


Page view tracker