aqHttpResponse.AllHeaders Property

Applies to TestComplete 14.10, last modified on June 5, 2019

Description

Use the AllHeaders property to get all the headers (with their values) of an HTTP response returned by the aqHttpRequest.Send method.

Note: This property is similar to the getAllResponseHeaders method of the IWinHttpRequest interface.

Declaration

aqHttpResponse.AllHeaders

Read-Only Property String

Applies To

The property is applied to the following object:

Property Value

A string containing all the headers of the response and their values. The name of a header and its value are separated by the colon.

Remarks

  • The value of this property is valid only after successful completion of the Send method call.

  • To get a value of a specific header, use the GetHeader method.

Example

The example below demonstrates how you can use the aqHttp object to create an HTTP GET request and send it to get a response from the server. To work with the created request, the code uses the aqHttpRequest object. To work with the server response, the sample code uses the aqHttpResponse object:

JavaScript, JScript

function httpGetRequest()
{
  var address = "http://now.httpbin.org";

  // Create an aqHttpRequest object
  var aqHttpRequest = aqHttp.CreateGetRequest(address);

  // Send the request, get an aqHttpResponse object
  var aqHttpResponse = aqHttpRequest.Send();
  
  // Read the response data
  Log.Message(aqHttpResponse.AllHeaders); // All headers
  Log.Message(aqHttpResponse.GetHeader("Content-Type")); // A specific header
  Log.Message(aqHttpResponse.StatusCode); // A status code
  Log.Message(aqHttpResponse.StatusText); // A status text
  Log.Message(aqHttpResponse.Text); // A response body
  
  // Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\body.txt");
}

Python

def httpGetRequest():
  address = "http://now.httpbin.org"

  # Create an aqHttpRequest object
  aqHttpRequest = aqHttp.CreateGetRequest(address)

  # Send the request, get an aqHttpResponse object
  aqHttpResponse = aqHttpRequest.Send()
  
  # Read the response data
  Log.Message(aqHttpResponse.AllHeaders) # All headers
  Log.Message(aqHttpResponse.GetHeader("Content-Type")) # A specific header
  Log.Message(aqHttpResponse.StatusCode) # A status code
  Log.Message(aqHttpResponse.StatusText) # A status text
  Log.Message(aqHttpResponse.Text) # A response body
  
  # Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\body.txt")

VBScript

Sub httpGetRequest
  Dim address, aqHttpRequest, aqHttpResponse
  address = "http://now.httpbin.org"

  ' Create an aqHttpRequest object
  Set aqHttpRequest = aqHttp.CreateGetRequest(address)

  ' Send the request, get an aqHttpResponse object
  Set aqHttpResponse = aqHttpRequest.Send()
  
  ' Read the response data
  Log.Message(aqHttpResponse.AllHeaders) ' All headers
  Log.Message(aqHttpResponse.GetHeader("Content-Type")) ' A specific header
  Log.Message(aqHttpResponse.StatusCode) ' A status code
  Log.Message(aqHttpResponse.StatusText) ' A status text
  Log.Message(aqHttpResponse.Text) ' A response body

  ' Save a response body to a file
  aqHttpResponse.SaveToFile("C:\\Work\\body.txt")
End Sub

DelphiScript

function httpGetRequest;
var address, aqHttpRequest, aqHttpResponse;
begin
  
  address := 'http://now.httpbin.org';

  // Create an aqHttpRequest object
  aqHttpRequest := aqHttp.CreateGetRequest(address);

  // Send the request, get an aqHttpResponse object
  aqHttpResponse := aqHttpRequest.Send();
  
  // Read the response data
  Log.Message(aqHttpResponse.AllHeaders); // All headers
  Log.Message(aqHttpResponse.GetHeader('Content-Type')); // A specific header
  Log.Message(aqHttpResponse.StatusCode); // A status code
  Log.Message(aqHttpResponse.StatusText); // A status text
  Log.Message(aqHttpResponse.Text); // A response body

  // Save a response body to a file
  aqHttpResponse.SaveToFile('C:\\Work\\body.txt');
  
end;

C++Script, C#Script

function httpGetRequest()
{
  var address = "http://now.httpbin.org";

  // Create an aqHttpRequest object
  var aqHttpRequest = aqHttp["CreateGetRequest"](address);

  // Send the request, get an aqHttpResponse object
  var aqHttpResponse = aqHttpRequest["Send"]();
  
  // Read the response data
  Log["Message"](aqHttpResponse["AllHeaders"]); // All headers
  Log["Message"](aqHttpResponse["GetHeader"]("Content-Type")); // A specific header
  Log["Message"](aqHttpResponse["StatusCode"]); // A status code
  Log["Message"](aqHttpResponse["StatusText"]); // A status text
  Log["Message"](aqHttpResponse["Text"]); // A response body
  
  // Save a response body to a file
  aqHttpResponse["SaveToFile"]("C:\\Work\\body.txt");
}

See Also

aqHttpResponse.StatusCode Property
aqHttpResponse.StatusText Property
aqHttpResponse.Text Property

Highlight search results