net/http: Request method does not default to GET with http2 #31061
Labels
Milestone
Comments
@chancez You are correct. There is a missing conversion from "" to "GET" when building the headers for http/2. |
Change https://golang.org/cl/169557 mentions this issue: |
gopherbot
pushed a commit
to golang/net
that referenced
this issue
Mar 27, 2019
We document that "" means "GET" for Request.Method. Updates golang/go#31061 Change-Id: I41d0c7361e6ad14e9c04c120aed8a30295b1f974 Reviewed-on: https://go-review.googlesource.com/c/net/+/169557 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Change https://golang.org/cl/174677 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran the following program twice, once with HTTP2 disabled and once with it enabled. The program makes a simple request to google.com with the
http.Request.Method
unset (which should default to GET according to godocs).https://play.golang.org/p/P89q1NGch2a
I saved the file as
request_main.go
and ran it once with:and once with:
What did you expect to see?
With HTTP2 and HTTP1 I expect it to succeed.
What did you see instead?
It only succeeds for HTTP1, returning 200:
For HTTP2 it fails with 405 method not allowed:
But, in other cases with a Go HTTP2 server (Kubernetes, with a less minimal example) returned a protocol error when receiving a similar request ( I have no example for this, but it's likely that the HTTP2 server needs to check for the request method being set, and return 405 instead of a protocol error ).
When I used mitmproxy and wireshark I was able to see the HTTP method header value is indeed, unset when
http.Request.Method
is unset when the client is using HTTP2. In the godoc, it statesFor client requests, an empty string means GET
when referring to theRequest
type:However, based on my testing, this is not happening for http2.
The text was updated successfully, but these errors were encountered: