Greenhornet Posted July 4, 2012 Posted July 4, 2012 Hello to the AutoIt Community - I'm here because I need help with WinHTTP:I coded a program which works with _WinHttpSimpleRequest and _WinHttpSimpleSSLRequest. But now I am working with proxies which require a username and password (ip:port:username:pw) but I can't get it to work. I already accomplished a working connection with HTTP but HTTPS won't work and I get the response "access dined". I would be happy if anybody could help me out. Here my code so farexpandcollapse popup;works $hConnect = _WinHttpConnect($hInternet, "autoit.de") Set_Proxy("ip:port") _WinHttpSimpleRequest2($hConnect, "GET") ;doesn't work $hConnect = _WinHttpConnect($hInternet, "google.de") Set_Proxy("ip:port") _WinHttpSimpleSSLRequest2($hConnect, "GET") Func _WinHttpSimpleRequest2($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sData = Default, $sHeader = Default, $fGetHeaders = Default, $iMode = Default) _WinHttpSetOption($hConnect, $WINHTTP_OPTION_PROXY_USERNAME, "user") _WinHttpSetOption($hConnect, $WINHTTP_OPTION_PROXY_PASSWORD, "pw") $source = "" $hRequest = _WinHttpOpenRequest($hConnect, $sType, $sPath, Default, $sReferrer) If $hRequest Then ; Set password here _WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_PROXY, $WINHTTP_AUTH_SCHEME_BASIC, "user", "pw") $sHeader = "Content-Type: application/x-www-form-urlencoded" & @CRLF If _WinHttpSendRequest($hRequest, $sHeader, $sData) Then _WinHttpReceiveResponse($hRequest) $source = _WinHttpSimpleReadData($hRequest) EndIf _WinHttpCloseHandle($hRequest) EndIf Return $source EndFunc Func _WinHttpSimpleSSLRequest2($hConnect, $sType = Default, $sPath = Default, $sReferrer = Default, $sData = Default, $sHeader = Default, $fGetHeaders = Default, $iMode = Default) $source = "" _WinHttpSetOption($hConnect, $WINHTTP_OPTION_PROXY_USERNAME, "user") _WinHttpSetOption($hConnect, $WINHTTP_OPTION_PROXY_PASSWORD, "pw") $hRequest = _WinHttpOpenRequest($hConnect, $sType, $sPath, Default, $sReferrer, Default, BitOR($WINHTTP_FLAG_SECURE, $WINHTTP_FLAG_ESCAPE_DISABLE)) If $hRequest Then ; Set password here _WinHttpSetCredentials($hRequest, $WINHTTP_AUTH_TARGET_PROXY, $WINHTTP_AUTH_SCHEME_BASIC, "user", "pw") $sHeader = "Content-Type: application/x-www-form-urlencoded" & @CRLF If _WinHttpSendRequest($hRequest, $sHeader, $sData) Then _WinHttpReceiveResponse($hRequest) $source = _WinHttpSimpleReadData($hRequest) EndIf _WinHttpCloseHandle($hRequest) EndIf Return $source EndFunc
Kyan Posted September 8, 2012 Posted September 8, 2012 (edited) try _WinHttpSimpleSSLRequest2($hConnect, "GET") Edited September 8, 2012 by DiOgO 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
ProgAndy Posted September 8, 2012 Posted September 8, 2012 You'll have to connect to the https port if you want to send ssl requests. The helpfile should contain examples. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
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