Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http/1.1 and http/2 #58

Open
eraserx99 opened this issue Oct 12, 2020 · 1 comment
Open

http/1.1 and http/2 #58

eraserx99 opened this issue Oct 12, 2020 · 1 comment

Comments

@eraserx99
Copy link

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
Copy link
Owner

h2non commented Oct 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants