Jump to content
Sign in to follow this  

POST request with HTTP UDF

Recommended Posts


Hey guys,

I recently used the example here: http://www.autoitscript.com/forum/index.php?showtopic=30342 in an attemp to send a post request. I used the first exmaple which uses OverloadUT's HTTP UDF here: http://www.autoitscript.com/forum/index.ph...mp;#entry319354.

I made an example page at www.sabbgrafix.com/welcome.php which is an extremely simple post example. I use an ISSET function to display post information, if there is any submitted. The post info is "name=yourNameHere".

I used the following code, but when I try and return the body of the page after the post request is sent, I get nothing. But the @error is 0 and the other attributes state that it sucesfully connected and sent.

#include <IE.au3>
#include <http.au3>

$Header = "Content-Type: application/x-www-form-urlencoded"
$Host = "www.sabbgrafix.com"
$File = "/welcome.php"
$URL = "http://" & $Host & $File
$PostData = "name=steve"

$Socket = _HTTPConnect($Host)
_HTTPPost($Host, $File, $Socket, $PostData)
$recv = _HTTPRead($Socket,0)
MsgBox(0,"","BODY: "&$recv&" ERROR: "&@error)

Any ideas as to what I'm doing wrong, or anyone know of any other more efficient ways to send POST requests to sites via AutoIt?

Thanks guys!


Share this post

Link to post
Share on other sites

I have tested your example with Firefox and LiveHttpHeader extension.

The response is:

HTTP/1.x 200 OK

Connection: close

Date: Wed, 15 Oct 2008 04:21:31 GMT

Server: Microsoft-IIS/6.0

X-Powered-By: ASP.NET, PHP/4.3.11

Content-Type: text/html

I think the HTTP UDF doesn't work because there is no Content-Length value in the response and when i look at the html code it is the

same like before the POST.

(checked with IE and it works - contains new html code after the POST)

I think the easiest way to send post request is to use IE UDF (_IEFormElementSetValue, _IEFormSubmit and so on).

It depends on what you want to do. The WinInet functions MSDN or Ultima UDF provide the most efficient way, but they are heavy the handle. :P

The HTTP UDF is the best middle way the work with HTTP Headers, HTML code and there's no need to cookies or downloading binary files.

(although with some modify it should be possible too)

Share this post

Link to post
Share on other sites

Thank you so much j0linus! I appreciate all your help! I knew about the _IE UDF but I was just curious as to any other ways of doing it. Thank you so much though. That cleared a lot up.


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this