Skip to content

Read the query string of a POST request - #149

Open
adityawrk wants to merge 2 commits into
ruby:masterfrom
adityawrk:fix/post-query-string
Open

adityawrk wants to merge 2 commits into
ruby:masterfrom
adityawrk:fix/post-query-string

Conversation

@adityawrk

@adityawrk adityawrk commented Nov 29, 2026 •

Copy link
Copy Markdown

Fixes #57.

initialize_query read QUERY_STRING only for GET and HEAD. A POST used the body alone, so POST /path?q=2 with body body=1 produced params of {"body" => ["1"]} and cgi["q"] of "".

The query string is now parsed for POST as well, including a multipart body. When a name is in both places, the body value stays first, so cgi[key] is unchanged for that name.

Before the change, that request had cgi["q"] == "". After it, cgi["q"] is "2" and cgi.params["body"] is ["1", "from-query"] when the query also sends body.

ruby -Ilib test/cgi/test_cgi_core.rb: 12 tests, 95 assertions, 0 failures.

Parameters in the query string of a POST were dropped. The body was
the only source.
POST parameters came only from the body, so a query string on a POST
was ignored. It is now included. A name that is in both places keeps
the body value first.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to read query params in a POST method

1 participant