一旦和伺服器的連線已經建立,我們打開了想要的檔案。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. |