aqHttpRequest.SetTimeouts Method

Applies to TestComplete 15.30, last modified on January 20, 2022

Description

Use the SetTimeouts method to specify timeout values for sending HTTP requests and receiving responses from the target server.

Declaration

aqHttpRequest.SetTimeouts(ResolveTimeout, ConnectTimeout, SendTimeout, ReceiveTimeout)

ResolveTimeout [in]    Required    Integer    
ConnectTimeout [in]    Required    Integer    
SendTimeout [in]    Required    Integer    
ReceiveTimeout [in]    Required    Integer    
Result None

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ResolveTimeout

A timeout value for resolving a host name to an IP address, in milliseconds.

ConnectTimeout

A timeout value for connecting to the target server, in milliseconds.

SendTimeout

A timeout value for sending request data to the target server, in milliseconds. If a request is split into multiple packets, the timeout value will be applied to each packet.

ReceiveTimeout

A timeout value for receiving response data from the target server, in milliseconds. If a response is split into multiple packets, the timeout value will be applied to each packet.

Result Value

None.

Remarks

  • If you don't use the SetTimeouts method in your script, the following default timeout values will be used:

    • ResolveTimeout– 0 (an infinite timeout)

    • ConnectTimeout– 60 000 (60 seconds)

    • SendTimeout– 30 000 (30 seconds)

    • ReceiveTimeout– 30 000 (30 seconds)

  • For all parameters, 0 and -1 mean an infinite timeout. Negative values other than -1 fail this method.

Example

The example below demonstrates how you can use the SetTimeouts method to specify timeout values for sending and receiving a GET request that downloads a file from a server.

JavaScript, JScript

function httpRequest()
{
  var address = "https://downloads.smartbear.com/TestComplete1410_Samples.exe";

  // Create an aqHttpRequest object
  var aqHttpRequest = aqHttp.CreateGetRequest(address);
    
  // Specify timeout values (Resolve, Connect, Send, Receive)
  aqHttpRequest.SetTimeouts(30000,60000,30000,70000);
  
  // Send the request, get an aqHttpResponse object
  var aqHttpResponse = aqHttpRequest.Send();
  
  // Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\TestComplete1410_Samples.exe");
}

Python

def httpRequest():
  address = "https://downloads.smartbear.com/TestComplete1410_Samples.exe"

  # Create an aqHttpRequest object
  aqHttpRequest = aqHttp.CreateGetRequest(address)
  
  # Specify timeout values (Resolve, Connect, Send, Receive)
  aqHttpRequest.SetTimeouts(30000,60000,30000,70000)

  # Send the request, get an aqHttpResponse object
  aqHttpResponse = aqHttpRequest.Send()
  
  # Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\TestComplete1410_Samples.exe")

VBScript

Sub httpRequest
  Dim address, aqHttpRequest, aqHttpResponse
  address = "https://downloads.smartbear.com/TestComplete1410_Samples.exe"

  ' Create an aqHttpRequest object
  Set aqHttpRequest = aqHttp.CreateGetRequest(address)
  
  ' Specify timeout values (Resolve, Connect, Send, Receive)
  Call aqHttpRequest.SetTimeouts(30000,60000,30000,70000)

  ' Send the request, get an aqHttpResponse object
  Set aqHttpResponse = aqHttpRequest.Send()
 
  ' Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\TestComplete1410_Samples.exe")
End Sub

DelphiScript

function httpRequest;
var address, aqHttpRequest, aqHttpResponse;
begin
  
  address := 'https://downloads.smartbear.com/TestComplete1410_Samples.exe';

  // Create an aqHttpRequest object
  aqHttpRequest := aqHttp.CreateGetRequest(address);
  
  // Specify timeout values (Resolve, Connect, Send, Receive)
  aqHttpRequest.SetTimeouts(30000,60000,30000,70000);

  // Send the request, get an aqHttpResponse object
  aqHttpResponse := aqHttpRequest.Send();
  
  // Save a response body to a file
  aqHttpResponse.SaveToFile('C:\\Work\\TestComplete1410_Samples.exe');
  
end;

C++Script, C#Script

function httpRequest()
{
  var address = "https://downloads.smartbear.com/TestComplete1410_Samples.exe";

  // Create an aqHttpRequest object
  var aqHttpRequest = aqHttp["CreateGetRequest"](address);
  
  // Specify timeout values (Resolve, Connect, Send, Receive)
  aqHttpRequest["SetTimeouts"](30000,60000,30000,70000);


  // Send the request, get an aqHttpResponse object
  var aqHttpResponse = aqHttpRequest["Send"]();
   
  // Save a response body to a file
  aqHttpResponse["SaveToFile"]("C:\\Work\\TestComplete1410_Samples.exe");
}

See Also

Send Method
SetHeader Method
aqHttpRequest Object
Sending and Receiving HTTP Requests

Highlight search results