Click to return to the Networking, Protocols     
HttpQueryInfo Function     HttpSendRequestEx Functio...     HTTP Functions    
Web Workshop  |  Networking, Protocols & Data Formats

HttpSendRequest Function


Sends the specified request to the HTTP server.

Syntax

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

The actual syntax of this function varies between its ANSI and Unicode implementations. For more information, see Win32 Internet Functions Syntax.

Parameters

hRequest
HINTERNET handle returned by HttpOpenRequest.
lpszHeaders
Address of a string variable that contains the additional headers to be appended to the request. This parameter can be NULL if there are no additional headers to append.
dwHeadersLength
Unsigned long integer value that contains the length, in TCHAR, 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
Address of a buffer containing 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
Unsigned long integer value that contains the length, in bytes, of the optional data. 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 will return ERROR_FILE_NOT_FOUND if the resource is not found in the Internet cache.

Function Information

Windows NT Use version 4.0. Implemented as ANSI and Unicode functions.
Windows Use Windows 95 and later. Implemented as ANSI and Unicode functions.
Header Wininet.h
Import library Wininet.lib
Minimum availability Internet Explorer 3.0 (ANSI only), 5 (ANSI and Unicode)

Windows CE

Windows CE Use version 2.12 and later. Implemented as ANSI and Unicode functions.
Minimum availability Internet Explorer 4.0

See Also

Microsoft Win32 Internet Functions Overview, HTTP Sessions, Microsoft Win32 Internet Functions Reference, HTTP Functions



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.