获取与HTTP请求相关的头部信息.
#Include <WinHttp.au3>
_WinHttpQueryHeaders($hRequest [, $iInfoLevel = Default [, $sName = Default [, $iIndex = Default ]]])
$hRequest | _WinHttpOpenRequest() 函数返回的句柄. |
$iInfoLevel | [可选参数] 一个包含属性和修正标志的组合. 默认为 $WINHTTP_QUERY_RAW_HEADERS_CRLF. |
$sName | [可选参数] 头名称字符串. 默认为 $WINHTTP_HEADER_NAME_BY_INDEX. |
$iIndex | [可选参数] 枚举多个同名头的索引. |
成功: | 返回包含头的字符串. |
失败: | 返回空字符串并设置 @error: |
1 - DllCall 失败 |
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include "WinHttp.au3"
Opt("MustDeclareVars", 1)
; 打开需要的句柄
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, "msdn.microsoft.com")
; 指明请求:
Global $hRequest = _WinHttpOpenRequest($hConnect, Default, "en-us/library/aa384101(VS.85).aspx")
; 发送请求
_WinHttpSendRequest($hRequest)
; 等待响应
_WinHttpReceiveResponse($hRequest)
; 获取完整头部
Global $sHeader = _WinHttpQueryHeaders($hRequest)
; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
; 显示获取的头部
MsgBox(0, "Header", $sHeader)