Creates an HTTP request handle.
Syntax
HINTERNET HttpOpenRequest(
__in HINTERNET hConnect,
__in LPCTSTR lpszVerb,
__in LPCTSTR lpszObjectName,
__in LPCTSTR lpszVersion,
__in LPCTSTR lpszReferer,
__in LPCTSTR *lplpszAcceptTypes,
__in DWORD dwFlags,
__in DWORD_PTR dwContext
);
Parameters
- hConnect [in]
-
A
handle to an HTTP session returned by
InternetConnect.
- lpszVerb [in]
-
A pointer to a null-terminated string that contains the HTTP verb to use in the request. If this parameter is NULL, the function uses GET as the HTTP verb.
- lpszObjectName [in]
-
A pointer to a null-terminated string that contains the name of the target object of the specified HTTP verb. This is generally a file name, an executable module, or a search specifier.
- lpszVersion [in]
-
A pointer to a null-terminated string that contains the HTTP version. If this parameter is NULL, the function uses HTTP/1.1 as the version.
- lpszReferer [in]
-
A pointer to a null-terminated string that specifies the URL of the document from which the URL in the request (lpszObjectName) was obtained. If this parameter is NULL, no referrer is specified.
- lplpszAcceptTypes [in]
-
A pointer to a null-terminated array of strings that indicates media types accepted by the client. If this parameter is NULL, no types are accepted by the client. Servers generally interpret a lack of accept types to indicate that the client accepts only documents of type "text/*" (that is, only text documents—no pictures or other binary files). For more information and a list of valid media types, see
ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/media-types.
- dwFlags [in]
-
Internet options. This parameter can be any of the following values.
| Value | Meaning |
- INTERNET_FLAG_CACHE_IF_NET_FAIL
| Returns the resource from the cache if the network request for the resource fails due to an ERROR_INTERNET_CONNECTION_RESET (the connection with the server has been reset) or ERROR_INTERNET_CANNOT_CONNECT (the attempt to connect to the server failed).
|
- INTERNET_FLAG_HYPERLINK
| Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
|
- INTERNET_FLAG_IGNORE_CERT_CN_INVALID
| Disables checking of SSL/PCT-based certificates that are returned from the server against the host name given in the request. WinINet functions use a simple check against certificates by comparing for matching host names and simple wildcarding rules.
|
- INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
| Disables checking of SSL/PCT-based certificates for proper validity dates.
|
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
| Disables detection of this special type of redirect. When this flag is used, WinINet functions transparently allow redirects from HTTPS to HTTP URLs.
|
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
| Disables detection of this special type of redirect. When this flag is used, WinINet functions transparently allow redirects from HTTP to HTTPS URLs.
|
- INTERNET_FLAG_KEEP_CONNECTION
| Uses keep-alive semantics, if available, for the connection. This flag is required for Microsoft Network (MSN), NT LAN Manager (NTLM), and other types of authentication.
|
- INTERNET_FLAG_NEED_FILE
| Causes a temporary file to be created if the file cannot be cached.
|
- INTERNET_FLAG_NO_AUTH
| Does not attempt authentication automatically.
|
- INTERNET_FLAG_NO_AUTO_REDIRECT
| Does not automatically handle redirection in
HttpSendRequest.
|
- INTERNET_FLAG_NO_CACHE_WRITE
| Does not add the returned entity to the cache.
|
- INTERNET_FLAG_NO_COOKIES
| Does not automatically add cookie headers to requests, and does not automatically add returned cookies to the cookie database.
|
- INTERNET_FLAG_NO_UI
| Disables the cookie dialog box.
|
- INTERNET_FLAG_PRAGMA_NOCACHE
| Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy.
|
- INTERNET_FLAG_RELOAD
| Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
|
- INTERNET_FLAG_RESYNCHRONIZE
| Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP resources are reloaded.
Windows XP and Windows Server 2003 R2 and earlier: Gopher resources are also reloaded.
|
- INTERNET_FLAG_SECURE
| Uses secure transaction semantics. This translates to using Secure Sockets Layer/Private Communications Technology (SSL/PCT) and is only meaningful in HTTP requests.
|
- dwContext [in]
-
A pointer to a variable that contains the application-defined value that associates this operation with any application data.
Return Value
Returns an HTTP request handle if successful, or NULL otherwise. To retrieve extended error information, call
GetLastError.
Remarks
HttpOpenRequest creates a new HTTP request handle and stores the specified parameters in that handle. An HTTP request handle holds a request to be sent to an HTTP server and contains all RFC822/MIME/HTTP headers to be sent as part of the request.
If a verb other than "GET" or "POST" is specified, HttpOpenRequest automatically sets INTERNET_FLAG_NO_CACHE_WRITE and INTERNET_FLAG_RELOAD for the request.
With Microsoft Internet Explorer 5 and later, if
lpszVerb is set to "HEAD", the Content-Length header is ignored on responses from HTTP/1.1 servers.
After the calling application has finished using the
HINTERNET handle returned by
HttpOpenRequest, it must be closed using the
InternetCloseHandle function.
Note When a request is sent in asynchronous mode (the dwFlags parameter of
InternetOpen specifies INTERNET_FLAG_ASYNC), and the dwContext parameter is zero (INTERNET_NO_CALLBACK), the callback function set with
InternetSetStatusCallback on the request handle will not be invoked, however, the call will still be performed in asynchronous mode.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Version | Internet Explorer 3.0 or later |
| Header | Wininet.h |
| Library | Wininet.lib |
| DLL | Wininet.dll |
| Unicode and ANSI names | HttpOpenRequestW (Unicode) and HttpOpenRequestA (ANSI) |
See Also
- HTTP Sessions
- WinINet Functions
Send comments about this topic to Microsoft
Build date: 11/19/2009