k6/http module provides functionality for making HTTP requests.
Functions
get(url, [params])
Makes an HTTP GET request.string
Target URL
object
Request parameters (headers, tags, etc.)
Response
HTTP response object
post(url, [body], [params])
Makes an HTTP POST request.string
Target URL
string | object | ArrayBuffer
Request body
object
Request parameters
put(url, [body], [params])
Makes an HTTP PUT request.string
Target URL
string | object | ArrayBuffer
Request body
object
Request parameters
patch(url, [body], [params])
Makes an HTTP PATCH request.del(url, [body], [params])
Makes an HTTP DELETE request.head(url, [params])
Makes an HTTP HEAD request.options(url, [body], [params])
Makes an HTTP OPTIONS request.request(method, url, [body], [params])
Makes an HTTP request with the specified method.string
HTTP method (GET, POST, etc.)
string
Target URL
string | object | ArrayBuffer
Request body
object
Request parameters
batch(requests)
Makes multiple HTTP requests in parallel.array | object
Array or object containing request definitions
file(data, [filename], [contentType])
Creates a file object for multipart requests.string | ArrayBuffer
File content
string
Filename
string
Content type
Classes
CookieJar
Manages HTTP cookies.Response Object
HTTP response objects contain:number
HTTP status code
string
Response body as string
object
Response headers
object
Response timing information
function
Parse response body as JSON
Constants
TLS Versions
http.TLS_1_0http.TLS_1_1http.TLS_1_2http.TLS_1_3
OCSP Status
http.OCSP_STATUS_GOODhttp.OCSP_STATUS_REVOKEDhttp.OCSP_STATUS_UNKNOWNhttp.OCSP_STATUS_SERVER_FAILED