一旦和伺服器的连线已经建立,我们打开了想要的档案。HttpOpenRequest和HttpSendRequest一起工作打开档案。HttpOpenRequest去创建个请求句柄并且把参数存储在句柄中。HttpSendRequest把请求参数送到HTTP伺服器。
基本介绍
- 外文名:HttpOpenRequest
- 档案名称:WinINet.dll
- 共同工作档案:HttpSendRequest
- 领域:程式设计
所处动态程式库的档案名称:WinINet.dll
HINTERNET hHttpFile = ::HttpOpenRequest(
hConnect, // 1 HINTERNET hHttpSession
"GET",// 2 LPCTSTR lpszVerb
"/MSDN/MSDNINFO/", // 3 LPCTSTR lpszObjectName
HTTP_VERSION, // 4 LPCTSTR lpszVersion
NULL,// 5 LPCTSTR lpszReferer
0, // 6 LPCTSTR FAR * lplpszAcceptTypes
INTERNET_FLAG_DONT_CACHE, // 7 DWORD dwFlags
0 // 8 DWORD dwContext
) ;
返回创建请求的句柄。
参数<1>的名称为“hConnect”,类型为“整数型”。就是Internet的连线句柄
参数<2>的名称为“lpszVerb”,类型为“文本型”。访问方式。在网页里只有get和post两种方法
参数<3>的名称为“lpszObjectName”,类型为“文本型”。页面的地址
参数<4>的名称为“lpszVersion”,类型为“文本型”。协定的版本“HTTP/1.1”现在通用的是这样。貌似听说过2.0,但是不懂是啥意思。
参数<5>的名称为“lpszReferer”,类型为“文本型”。引用页,抓包得到的refer
参数<6>的名称为“lplpszAcceptTypes”,类型为“文本型”。
参数<7>的名称为“dwFlags”,类型为“整数型”。2147483648
参数<8>的名称为“dwContext”,类型为“整数型”。0
如果创建失败。需要释放Internetopen句柄和Internetconnect句柄
Value | Description |
INTERNET_FLAG_CACHE_IF_NET_FAIL | Return the resource from the cache if the network request for the resource fails due to an ERROR_INTERNET_CONNECTION_RESET or ERROR_INTERNET_CANNOT_CONNECT. 为资源的网路请求失败返回快取的资源 |
INTERNET_FLAG_DONT_CACHE | Not supported. Data is never cached. 数据没有被快取。 |
INTERNET_FLAG_HYPERLINK | Forces a reload if there was no Expires time and no Last-Modified time returned from the server when determining whether to reload the item from the network. WinInet函式禁用SSL / TLS证书,是基于对给定的主机名的请求伺服器返回检查。WinInet函式对一个简单的检查,使用证书的主机名称和简单的通配符匹配规则的比较。 |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID | Disables WinInet function checking of SSL/TLS-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 WinInet function checking of SSL/TLS-based certificates for proper validity dates. |
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | Disables the ability of the WinInet functions to detect 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 the ability of the WinInet functions to detect 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_MAKE_PERSISTENT | Not supported. 不支持 |
INTERNET_FLAG_MUST_CACHE_REQUEST | Causes a temporary file to be created if the file cannot be cached. Identical to the preferred value INTERNET_FLAG_NEED_FILE. |
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. If the INTERNET_FLAG_HYPERLINK is also specified, WinInet will create the cache file but will not commit it. |
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_READ_PREFETCH | This flag is currently disabled. |
INTERNET_FLAG_RELOAD | Not supported. Data is always from the wire and caching is not supported. |
INTERNET_FLAG_RESYNCHRONIZE | Reloads HTTP resources if the resource has been modified since the last time it was downloaded. |
INTERNET_FLAG_SECURE | Uses SSL/TLS transaction semantics. |