You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
r.Method is overridden to GETbeforer.ParseForm() which causes ParseForm to skip parsing the request body and goes straight to parsing from the query string parameters. Since the whole point of using X-HTTP-Method-Override is to move the query string parameters to the request body, no query string parameters are present in the URL
One possible solution is to move r.Method = strings.ToUpper(override)after the r.ParseForm() block.
To Reproduce
Send a POST request to a GET endpoint with Content-Type: application/x-www-form-urlencoded and X-HTTP-Method-Override: GET headers. Set the request body with what would be query string parameters e.g. limit=15&page=1
Expected behavior
Form parameters are parsed and passed along to the API handler
Actual Behavior
Form parameters are not parsed and none of the parameters are populated when reaching the API handler
Your Environment
(no info)
The text was updated successfully, but these errors were encountered:
Hi, thanks for the detailed issue! The problem as you describe it seems indeed to be that we're mutating the request before parsing. Would you be willing to contribute a PR with a fix and a test confirming the fix?
🐛 Bug Report
There is a bug around this code:
grpc-gateway/runtime/mux.go
Lines 324 to 330 in 1c444cc
r.Method
is overridden toGET
beforer.ParseForm()
which causesParseForm
to skip parsing the request body and goes straight to parsing from the query string parameters. Since the whole point of usingX-HTTP-Method-Override
is to move the query string parameters to the request body, no query string parameters are present in the URLOne possible solution is to move
r.Method = strings.ToUpper(override)
after ther.ParseForm()
block.To Reproduce
Send a
POST
request to aGET
endpoint withContent-Type: application/x-www-form-urlencoded
andX-HTTP-Method-Override: GET
headers. Set the request body with what would be query string parameters e.g.limit=15&page=1
Expected behavior
Form parameters are parsed and passed along to the API handler
Actual Behavior
Form parameters are not parsed and none of the parameters are populated when reaching the API handler
Your Environment
(no info)
The text was updated successfully, but these errors were encountered: