HTTP Checks
Checks specific to HTTP requests
HTTP Specific Check Type
The HTTP Check implementation provides the following built-ins:
HTTP status
status
Targets the HTTP response status code.
.check(
status().saveAs("status")
)
.check(
status().saveAs("status")
)
.check(
status().saveAs("status")
)
.check(
status.saveAs("status")
)
Page location
currentLocation
Targets the current page absolute URL. Useful when following redirects in order to check if the landing page is indeed the expected one.
.check(
currentLocation().saveAs("url")
)
.check(
currentLocation().saveAs("url")
)
.check(
currentLocation().saveAs("url")
)
.check(
currentLocation.saveAs("url")
)
currentLocationRegex
A version of currentLocation that applies a Java Regular Expression to capture some information out of it, like in the generic regex.
It takes one single parameter:
pattern
can be a plainString
, a Gatling Expression LanguageString
or a function.
.check(
// single capture group
currentLocationRegex("https://(.*)/.*")
.saveAs("domain"),
// multiple capture groups with "captureGroups"
currentLocationRegex("http://foo.com/bar?(.*)=(.*)")
.captureGroups(2)
.saveAs("queryParamKeyAndValue")
)
.check(
// single capture group
currentLocationRegex("https://(.*)/.*")
.saveAs("domain"),
// multiple capture groups with "captureGroups"
currentLocationRegex("http://foo.com/bar?(.*)=(.*)")
.captureGroups(2)
.saveAs("queryParamKeyAndValue")
)
.check(
// single capture group
currentLocationRegex("https://(.*)/.*")
.saveAs("domain"),
// multiple capture groups with "captureGroups"
currentLocationRegex("http://foo.com/bar?(.*)=(.*)")
.captureGroups(2)
.saveAs("queryParamKeyAndValue")
)
.check(
// single capture group
currentLocationRegex("https://(.*)/.*")
.saveAs("domain"),
// multiple capture groups with "captureGroups"
currentLocationRegex("http://foo.com/bar?(.*)=(.*)")
.ofType[(String, String)]
.saveAs("queryParamKeyAndValue")
)
HTTP header
header
It takes one single parameter:
headerName
can be a plainString
, a Gatling Expression LanguageString
or a function.
.check(
header("Content-Encoding").is("gzip")
)
.check(
header("Content-Encoding").is("gzip")
)
.check(
header("Content-Encoding").shouldBe("gzip")
)
.check(
header("Content-Encoding").is("gzip")
)
headerRegex
A version of header that applies a Java Regular Expression to capture some information out of it, like in the generic regex.
It takes two parameters:
headerName
can be a plainString
, a Gatling Expression LanguageString
or a function.pattern
can be a plainString
, a Gatling Expression LanguageString
or a function.
.check(
headerRegex("FOO", "foo(.*)bar(.*)baz")
.captureGroups(2)
.saveAs("data")
)
.check(
headerRegex("FOO", "foo(.*)bar(.*)baz")
.captureGroups(2)
.saveAs("data")
)
.check(
headerRegex("FOO", "foo(.*)bar(.*)baz")
.captureGroups(2)
.saveAs("data")
)
.check(
headerRegex("FOO", "foo(.*)bar(.*)baz")
.ofType[(String, String)]
.saveAs("data")
)