Can I make an HTTP request that uses only HTTP / 2

I am working on some scenarios to test our infrastructure at different levels. I am trying to run tests to test functionality for clients with and without http2. The docs say how to disable http2 by overriding Transport.TLSNextProto, but I cannot find a way to require http2.

Is there a way for an HTTP request to use only http / 2? Or, if not, is there any field or hook to see if he used http2 or not?

+6
source share
1 answer

You can use Response.ProtoAtLeast(2, 0)to check if it is in version 2. See: https://golang.org/pkg/net/http/#Response.ProtoAtLeast

+2
source

Source: https://habr.com/ru/post/1017068/


All Articles