kenunloaded Posted May 5, 2011 Posted May 5, 2011 (edited) Alright so i was writing some code to do a login function for youtube. Now the problem is that whenever i try using a proxy with $WINHTTP_FLAG_SECURE option it just goes and connect to port 443 and doesn't go to the right url, i already tried inserting all different proxies and it just wont work . My functions works great without proxy but when ever i put a proxy and i use ssl its just gets stuck so for the following example i get this in return CONNECT www.google.com:443 HTTP/1.0 User-Agent: Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8 Host: www.google.com:443 Content-Length: 0 Proxy-Connection: Keep-Alive those are my http headers for example this is my code expandcollapse popupFunc _POST($main, $file, $query,$cookie = "none=none",$flags = 0,$isbinary = 0,$redirect = 0,$proxy = "",$referrer = "",$useragent = "") If $useragent = "" then $useragent = "Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8" Local $hOpen, $hConnect, $hRequest if $proxy = "" Then $hOpen = _WinHttpOpen("Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8",$WINHTTP_ACCESS_TYPE_NO_PROXY) Else $hOpen = _WinHttpOpen("Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8",$WINHTTP_ACCESS_TYPE_NAMED_PROXY,$proxy) EndIf $hConnect = _WinHttpConnect($hOpen, $main) _WinHttpSetTimeouts($hOpen,0,300000,1300000,1300000) ;$hRequest = _WinHttpOpenRequest($hConnect, "POST", $file, $WINHTTP_NO_REFERER, $WINHTTP_DEFAULT_ACCEPT_TYPES, $flags) $hRequest = _WinHttpOpenRequest($hConnect, "POST", $file, 'HTTP/1.1', $WINHTTP_NO_REFERER, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", $flags) _WinHttpAddRequestHeaders($hRequest, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") _WinHttpAddRequestHeaders($hRequest, "Accept-Language: en-us,en;q=0.5") _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: ") _WinHttpAddRequestHeaders($hRequest, "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7") _WinHttpAddRequestHeaders($hRequest, "Keep-Alive:115") _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive") _WinHttpAddRequestHeaders($hRequest, "Referer: " & $referrer) if $cookie <> "none=none" then _WinHttpAddRequestHeaders($hRequest, "Cookie: " & $cookie) if $redirect <> 0 then _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_REDIRECTS) _WinHttpSendRequest($hRequest, "Content-Type: application/x-www-form-urlencoded;charset=utf-8", $query) _WinHttpReceiveResponse($hRequest) Local $aReturn[2]= ['', ''] Switch $isbinary case 0 If _WinHttpQueryDataAvailable($hRequest) Then do $aReturn[1] &= _WinHttpReadData($hRequest) Until 0=@extended EndIf case 1 While 1 $bChunk = _WinHttpReadData($hRequest, 2) If @error Then ExitLoop $aReturn[1] = _WinHttpBinaryConcat($aReturn[1], $bChunk) WEnd EndSwitch $aReturn[0] = _WinHttpQueryHeaders($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $aReturn EndFunc Func _GET($main, $file,$cookie = "none=none",$flags = 0,$isbinary = 0,$redirect = 0,$proxy = "",$referrer = "",$useragent = "") If $useragent = "" then $useragent = "Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8" Local $hOpen, $hConnect, $hRequest if $proxy = "" Then $hOpen = _WinHttpOpen("Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8") Else $hOpen = _WinHttpOpen("Mozilla/5.0 (Winws; U; Winws NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 AskTbUT2V5/3.8.0.12304 Firefox/3.6.8",$WINHTTP_ACCESS_TYPE_NAMED_PROXY,$proxy) EndIf _WinHttpSetTimeouts($hOpen,0,300000,1300000,1300000) _WinHttpSetDefaultProxyConfiguration($WINHTTP_ACCESS_TYPE_DEFAULT_PROXY) $hConnect = _WinHttpConnect($hOpen, $main) $hRequest = _WinHttpOpenRequest($hConnect, "GET", $file, 'HTTP/1.1', $WINHTTP_NO_REFERER, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", $flags) _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: ") _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded") _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive") _WinHttpAddRequestHeaders($hRequest, "Referer: " & $referrer) if $cookie <> "none=none" then _WinHttpAddRequestHeaders($hRequest, "Cookie: " & $cookie) if $redirect <> 0 then _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_REDIRECTS) _WinHttpSendRequest($hRequest, "Content-Type: application/x-www-form-urlencoded;charset=utf-8") _WinHttpReceiveResponse($hRequest) Local $aReturn[2]= ['', ''] Switch $isbinary case 0 If _WinHttpQueryDataAvailable($hRequest) Then do $aReturn[1] &= _WinHttpReadData($hRequest) Until 0=@extended EndIf case 1 While 1 $bChunk = _WinHttpReadData($hRequest, 2) If @error Then ExitLoop $aReturn[1] = _WinHttpBinaryConcat($aReturn[1], $bChunk) WEnd EndSwitch $aReturn[0] = _WinHttpQueryHeaders($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $aReturn EndFunc _GET("www.google.com","/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252F&hl=en_US<mpl=sso","",$WINHTTP_FLAG_SECURE,0,0,"89.149.208.46:30366") Edited May 5, 2011 by kenunloaded
Kyan Posted September 14, 2012 Posted September 14, 2012 I have exactly the same question, I use a https proxy, but it doesn't connect to a website because is trying to connect to 443 port (https port) instead of 80 port, I set in _WinHttpConnect the 80 port, and how I espected it send a request with: CONNECT web.com:80 HTTP/1.1 Host: web.com:80 but not response from the server , if I remove the flag $WINHTTP_FLAG_SECURE, it works but, in this site "whatismyip.com" the proxy is detected, with $WINHTTP_FLAG_SECURE flag, so $WINHTTP_FLAG_SECURE is my problem may someone who's used to work with proxies/_winhttp could help... Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there'sĀ InetReadĀ and WinHTTP, way better
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now