Close menu
Open menu

HTTP Client Manager



This Manager provides a variety of common HTTP client operations you can use in your tests. For example, you can use this Manager in a test where you want to determine if a particular web page contains (or does not contain) some specific content. This is exactly how it is used in the Docker Manager IVT (Installation Verification Test). As well as providing client functionality to people who write tests, it may also be used internally by other Managers to enrich their range of offered services. This Manager supports outbound HTTP calls, JSON requests, HTTP file transfer and Web Services calls. SSL is supported. You can view the Javadoc documentation for the Manager here.

Code snippets

Use the following code snippets to help you get started with the HTTP Client Manager.

Instantiate an HTTP Client

This code instantiates an HTTP Client.

public IHttpClient client;

You can just as simply instantiate multiple HTTP Clients.

public IHttpClient client1;

public IHttpClient client2;
Set the target URI for an HTTP Client

This code sets an HTTP Client's target URI.

public IHttpClient client;


You would typically use this call prior to, say, an outbound HTTP call to retrieve the contents of a web page.

Make an outbound HTTP call

This code makes a get request to the given path.

client.setURI(new URI(""));
String pageContent = client.getText("/get").getContent();

These two lines use the HTTPClient to perform a GET request against the URL The getText method is used as we want to retrieve the response as a string. Alternatives for XML, JSON and JAXB objects exist. There are also methods for the other HTTP verbs such as PUT, POST and DELETE

Use streams to download a file The following code is an example of one way to download a file using streams.
public IHttpClient client;

File f = new File("/tmp/dev.galasa_0.7.0.jar");

client.setURI(new URI(""));
CloseableHttpResponse response = client.getFile("/plugins/dev.galasa_0.7.0.jar");
InputStream in = response.getEntity().getContent();
OutputStream out = new FileOutputStream(f);
int count;
byte data[] = new byte[2048];
while((count = != -1) {
   out.write(data, 0, count);

The snippet begins by declaring client as before and f, an instance of File. The client's URI is set and its getFile method called to return response - an instance of CloseableHttpResponse.

The two streams in and out are declared and initialized and the data transferred from in to out in 2048 byte chunks, after which the output stream is flushed and then closed.