gohttp2

How do I make a HTTP2-only request over http:// in Go?


I'm using Go 1.6 and want to make a HTTP2-only request over http://.

Attempting to do this currently results in:

Head http://localhost:2076/completed/764c1b6bc55548707507a2dd25570483a7216bf4: http2: unsupported scheme

To force http2, I believe I need http.Client.Transport.TLSConfig.NextProtos set to []string{"h2"}.

What else is required?


Solution

  • You need to use https, not http. The http2 transport doesn't recognize the http scheme.