Jump to content

Recommended Posts

Hi all,

I tried a lot to solve the following problem:

In the script below, sometimes I get an error on the line lf send($data). This is because the data size may be  large with relative to the internet speed or because of interrupted internet connection. This lead to an error that will crash the running of program. Any solution to avoid this error??



Global Const $HTTP_STATUS_OK = 200

Func HttpPost($sURL, $sData = "")
Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")

$oHTTP.Open("POST", $sURL, False)
If (@error) Then Return SetError(1, 0, 0)

$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

If (@error) Then Return SetError(2, 0, 0)

If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0)

Return SetError(0, 0, $oHTTP.ResponseText)
Link to post
Share on other sites


You might want to set the default timeouts higher...

$oHttp.SetTimeouts('5000', '5000', '5000', '5000'); <-- milliseconds


Here is the main page for the http object:


Also, I noticed there is no size for the post in the header...

$oHttp.SetRequestHeader('Content-Length', $nValue)


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...