Unable to check for h2c - HTTP/2 clear text protocol


resp.proto can never be checked with h2 or h2c. It can only be checked against HTTP/2.0 or HTTP/1.1, but what do I for HTTP/2 without TLS encryption?

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

export default function() {
  let res = http.get("https://www.bbc.co.uk/");
  check(res, {
    "protocol is HTTP/2": (r) => r.proto === 'h2'

For example, this is what you have in your documentation. The check actually fails because it cannot be compared with h2. However, it works if you change this to HTTP/2.0. It would be great if you give me a solution for HTTP/2.0 with clear text.


HTTP/2.0 automatic upgrade

I’m very sorry, it seems like the documentation was wrong and very misleading. Unfortunately, k6 currently doesn’t have support for making h2c requests. I’m not sure why the docs claimed otherwise, since as far as I can see, we’ve never supported them :confused:

I corrected the http.Response and http2 pages in the docs, and I’ve created a new GitHub issue for adding h2c support in k6: https://github.com/loadimpact/k6/issues/970

Please, give it a :+1:, and again, sorry for misleading you with the wrong documentation.



Oh okay! Thanks for the update. Hoping for the issue to be fixed soon.