net/http: Request method does not default to GET with http2 #31061
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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: