HTTPTimeout()

Syntax

HTTPTimeout(ConnectTimeout [, GlobalTimeout])
Description
Specify timeout to use for the following HTTP commands: ReceiveHTTPFile(), ReceiveHTTPMemory(), HTTPRequest() and HTTPRequestMemory().

Parameters

ConnectTimeout The timeout, in milliseconds, to abort the HTTP request if the remote host doesn't connect. The default timeout is set to 30 seconds. #PB_Default can be used to revert to the default timeout value (30 seconds).
GlobalTimeout (optional) The global timeout, in milliseconds, to abort the HTTP request if it is still not finished. There is no timeout by default. #PB_Default can be used to revert to the default behaviour (no timeout). Note: if a connection is slow, it could abort a valid unfinished request.

Return value

None.

Remarks

If "Create thread-safe executable" is enabled in the compiler options then every thread has its own timeouts, which means two threads can have different timeouts at the same time.

Example

  HTTPTimeout(5000) ; Allows 5 secs to connect to the server

  HttpRequest = HTTPRequest(#PB_HTTP_Get, "https://www.google.com")
  If HttpRequest
    Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
    Debug "Response: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
    
    FinishHTTP(HTTPRequest)
  Else
    Debug "Request creation failed"
  EndIf

See Also

ReceiveHTTPFile(), ReceiveHTTPMemory(), HTTPRequest(), HTTPRequestMemory()

Supported OS

All

<- HTTPRequestMemory() - Http Index - ReceiveHTTPFile() ->