HttpOpenRequestW function
Retrieves a pointer to an HTTP request handle for a specified HTTP session. Use this function to prepare an HTTP request to be sent to the HTTP server.
Syntax
BOOL HttpOpenRequestW(
HINTERNET hInternet,
LPCWSTR pszVerb,
LPCWSTR pszObjectName,
LPCWSTR pszVersion,
LPCWSTR pszReferer,
LPCWSTR *ppszAcceptTypes,
DWORD dwFlags,
DWORD_PTR dwContext
);
Parameters
| Parameter | Description |
|---|---|
hInternet |
A handle to an HINTERNET session created by a previous call to InternetOpen. |
pszVerb |
A pointer to a null-terminated string that contains the HTTP request verb. Common verbs include GET, POST, and HEAD. If this parameter is NULL, the function uses GET. |
pszObjectName |
A pointer to a null-terminated string that contains the URL-encoded name of the target object. This is typically the file name or resource on the server. If this parameter is NULL, the function uses /. |
pszVersion |
A pointer to a null-terminated string that contains the HTTP version. If this parameter is NULL, the function uses HTTP/1.1. |
pszReferer |
A pointer to a null-terminated string that contains the URL of the document containing the URL specified by pszObjectName. If this parameter is NULL, the function does not send a referer header. |
ppszAcceptTypes |
A pointer to a null-terminated array of null-terminated strings that specify the MIME types the client can accept. If this parameter is NULL, the function accepts all MIME types. |
dwFlags |
Flags that control the behavior of the request. See HttpOpenRequest Flags for a list of possible values. |
dwContext |
A pointer to a DWORD_PTR that contains the application-defined context value associated with this request. This context value is used in callbacks to identify the application's context. |
Return Value
Returns a handle to an HINTERNET request object if the function succeeds, or NULL otherwise. To get extended error information, call GetLastError.
Remarks
The HttpOpenRequestW function opens an HTTP request. The returned handle is a child of the handle specified by hInternet.
The request handle must be closed by calling InternetCloseHandle.
The application must call InternetConnect before calling HttpOpenRequestW if the hInternet parameter is a handle to an HINTERNET session created by InternetOpen. If hInternet is a handle to an HINTERNET connection, then HttpOpenRequestW can be called directly.
Note
This API is part of the WinInet API, which is a set of high-level APIs for accessing resources over HTTP and FTP. Win32 applications should use Win32 APIs like this whenever possible.
Important
The HttpOpenRequestW function is the wide-character (Unicode) version of HttpOpenRequestA. The ANSI version is HttpOpenRequestA.
Requirements
| Attribute | Value |
|---|---|
| Minimum supported client | Windows 2000 Professional [desktop apps only] |
| Minimum supported server | Windows 2000 Server [desktop apps only] |
| Header | wininet.h |
| Library | Wininet.lib |
| DLL | Wininet.dll |
| Unicode and ANSI versions | HttpOpenRequestW (Unicode) and HttpOpenRequestA (ANSI) |