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

parameterstructuredescription
bodycontentThe content that the request body should have.
content_typestringThe Content-Type header expected in the response.
encodingstringThe Content-Encoding header expected in the response. This also gets sent in the Accept-Encoding header of the request.
headerstableA mapping of HTTP headers that should exist on the response
redirect_tostringThe URL to redirect to, if the response has a redirect HTTP status.
serverstringThe Server header expected in the response.
urlstringThe 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:

ATOMapplication/atom+xml
CSStext/css
EOTapplication/vnd.ms-fontobject
FLIFimage/flif
GIFimage/gif
HTMLtext/html
ICOimage/x-icon
JPEGimage/jpeg
JStext/javascript
JSONapplication/json
OTFfont/opentype
PDFapplication/pdf
PNGimage/png
SVGimage/svg+xml
TTFfont/ttf
WEBPimage/webp
WOFFapplication/font-woff
WOFF2font/woff2
XMLtext/xml
ZIPapplication/zip