Jump to content

How to send large strings over http?


Recommended Posts

I want to send with either post or get serveral &vars= to a php page. This works with my first example as long as the total url string is less then something like 2000 chars.

$sUrl="http://192.168.1.8/final/com/insert.php?test1=bla&test2=bla"
$hDataBin=InetRead($sUrl,1)
$sData=BinaryToString($hDataBin)
msgbox(0,"",stringlen($sUrl)&". "&$sData)

So then I thought lets try something else like post with WinHttp.au3, but whatever I try this next example never sends anything.

#include<WinHttp.au3>
$hInternet = _WinHttpOpen()
$hConnect = _WinHttpConnect($hInternet, "http://192.168.1.8")
$sPost = "test1=bla&test2=bla"
$sResult = _WinHttpSimpleRequest($hConnect, "POST", "/final/com/insert.php", '', $sPost)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hInternet)
MsgBox(0, '',stringlen($str)&". "&$sResult)

So can anyone perhaps tell me how I could use autoit to make this work? Or is there some max on the post/get string?

Edited by Rutger83
Link to comment
Share on other sites

This works:)

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://127.0.0.1/test.php", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

; Performing the Request
$oHTTP.Send("var1=&var2=")

; Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
Link to comment
Share on other sites

You may also need to send large data in chunks, and sleep briefly to give the receiver time to catch up. TCP flow control is supposed to do this, but I found threads suggesting that this is necessary, and I did it for my own projects. Also worth considering, I just read a thread that uses PNG as a compression tool, very interesting, and it might have the size of the data you need to send.

Happy coding.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...