h2non/gentleman

http/1.1 and http/2

eraserx99 opened this issue · 1 comments

Supposedly, the newer version GO (I'm using GO 1.14.9) would use http/2 with TLS by default on the client-side when the server-side supports http/2. I expect to see HTTP/2 getting logged on the server-side when I use the following code (gentleman.V2 2.0.4)

cli := gentleman.New()
cli.URL("https://mytestserver.com")
cli.Request().Send()

However, I got this logged on the server-side,

[12/Oct/2020:15:43:03 +0000] "GET / HTTP/1.1" 200 14195 "-" "gentleman/2.0.4"

If I do this,

cli := gentleman.New()
cli.Use(transport.Set(http.DefaultTransport))
cli.URL("https://mytestserver.com")
cli.Request().Send()

I got this logged on the server-side,

[12/Oct/2020:15:58:12 +0000] "GET / HTTP/2.0" 200 14175 "-" "gentleman/2.0.4"

Of course, a simple call from the http package like below also got HTTP/2.0 logged on the server-side,

http.Get("https://mytestserver.com")

I've not found the gentleman documentation about this behavior (probably, I'm not thorough enough).

Any comments?

h2non commented

It looks like in recent go versions, you can explicitly force http/2 by defining the ForceAttemptHTTP2 field as true:
https://golang.org/pkg/net/http/#Transport.ForceAttemptHTTP2

We should mimic the http.Transport default behavior in recent go versions.