fielmann Posted April 14, 2008 Posted April 14, 2008 Hello autoit-friends!I'd like to send the folowing POST command to my webserver:--------------------------------------------POST /login.php?sid=d620b0ae8c1e8ac0f1155b7dddf054a1 HTTP/1.1Host: www.mywebserver.comUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-aliveReferer: http://www.mywebserver.com/Cookie: Logindata=myuser%B41; PHPSESSID=d620b0ae8c1e8ac0f1155b7dddf054a1Content-Type: application/x-www-form-urlencodedContent-Length: 113PHPSESSID=d620b0ae8c1e8ac0f1155b7dddf054a1&login_name=myuser&login_password=12345&Submit=enter+webserver--------------------------------------------I've put the hole content of the POST into the variable $command and then I send it with TCPSend($socket, $command).It does not work! Does anybody where the problem is?
weaponx Posted April 14, 2008 Posted April 14, 2008 I did this as a test, this is just some random site I found (http://www.snee.com/xml/crud/posttest.html). You will see that the html returned to the console is the exact same thing you will see in the browser. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "http://www.snee.com/xml/crud/posttest.cgi") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send("fname=john&lname=smith") ConsoleWrite($oHTTP.ResponseText & @CRLF) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1) Endfunc
fielmann Posted April 14, 2008 Author Posted April 14, 2008 weaponx said: I did this as a test, this is just some random site I found (http://www.snee.com/xml/crud/posttest.html). You will see that the html returned to the console is the exact same thing you will see in the browser. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "http://www.snee.com/xml/crud/posttest.cgi") $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send("fname=john&lname=smith") ConsoleWrite($oHTTP.ResponseText & @CRLF) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1) Endfunc Looks good at the first look! I've startet the script, but I can't see anything ?!? Where or how can I see the result of ConsoleWrite ? I've checked the autoit helpfile for consolewrite: Local $var = "Test" ConsoleWrite("var=" & $var & @CRLF) ; Running this in a text editor which can trap console output should produce "var=Test" Which editor supports this feature ?
aGorilla Posted April 14, 2008 Posted April 14, 2008 fielmann said: Which editor supports this feature ? SciTE. It's included with AutoIt.Start -> Programs -> AutoIt v3 -> SciTE Script Editor Search AutoItScript.com via Google
weaponx Posted April 14, 2008 Posted April 14, 2008 If you don't want to use ConsoleWrite() in this case you can use FileWrite("new.html", $oHTTP.ResponseText) to create an actual html file of the result page.
fielmann Posted April 14, 2008 Author Posted April 14, 2008 weaponx said: If you don't want to use ConsoleWrite() in this case you can use FileWrite("new.html", $oHTTP.ResponseText) to create an actual html file of the result page.Scite is OK, but how to catch ConsoleWrite-Output with it ?
weaponx Posted April 14, 2008 Posted April 14, 2008 fielmann said: Scite is OK, but how to catch ConsoleWrite-Output with it ? The console is shown when you run your script. Like I said, FileWrite() and FileWriteLine() will output to a file.
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