Header step

Header step is a way to inspect HTTP headers in a generic way.

Syntax

  • Header statement is only valid where response is the context
  • The header name is case-insensitive, as the HTTP header fields are

Usage

Check that header exists on the response

With Link "author" {
    Expect Header ETag
}

Test header value

To check that a header contains a specific value it is possible to do an exact comparison or regular expression matching.

With Link "author" {
    // exact match
    Expect Header Content-Type "application/problem+json"

    // regular expression match
    Expect Header Location Matching "^http://expected.url/"
}

The regular expression itself is not parsed as the exact implementation would depend on the test runner and its platform.

Capture header value

It is also possible to create a "variable" containing the header's value, so that it can be used in subsequent steps.

With Link "author" {
    Expect Header Content-Location [uri]
}
Last Updated: 7/14/2019, 7:33:32 PM