HttpOpenRequest

HttpOpenRequest

一旦和伺服器的連接已經建立,我們打開了想要的文件。HttpOpenRequest和HttpSendRequest一起工作打開文件。HttpOpenRequest去創建個請求句柄並且把參數存儲在句柄中。HttpSendRequest把請求參數送到HTTP伺服器。

目錄

正文


所處動態鏈接庫的文件名: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句柄
ValueDescription
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_INVALIDDisables 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_INVALIDDisables WinInet function checking of SSL/TLS-based certificates for proper validity dates.
INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPDisables 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_HTTPSDisables 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_CONNECTIONUses 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_PERSISTENTNot supported. 不支持
INTERNET_FLAG_MUST_CACHE_REQUESTCauses a temporary file to be created if the file cannot be cached. Identical to the preferred value INTERNET_FLAG_NEED_FILE.
INTERNET_FLAG_NEED_FILECauses a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_NO_AUTHDoes not attempt authentication automatically.
INTERNET_FLAG_NO_AUTO_REDIRECTDoes not automatically handle redirection in HttpSendRequest.
INTERNET_FLAG_NO_CACHE_WRITEDoes 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_COOKIESDoes not automatically add cookie headers to requests, and does not automatically add returned cookies to the cookie database.
INTERNET_FLAG_NO_UIDisables the cookie dialog box.
INTERNET_FLAG_PRAGMA_NOCACHEForces the request to be resolved by the origin server, even if a cached copy exists on the proxy.
INTERNET_FLAG_READ_PREFETCHThis flag is currently disabled.
INTERNET_FLAG_RELOADNot supported. Data is always from the wire and caching is not supported.
INTERNET_FLAG_RESYNCHRONIZEReloads HTTP resources if the resource has been modified since the last time it was downloaded.
INTERNET_FLAG_SECUREUses SSL/TLS transaction semantics.