Protocols

HTTP

Plugin definition

The http-plugin object represents the plugin_info in a plugin object.

Name Type Required Action Info
servers list of server objects Yes No Servers list; allows IP load balancing.
timeout integer No No Timeout in milliseconds; defaults to 30000;
connect_timeout integer No No Connection timeout in milliseconds; defaults to 15000;
stats_per_url boolean No No Generates stats per URL.

The server object represents the server information.

Name Type Required Action Info
host string Yes No IPv4 or IPv6 address of the HTTP server.
port integer Yes No Port number of the HTTP server of the SUT.
ssl boolean Yes No Sets SSL connection.

The plugin does a round robin between servers to establish connections. Statistics are retrieved per IP. host accepts the following address representations for IPv4:

  • Dotted decimal: 192.0.2.235
  • Dotted hexadecimal: 0xC0.0x00.0x02.0xEB
  • Hexadecimal: 0xC00002EB
  • Decimal: 3221226219

It accepts the following representations for IPv6:

  • Full address: 2001:0db8:0000:0000:0000:ff00:0042:8329
  • Shortened address, without leading zeroes: 2001:db8:0:0:0:ff00:42:8329
  • Shortened address, without consecutive sections of zeroes: 2001:db8::ff00:42:8329

Example

{"http-plugin" : {"servers" : [{"host" : "192.165.0.1",
                                "port" : 5050,
                                "ssl" : false}
                              ],
                  "stats_per_url" : true
                 }
}

HTTP request

The http-request object performs an HTTP request.

Name Type Required Action Info
plugin_id string Yes No Plugin ID. Must belong to one of the plugins declared in the specification.
method string Yes No Valid HTTP method: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
path string Yes Yes URI of the request as defined in http://tools.ietf.org/html/rfc2616#section-5.1.2. Can be the result of an action.
headers object No No JSON object which represents the header list. Each member is a header pair. { header-name : header-value }
body string or list of strings No Yes String or list of strings which are appended to build the body. Can be replaced for the result of an action.
group string No No Group label used in reporting. For example: response times per group of requests or successful/failed requests per group.
assert_status string No No Asserts HTTP response status code is that specified. Determines whether a request is successful.
assert_body object No Yes Asserts that the body of the response matches the specification provided here. Determines whether a request is successful.

If the evaluation of path or body fails before the request is sent, the request is considered invalid and the scenario aborted.

Response asserted in assert_body is of the form:

{
      "body" : <BODY>,
      "status" : <STATUS>,
      "reason" : <REASON>,
      "headers" : <HEADERS>
}

Example

{"http-request" : {
                    "plugin_id" : "my_web_server",
                    "method" : "POST",
                    "path" : "/charges",
                    "headers" : {“Content-Type” : “application/json”},
                    "body" : "{ \"id\": \"cu_228rD6XZsvYmuc\"}",
                    "assert_status" : "200",
                    "assert_body" :
                      {"jsonpath-value" :
                        {"path" : "body.count",
                          "value" : 5}}
                  }
}

Assuming the body of the response is something like:

{"count" : 2,
 "data" : [ { "id" : "d98fn357fn23",
              "amount" : 6324,
              "currency" : "gbp" },
            { "id" : "d98fn3qwrqr1",
              "amount" : 50,
              "currency" : "gbp" }
          ]
}

the request would be counted as failed as the value for count is 2 and not 5.

The HTTP client redirects all requests that MUST be redirected following: http://tools.ietf.org/html/rfc2616#section-10.3. Those redirects are included in the statistics and any other redirection should be handled from the test specification.

HTTP requests return a JSON object, which can be queried with the JSON actions. The following table shows the format of the HTTP response:

The http-response object contains the following:

Name Type Info
status string Status code, represented as a string. See http://tools.ietf.org/html/rfc2616#section-6.1.1.
reason string Reason phrase. See http://tools.ietf.org/html/rfc2616#section-6.1.1.
headers list of objects Response headers as a list of objects. Header name is always lowercase.
body string Response body.

Example

{
  "status" : "200",
  "reason" : "OK",
  "headers" : [{"Content-Type" : "application/json"}], 
  "body" : "{\"customer\" : { \"active_card\" : {\"type\" : \"Visa\",
                                                 \"exp_month\" : 6},
                              \"email\" : \"me@me.com\"
                             }
            }”
}