Response is used by the http.* methods that generate HTTP request. Those methods return one (or more, in the case of http.batch()) Response objects that contain HTTP response contents and performance timing measurements.
Note that in the case of redirects, all the information in the Response object will pertain to the last request (the one that doesn't get redirected).
|Response body content, often used to extract dynamic data (see examples here) and when verifying the presence of content using checks.
See Params.responseType and options.discardResponseBodies for how to discard the body when it is not needed (and to save memory) or when handling bodies with binary data.
|Response cookies. The object properties are the cookie names and the value is an array of cookie objects (with name, value, domain, path, httpOnly, secure, maxAge and expires fields).
|Error message if there was a non-HTTP error while trying to send the request.
|Error code if there was a non-HTTP error or 4xx or 5xx HTTP error it will be set to a specific code that describes the error. (Added in 0.24.0)
|Key-value pairs representing all HTTP headers sent by the server. Note that the header names are in canonical form, i.e.: if the server responds with "accept-encoding", the key will be "Accept-Encoding".
|If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this OCSP stapled response was signed by CA (or by CA entrusted OCSP responder)
|If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time at which the status being indicated was known to be correct.
|If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this OCSP stapled response will be refreshed with CA (or by CA entrusted OCSP responder).
|The reason for revocation of the certificate (if that is the status), one of the following constants: http.OCSP_REASON_UNSPECIFIED, http.OCSP_REASON_KEY_COMPROMISE, http.OCSP_REASON_CA_COMPROMISE,
|If a stapled OSCP response was provided by server, the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC, representing the time when this certificate was revoked (if that is the status).
|The status of the certificate, one of the following constants: http.OCSP_STATUS_GOOD, http.OCSP_STATUS_REVOKED, http.OCSP_STATUS_UNKNOWN or http.OCSP_STATUS_SERVER_FAILED.
|Protocol used to perform the transfer. Possible values are "HTTP/1.0", "HTTP/1.1", or "HTTP/2.0".
|The IP address of the server handling the request.
|The port that was connected to on the server side.
|Request body content.
|Request cookies. The object properties are the cookie names and the value is an array of cookie objects (with name, value and replace fields).
|Request HTTP method.
|HTTP status code returned by the server.
|(new in k6 v0.29.0) HTTP status text returned by the server.
|Performance timing information for the HTTP request.
|Containing time (ms) spent blocked before initiating request.
|Containing time (ms) spent setting up TCP connection to host.
|Containing time (ms) spent handshaking TLS session with host.
|Containing time (ms) spent sending request.
|Containing time (ms) spent waiting for server response.
|Containing time (ms) spent receiving response data.
|Total time for the request (ms). It's equal to sending + waiting + receiving, i.e. how long did the remote server take to process the request and respond, without the initial DNS lookup/connection times.
|If a TLS session was established, the cipher suite that was used.
|If a TLS session was established, the version of SSL/TLS that was used.
|The URL that was ultimately fetched (i.e. after any potential redirects).
|Response.clickLink( [params] )
|Parses response as HTML, looks for a specific link and does the request-level equivalent of a click on that link.
|Returns an object that supports Selection.find(selector).
|Response.json( [selector] )
|Parses the response body data as JSON and returns a JS object or array. This call caches the deserialized JSON data, additional calls will return the cached data. An optional selector can be specified to extract a specific part of the data, see here for selector syntax.
|Response.submitForm( [params] )
|Parses response as HTML, parses the specified form (defaults to looking for a "form" element) with option to override fields and then submits form taking form's method and action into account.
A k6 script that will make an HTTP request and print all HTTP response headers