k6

A modern load testing tool, using Go and JavaScript

"like unit testing, for performance"

k6 is a modern load testing tool, building on Load Impact's years of experience. It provides a clean, approachable JavaScript scripting API, distributed and cloud execution, and orchestration via a REST API.

Get Started    Documentation

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Response (k6/http)

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.submitForm() not available in an official release yet

As of this writing, Jan 9th 2018, the Response.submitForm() method is not available in an official release. It's only available if building k6 from source or if you're using the latest Docker image tag.

Response.timings.tls_handshaking not available in an official release yet

As of this writing, Jan 11th 2018, the Response.timings.tls_handshaking property is not available in an official release. It's only available if building k6 from source or if you're using the latest Docker image tag.

Name
Type
Description

Response.body

string

HTML body content.

Response.headers

object

Key-value pairs representing all HTTP headers sent by the server.

Response.ocsp.produced_at

number

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)

Response.ocsp.this_update

number

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.

Response.ocsp.next_update

number

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).

Response.ocsp.revocation_reason

string

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,
http.OCSP_REASON_AFFILIATION_CHANGED,
http.OCSP_REASON_SUPERSEDED,
http.OCSP_REASON_CESSATION_OF_OPERATION,
http.OCSP_REASON_CERTIFICATE_HOLD,
http.OCSP_REASON_REMOVE_FROM_CRL,
http.OCSP_REASON_PRIVILEGE_WITHDRAWN or
http.OCSP_REASON_AA_COMPROMISE.

Respons.ocsp.revoked_at

number

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).

Response.ocsp.status

string

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.

Response.proto

string

Protocol used to perform the transfer. Possible values are "HTTP/1.0" or "HTTP/1.1", "h2" for standard HTTP/2 over TLS and "h2c" for unencrypted HTTP/2.

Response.remote_ip

string

The IP address of the server handling the request.

Response.remote_port

number

The port that was connected to on the server side.

Response.status

number

HTTP status code returned by server.

Response.timings

object

Performance timing information for the HTTP request.

Response.timings.blocked

float

Containing time (ms) spent blocked before initiating request.

Response.timings.looking_up

float

Containing time (ms) spent looking up host name in DNS.

Response.timings.connecting

float

Containing time (ms) spent setting up TCP connection to host.

Response.timings.tls_handshaking

float

Containing time (ms) spent handshaking TLS session with host.

Response.timings.sending

float

Containing time (ms) spent sending request.

Response.timings.waiting

float

Containing time (ms) spent waiting for server response (a.k.a. TTFB).

Response.timings.receiving

float

Containing time (ms) spent receiving response data.

Response.timings.duration

float

Containing total time (ms) for request, excluding blocked time.

Response.tls_cipher_suite

string

If a TLS session was established, the cipher suite that was used.

Response.tls_version

string

If a TLS session was established, the version of SSL/TLS that was used.

Response.url

string

The URL that was ultimately fetched (i.e. after any potential redirects).

Response.html()

function

Returns an object that supports Selection.find(selector)

Response.json()

function

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.

function

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.

import {check} from "k6";
import http from "k6/http";


export default function() {
	let res = http.get("https://loadimpact.com");
	for (var p in res.headers) {
		if (res.headers.hasOwnProperty(p)) {
			console.log(p + " : " + res.headers[p]);
		}
	}
  check(res, {
    "status is 200": (r) => r.status === 200,
    "caption is correct": (r) => r.html("h1").text() == "Example Domain",
  })
};

A k6 script that will make an HTTP request and print all HTTP response headers

Response (k6/http)