ProgAndy Posted March 6, 2010 Share Posted March 6, 2010 You have to add the content-type-hedaer: _WinHttpSendRequest($hRequest,"Content-Type: application/x-www-form-urlencoded" & @CRLF, $WINHTTP_NO_REQUEST_DATA, StringLen($data)) *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 Link to comment Share on other sites More sharing options...
trancexx Posted March 6, 2010 Author Share Posted March 6, 2010 (edited) And technically you don't need to use _WinHttpWriteData(). You can send this:$data = "v=101" _WinHttpSendRequest($hRequest,"Content-Type: application/x-www-form-urlencoded", $data) or:$data = "v=101" _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded") _WinHttpSendRequest($hRequest,$WINHTTP_NO_ADDITIONAL_HEADERS, $data) Edited March 6, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Digisoul Posted March 6, 2010 Share Posted March 6, 2010 Thank you very much for your kind help guys. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
Digisoul Posted March 6, 2010 Share Posted March 6, 2010 WinHttpWriteData has been translated by trancexx and me.Now, i#ll post WinHttpCrackUrl, WinHttpCreateUrl and WinHttpSetStatusCallback (examples in the files)your callback example never work for me ? 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
ProgAndy Posted March 6, 2010 Share Posted March 6, 2010 your callback example never work for me ?The example acutally doesn't do anything. It just sets the status callback and exits, you have to add some code on your own to use the status callback. *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 Link to comment Share on other sites More sharing options...
Digisoul Posted March 6, 2010 Share Posted March 6, 2010 The example acutally doesn't do anything. It just sets the status callback and exits, you have to add some code on your own to use the status callback.I am not a pro in C++ , so any working example please ? 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
ProgAndy Posted March 6, 2010 Share Posted March 6, 2010 Why do you need an other example? This function is only useful if you want to do asynchronous WinHTTP-calls, that means sending a request without waiting for tehe response of the server. Then the callback will receive a message when the server has responded and your script can continue processing the response. I think this techniue is rarely used. *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 Link to comment Share on other sites More sharing options...
Digisoul Posted March 6, 2010 Share Posted March 6, 2010 Why do you need an other example? This function is only useful if you want to do asynchronous WinHTTP-calls, that means sending a request without waiting for tehe response of the server. Then the callback will receive a message when the server has responded and your script can continue processing the response.I think this techniue is rarely used.I am creating a Clint Service for updating the software (Automatic or Manual), which is controlled by the User Base GUI. So when the user send the request or the new update is avialible , it will start the update process & send the updating progress to the User Base GUI.Before implementing this UDF i was using FTP & "internet Status Callback" function to show the progress, but i found that FTP is not enough secure, i mean i found some tools which can allocate detail about Opened Session of FTP, thats why i come to this UDF. I know that there is nothing impossible to hack, but through HTTP & PHP its a bit secure.Now i want to implement the callback function, but in your example its always return the INVALID_HANDLE, thats why i am asking for working example. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
rCANE Posted March 30, 2010 Share Posted March 30, 2010 Thanks for this great UDF! Is it possible somehow to check the progress when uploading/downloading files ( uploaded / downloaded bytes ) ? ...in my case uploading to/downloading from PHP. THX! Link to comment Share on other sites More sharing options...
autoitVietNam Posted May 5, 2010 Share Posted May 5, 2010 I asked for function _WinHttpAddRequestHeaders($ hRequest, $ sHeader, $ = $ WINHTTP_ADDREQ_FLAG_ADD_IF_NEW iModifier) $SHeader = cookie ????? Link to comment Share on other sites More sharing options...
trancexx Posted May 5, 2010 Author Share Posted May 5, 2010 Leave English aside for a moment, speak only AutoIt. Maybe you'll be understood better. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Marlo Posted May 20, 2010 Share Posted May 20, 2010 Good work mate, This will help me alot Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
motionman95 Posted July 27, 2010 Share Posted July 27, 2010 This works perfectly, but there seems to be a limit on the amount of text returned by a request? In my code it's not returning the whole response. Link to comment Share on other sites More sharing options...
motionman95 Posted July 29, 2010 Share Posted July 29, 2010 This works perfectly, but there seems to be a limit on the amount of text returned by a request? In my code it's not returning the whole response.Bump... Link to comment Share on other sites More sharing options...
trancexx Posted July 29, 2010 Author Share Posted July 29, 2010 And the code is? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
motionman95 Posted July 29, 2010 Share Posted July 29, 2010 And the code is? Func _POSTRequest($domain, $file, $query) Local $hOpen, $hConnect, $hRequest $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, $domain) $hRequest = _WinHttpOpenRequest($hConnect, "POST", $file) _WinHttpAddRequestHeaders($hRequest, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6") _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded") _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive") _WinHttpSendRequest($hRequest, $WINHTTP_NO_ADDITIONAL_HEADERS, $query) _WinHttpReceiveResponse($hRequest) $hResponse = _WinHttpReadData($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $hResponse EndFunc That's the function I use...it's only giving me back a 8192 of the response instead of the full response. Link to comment Share on other sites More sharing options...
trancexx Posted July 29, 2010 Author Share Posted July 29, 2010 (edited) Func _POSTRequest($domain, $file, $query) Local $hOpen, $hConnect, $hRequest $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, $domain) $hRequest = _WinHttpOpenRequest($hConnect, "POST", $file) _WinHttpAddRequestHeaders($hRequest, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6") _WinHttpAddRequestHeaders($hRequest, "Content-Type: application/x-www-form-urlencoded") _WinHttpAddRequestHeaders($hRequest, "Connection: Keep-Alive") _WinHttpSendRequest($hRequest, $WINHTTP_NO_ADDITIONAL_HEADERS, $query) _WinHttpReceiveResponse($hRequest) $hResponse = _WinHttpReadData($hRequest) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $hResponse EndFunc That's the function I use...it's only giving me back a 8192 of the response instead of the full response. No, not "instead". That's the default behavior of _WinHttpReadData() function. I made sure that was documented, just read the header of that function. Anyway, you have to read in a loop to get all of the response. For example:;... Local $sChunk, $sResponse While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sResponse &= $sChunk WEnd _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $sResponse ;... Edited July 29, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
motionman95 Posted August 3, 2010 Share Posted August 3, 2010 (edited) Thanks trancexx. New problem, LOL. Err, is WinHTTP not able to access localhost? The following code won't work... #include "WinHTTP.au3" $LocalIP = "localhost" $hw_open = _WinHttpOpen() $hw_connect = _WinHttpConnect($hw_open, $LocalIP) $h_openRequest = _WinHttpOpenRequest($hw_connect, "GET", "/test.html") _WinHttpSendRequest($h_openRequest,$WINHTTP_NO_ADDITIONAL_HEADERS, $WINHTTP_NO_REQUEST_DATA) _WinHttpReceiveResponse($h_openRequest) MsgBox(0, "", _WinHttpReadData($h_openRequest)) _WinHttpCloseHandle($h_openRequest) _WinHttpCloseHandle($hw_connect) _WinHttpCloseHandle($hw_open) Edited August 3, 2010 by motionman95 Link to comment Share on other sites More sharing options...
trancexx Posted August 4, 2010 Author Share Posted August 4, 2010 Go with "127.0.0.1". ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
motionman95 Posted August 4, 2010 Share Posted August 4, 2010 Go with "127.0.0.1".Err, that doesn't work either. If I MsgBox it I get something like "yb<" 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