Skip to content

Commit 4fea706

Browse files
committed
Changed: Default user-agent string.
1 parent 72d80df commit 4fea706

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

WinHttp.au3

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ EndFunc
492492
; Name...........: _WinHttpOpen
493493
; Description ...: Initializes the use of WinHttp functions and returns a WinHttp-session handle.
494494
; Syntax.........: _WinHttpOpen([$sUserAgent = Default [, $iAccessType = Default [, $sProxyName = Default [, $sProxyBypass = Default [, $iFlag = Default ]]]]])
495-
; Parameters ....: $sUserAgent - [optional] The name of the application or entity calling the WinHttp functions. Default is "AutoIt/3.3 WinHTTP/5.1".
495+
; Parameters ....: $sUserAgent - [optional] The name of the application or entity calling the WinHttp functions.
496496
; $iAccessType - [optional] Type of access required. Default is $WINHTTP_ACCESS_TYPE_NO_PROXY.
497497
; $sProxyName - [optional] The name of the proxy server to use when proxy access is specified by setting $iAccessType to $WINHTTP_ACCESS_TYPE_NAMED_PROXY. Default is $WINHTTP_NO_PROXY_NAME.
498498
; $sProxyBypass - [optional] An optional list of host names or IP addresses, or both, that should not be routed through the proxy when $iAccessType is set to $WINHTTP_ACCESS_TYPE_NAMED_PROXY. Default is $WINHTTP_NO_PROXY_BYPASS.
@@ -507,7 +507,7 @@ EndFunc
507507
; Link ..........: http://msdn.microsoft.com/en-us/library/aa384098.aspx
508508
;============================================================================================
509509
Func _WinHttpOpen($sUserAgent = Default, $iAccessType = Default, $sProxyName = Default, $sProxyBypass = Default, $iFlag = Default)
510-
__WinHttpDefault($sUserAgent, "AutoIt/3.3 WinHTTP/5.1")
510+
__WinHttpDefault($sUserAgent, __WinHttpUA())
511511
__WinHttpDefault($iAccessType, $WINHTTP_ACCESS_TYPE_NO_PROXY)
512512
__WinHttpDefault($sProxyName, $WINHTTP_NO_PROXY_NAME)
513513
__WinHttpDefault($sProxyBypass, $WINHTTP_NO_PROXY_BYPASS)
@@ -2098,6 +2098,23 @@ Func __WinHttpPtrStringLenW($pString)
20982098
Return $aCall[0]
20992099
EndFunc
21002100

2101+
Func __WinHttpUA()
2102+
Local Static $sUA = "Mozilla/5.0 " & __WinHttpSysInfo() & " WinHttp/" & __WinHttpVer() & " (WinHTTP/5.1) like Gecko"
2103+
Return $sUA
2104+
EndFunc
2105+
2106+
Func __WinHttpSysInfo()
2107+
Local $sData = FileGetVersion("kernel32.dll")
2108+
$sData = "(Windows NT " & StringLeft($sData, StringInStr($sData, ".", 1, 2) - 1)
2109+
If StringInStr(@OSArch, "64") And Not @AutoItX64 Then $sData &= "; WOW64"
2110+
$sData &= ")"
2111+
Return $sData
2112+
EndFunc
2113+
2114+
Func __WinHttpVer()
2115+
Return "1.6.3.8"
2116+
EndFunc
2117+
21012118
Func _WinHttpBinaryConcat(ByRef $bBinary1, ByRef $bBinary2)
21022119
Local $bOut = _WinHttpSimpleBinaryConcat($bBinary1, $bBinary2)
21032120
Return SetError(@error, 0, $bOut)

0 commit comments

Comments
 (0)