How to specify the ":authority" header in HTTP2 requests?

I would like to specify the pseudo-header “:authority” that is used in HTTP2.
How is this possible?

Normally, the URI like “https://my-authority/my-path” is split into
“:authority” : “my-authority”
“:path” : “my-path”
“:method” : “POST”

However, my receiving side has problems doing the split correctly, so it would be very good if I could specify the “:authority” header myself.

Hi @ChristianS,

It seems like this isn’t support by golang and k6 is written in golang, so this seems unlikely to be fixed, before it is fixed upstream. But it should be w/e the header Host is, so if you set it manually it should be the same :thinking:.

Maybe this is due to an old golang issue and we not updating a dependency - you should try using the current master, best done through using the docker master label and check if that fixes w/e isn’t working for you.

Hi @mstoykov,

I came here accross searching help about this issue. I was reviewing latest changes in k6 for GRPC protocol, and now it seems posible to use the method WithAuthority(), but unfortunately I was not able to create a GRPC request adding this header.

I was thinking this could be done using the jslib API, but I have not found nothing about the new “lib/netext/grpcext” packet.

Could you please help us with this issue?


Hi @ivanape, welcome to the communityu forum :tada: !

The latest changes lets extensions use DialOptions while moving the not js parts out of the js code. AFAIK there is no new functionality exposed through the jslib API.

As far as I can see the :authority header will be set to whatever is the hostname of the server you are connecting to - is that not okay? You can try to hack around this through the usage of hosts by setting the the hostname you want to point to the IP of your server.

Hope this helps and please open new topics instead of writing in year old ones as I would’ve probably missed that

1 Like

Thank you @mstoykov. I was able to connect usigin following naming.