HTTP Server Tasks - Version 1.8

This document describes the HTTP Server Tasks, provided as custom tasks that must be installed with PureLoad/PureTest on each machine using these tasks.

The HTTP Server Tasks may be used simulate a HTTP (or HTTPS) server. I.e wait for HTTP requests and return HTTP responses using the provided set of tasks.

A server that is started with a known defined listening port will be shared and can be used by several scenarios concurrently. Take note that a shared HTTP server will be closed when the first HttpServerCloseTask is executed. If no HttpServerCloseTask is used, the HTTP server will be automatically stopped when the test is completed. Read more about HTTPS/SSL support.

Before you use the tasks, read more about installing and how to load and use custom tasks.

Provided tasks



HttpServerInitTask

Task used to to initiate and start HTTP and/or HTTPS Server, used by HTTP Server tasks following this task. A server that is started with a known defined listening port can be shared and used by several scenarios concurrently. If listening port is set to 0, the system will choose a port and the actual port is stored in a variable so that the server can be contacted from within the scenario.

HTTPS/SSL is supported. Read more about HTTPS/SSL support

Parameters

Host Used to bind the server to a specified local host IP address. If not specified the default local IP address is used.
HTTP Port Used to bind the server to a specified local port(s). If set to 0 the system will pick up an ephemeral port. Set to -1 to not listen on any HTTP port. The variable specified using parameter "Save HTTP port variable" is assigned to the port used.
HTTPS Port Used to bind the server to a specified local port(s). If set to 0 the system will pick up an ephemeral port. Set to -1 to not listen on any HTTPS port. The variable specified using parameter "Save HTTPS port variable" is assigned to the port used.
SSL Keystore Path Path to keystore (leave blank to use a selfsigned dummy certificate)
SSL Keystore Type Keystore type (JKS or PKCS12)
SSL Keystore Password Keystore password
SSL Key Password Key (private) password
SSL Protocol SSL Protocol to be used (SSL, SSLv3, TLS or TLSv1)
Save HTTP port variable Save allocated HTTP server port using specified variable name.
Save HTTPS port variable Save allocated HTTPS/SSL server port using specified variable name.
Request Timeout Timeout in milliseconds for incoming requests.


HttpServerCloseTask

Task used to to stop an HTTP Server.



HttpServerWaitTask

Task used to to wait for a specified HTTP request. The task blocks until an HTTP request with the specified method and/or URL and/or content is received or timeout. Should be followed by an HttpServerResponseTask to send a response.

Parameters

Wait for Request Method Wait for specified method (GET, POST, PUT, etc). If none specified any method will match.
Wait for Request URI Wait for specified request URI (path specified using regular expression). Examples:
  • .* - accept any request
  • /foo - accept request with URI /foo
Wait for Content Wait for specified request body content pattern (regular expression)
Fail if Match Fail if we receive a matching request (task timeout will be ignored if selected).


HttpServerRequestVerifyTask

Task used to verify a received HTTP request. The task must be used after receiving a request using an HttpServerWaitTask.

Parameters

Expected URL Path Regular expression to match the received URL path. Leave empty to ignore.
Expected Headers List of expected headers, specified using Name and Value. Value can be empty (match any value) or contain an regular expression.
Verify Header Order Select to verify that the order of received headers are the same as listed for Expected Headers.
Verify Headers Exact Select to verify that te received headers are exactly the same as listed for Expected Headers. I.e headers received not listed as Expected Headers will give an error.


HttpServerResponseTask

Task used to to return a specified HTTP response. Must be preceded by an HttpServerWaitTask.

Parameters

Content Type Response Content Type.
Content Type Response Content Type.
Content File Path Response content file path (optional). Path to file to be returned as body of the response.
Content Response Content Body (used if no Content File Path specified).
Response Code HTTP Response status code for response to be sent.
Response Headers HTTP Response headers to be included in response (in addition to Content-Type).


HttpServerPublishTask

Task used to publish static content to be returned for matching HTTP requests.

Parameters

Wait for Request Method Wait for specified method (GET, POST, PUT, etc). If none specified any method will match.
Wait for Request URI Wait for specified request URI (path specified using regular expression). Examples:
  • .* - accept any request
  • /foo - accept request with URI /foo
Wait for Content Wait for specified request body content pattern (regular expression)
Content Type Response Content Type.
Content Type Response Content Type.
Content File Path Response content file path (optional). Path to file to be returned as body of the response.
Content Response Content Body (used if no Content File Path specified).
Response Code HTTP Response status code for response to be sent.
Response Headers HTTP Response headers to be included in response (in addition to Content-Type).