http
— make HTTP requests
The http
check makes an HTTP request, and asserts that the response received has the expected properties.
Examples
Check that a server returns HTML:
[[http]] url = 'https://rfcs.io/' status = 200 content_type = 'HTML'
Check that a server supports gzip:
[[http]] url = 'https://rfcs.io/' status = 200 encoding = 'gzip'
Check that HTTP redirects to HTTPS:
[[http]] url = 'http://rfcs.io/' redirect_to = 'https://rfcs.io/'
Check the Server header:
[[http]] url = 'https://rfcs.io/' server = 'nginx (version hidden)'
Send extra headers:
[[http]] url = 'https://example.com/secret' [[http.request.headers]] Authorization = 'Basic d2hhdCBkaWQ6eW91IGV4cGVjdD8='
List of parameters
parameter | structure | description |
---|---|---|
body | content | The content that the request body should have. |
content_type | string | The Content-Type header expected in the response. |
encoding | string | The Content-Encoding header expected in the response. This also gets sent in the Accept-Encoding header of the request. |
headers | table | A mapping of HTTP headers that should exist on the response. |
redirect_to | string | The URL to redirect to, if the response has a redirect HTTP status. |
server | string | The Server header expected in the response. |
url | string | The URL that is being tested. |
List of Content-Type shorthands
Specsheet accepts shorthand versions of many common Content-Type
values.
Here’s the full list:
ATOM | application/atom+xml |
CSS | text/css |
EOT | application/vnd.ms-fontobject |
FLIF | image/flif |
GIF | image/gif |
HTML | text/html |
ICO | image/x-icon |
JPEG | image/jpeg |
JS | text/javascript |
JSON | application/json |
OTF | font/opentype |
PDF | application/pdf |
PNG | image/png |
SVG | image/svg+xml |
TTF | font/ttf |
WEBP | image/webp |
WOFF | application/font-woff |
WOFF2 | font/woff2 |
XML | text/xml |
ZIP | application/zip |