frank10 Posted January 10, 2011 Share Posted January 10, 2011 All works very well. Thank you. Link to comment Share on other sites More sharing options...
arcker Posted January 17, 2011 Share Posted January 17, 2011 Hi frank, finally it works, good news you're welcome. So my question about mime/type was legitimate ! it happened to mee too. Hope this will help future coders. regards, arcker. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
frank10 Posted May 30, 2011 Share Posted May 30, 2011 Hi! Here, all goes well in syncronous POST calls. Very good. Now, I want to make an async call to a php file, because I don't need the response output and the php has a while cycle that blocks autoit execution. If you make a sync call, after local $hHttpSendRequest= _WinINet_HttpSendRequest($hHttpOpenRequest, $toSend, StringToBinary($JSONdata) ) it waits all the php while cycle and it blocks the autoit script. So, I tried an async approach in GET, putting $INTERNET_FLAG_ASYNC in InternetOpen: $hInternetOpen = _WinINet_InternetOpen("Mozilla/5.0 Firefox/3.0.1",$INTERNET_OPEN_TYPE_DIRECT, $INTERNET_FLAG_ASYNC, Default, Default) $hInternetConnect = _WinINet_InternetConnect($hInternetOpen, $INTERNET_SERVICE_HTTP, "www.myserver", 0, 0, Default, Default, 0) $hHttpOpenRequest = _WinINet_HttpOpenRequest($hInternetConnect, "GET", "/public/Files/PHP/contentLoop.php?" & $JSONdata, $INTERNET_FLAG_RELOAD, "HTTP/1.1", Default, Default, 0) $hHttpSendRequest = _WinINet_HttpSendRequest($hHttpOpenRequest, Default, Default) But it fails with the SendRequest that returns false, while InternetOpen and InternetConnect work. I need only to fire up my php and close my connection and continue autoit script, I don't need any answer from the server. Link to comment Share on other sites More sharing options...
frank10 Posted December 30, 2011 Share Posted December 30, 2011 (edited) I was trying to see if there is Internet connection before sending other wininet commands, so I tried both_WinINet_InternetCheckConnection()_WinINet_InternetAttemptConnect()Both failed.While I tried another call to the dll found in the forum and this works.It's necessary to correct the udf.Local $sz_url = "http://www.google.com" Local $u_flags = 0x00000001 Local $u_reserved = 0 Local $a_ret_val = DllCall("WinInet.dll", "int", "InternetCheckConnection", "str", $sz_url, "uint", $u_flags, "uint", $u_reserved) ConsoleWrite($sz_url & " is connected = " & ($a_ret_val[0] <> 0) & @CRLF) ConsoleWrite(_WinINet_InternetCheckConnection()& @CRLF) $iInternetAttemptConnect = ConsoleWrite( _WinINet_InternetAttemptConnect() & @CRLF )with an Internet connection:http://www.google.com is connected = TrueTrueTruewithout an Internet connection:http://www.google.com is connected = FalseTrueTrue Edited December 30, 2011 by frank10 Link to comment Share on other sites More sharing options...
Inververs Posted January 27, 2012 Share Posted January 27, 2012 Just for example. Get certificate info. expandcollapse popup#include "WinINet.au3" _WinINet_Startup() ; Set variables Local $sURIScheme = "https" Local $sServerName = "mail.google.com" Local $iServerPort = 443 Local $hInternetOpen = _WinINet_InternetOpen("AutoIt/" & @AutoItVersion) If @error Then Exit ConsoleWrite("Open Internet connection: failed." & @LF) Local $hInternetOpenUrl = _WinINet_InternetOpenUrl($hInternetOpen, $sURIScheme & "://" & $sServerName, Default, $INTERNET_FLAG_SECURE) If @error Then Exit ConsoleWrite("Open Internet URL: failed." & @LF) ConsoleWrite("Query certificate info..." & @LF) Local $tBuffer = _WinINet_InternetQueryOption($hInternetOpenUrl, $INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT) Local $tINTERNET_CERTIFICATE_INFO = DllStructCreate($tagINTERNET_CERTIFICATE_INFO, DllStructGetPtr($tBuffer)) Local $tSystTime = DllStructCreate($tagSYSTEMTIME) ConsoleWrite("=====================================================" & @LF) DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", DllStructGetPtr($tINTERNET_CERTIFICATE_INFO, "StartTime"), "struct*", $tSystTime) $sResult = StringFormat("%04d-%02d-%02d %02d:%02d:%02d", _ DllStructGetData($tSystTime, "Year"), _ DllStructGetData($tSystTime, "Month"), _ DllStructGetData($tSystTime, "Day"), _ DllStructGetData($tSystTime, "Hour"), _ DllStructGetData($tSystTime, "Minute"), _ DllStructGetData($tSystTime, "Second")) ConsoleWrite("StartTime: " & $sResult & @LF) ConsoleWrite("=====================================================" & @LF) DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", DllStructGetPtr($tINTERNET_CERTIFICATE_INFO, "ExpiryTime"), "struct*", $tSystTime) $sResult = StringFormat("%04d-%02d-%02d %02d:%02d:%02d", _ DllStructGetData($tSystTime, "Year"), _ DllStructGetData($tSystTime, "Month"), _ DllStructGetData($tSystTime, "Day"), _ DllStructGetData($tSystTime, "Hour"), _ DllStructGetData($tSystTime, "Minute"), _ DllStructGetData($tSystTime, "Second")) ConsoleWrite("ExpiryTime: " & $sResult & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("KeySize: " & DllStructGetData($tINTERNET_CERTIFICATE_INFO, "KeySize") & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("SubjectInfo: " & DllStructGetData(DllStructCreate('char[256]', DllStructGetData($tINTERNET_CERTIFICATE_INFO, "SubjectInfo")), 1) & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("IssuerInfo: " & DllStructGetData(DllStructCreate('char[256]', DllStructGetData($tINTERNET_CERTIFICATE_INFO, "IssuerInfo")), 1) & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("ProtocolName: " & DllStructGetData(DllStructCreate('char[256]', DllStructGetData($tINTERNET_CERTIFICATE_INFO, "ProtocolName")), 1) & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("SignatureAlgName: " & DllStructGetData(DllStructCreate('char[256]', DllStructGetData($tINTERNET_CERTIFICATE_INFO, "SignatureAlgName")), 1) & @LF) ConsoleWrite("=====================================================" & @LF) ConsoleWrite("EncryptionAlgName: " & DllStructGetData(DllStructCreate('char[256]', DllStructGetData($tINTERNET_CERTIFICATE_INFO, "EncryptionAlgName")), 1) & @LF) ConsoleWrite("=====================================================" & @LF) _WinINet_InternetCloseHandle($hInternetOpenUrl) _WinINet_InternetCloseHandle($hInternetOpen) _WinINet_Shutdown() mLipok 1 Link to comment Share on other sites More sharing options...
lionfaggot Posted October 23, 2013 Share Posted October 23, 2013 (edited) does this udf handle cookies? or do i have to parse that myself? its fine if i do, i know how to do it with sockets and its the same logic eh? but im assuming this handles those provisions for you correct Edit: nevermind i see now in the udf this more than thoroughly handles cookies. quite pleased Edited October 24, 2013 by lionfaggot Link to comment Share on other sites More sharing options...
Acanis Posted January 26, 2019 Share Posted January 26, 2019 (edited) Sad, that this UDF is outdated. Looks amazing Edited January 26, 2019 by Acanis Link to comment Share on other sites More sharing options...
iso23270 Posted April 3, 2019 Share Posted April 3, 2019 Hi, I stumbled over a strange problem which I described here: https://www.autoitscript.com/forum/topic/198427-strange-wininet-problem Bottom line: If I use the _WinINet_HttpSendRequest function as is and I send additional data in the request, every second byte of the data is 0x0 - which is obviously wrong. I solved it with modifying the function like this: expandcollapse popupFunc _MyWinINet_HttpSendRequest($hHttpOpenRequest, $sHeaders = Default, $vOptional = Default) ; Set data/structures up Local $iHeaders = 0, $pHeaders = 0 If $sHeaders <> Default Then $iHeaders = StringLen($sHeaders) Local $tHeaders = DllStructCreate($WIN32_TCHAR & "[" & ($iHeaders+1) & "]") DllStructSetData($tHeaders, 1, $sHeaders) $pHeaders = DllStructGetPtr($tHeaders) EndIf Local $iOptional = 0, $pOptional = 0 If $vOptional <> Default Then If IsDllStruct($vOptional) Then $iOptional = DllStructGetSize($vOptional) $pOptional = DllStructGetPtr($vOptional) Else Local $tOptional If IsBinary($vOptional) Then $iOptional = BinaryLen($vOptional) $tOptional = DllStructCreate("byte[" & $iOptional & "]") Else $iOptional = StringLen($vOptional) ; using $WIN32_TCHAR here will not work when trying to send additional paylod ; with the request, e.g. when trying REQUEST for a webdav service $tOptional = DllStructCreate("char[" & ($iOptional+1) & "]") EndIf DllStructSetData($tOptional, 1, $vOptional) $pOptional = DllStructGetPtr($tOptional) EndIf EndIf ; Make DLL call Local $avResult = DllCall($__WinINet_hDLL, _ "int", "HttpSendRequest" & $WIN32_FTYPE, _ "ptr", $hHttpOpenRequest, _ "ptr", $pHeaders, _ "dword", $iHeaders, _ "ptr", $pOptional, _ "dword", $iOptional _ ) ; Return response If @error Or Not $avResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_MyWinINet_HttpSendRequest Link to comment Share on other sites More sharing options...
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