This is a narrowed-down PR based on the work I did in #180, focusing on the bug fix only, and leaving the refactoring work to be addressed in a separate follow-up PR.
This PR resolves #179. Now, when a BodyParser middleware is loaded, and the request’s content type does not match any of the loaded parser, it does not attempt to parse and symbolize the body. This ensures there will be no unexpected content in the resulting request env hash.
To make this concrete, given a BodyParser loaded, with :json as its only configured content type, when an ordinary x-www-form-urlencoded request comes through, it's body will not be parsed, allowing Rack to parse it properly later on. This means we end up with params like this:
{:hanami => "ok"}
And not like this:
{:hanami => "ok", :_ => "hamami=ok"}
More details of the bug this fixes are in #179.
@jodosha Hopefully this is focused enough for you to review and merge? Once this is merged I'll follow up with the refactoring PR.
This is a narrowed-down PR based on the work I did in #180, focusing on the bug fix only, and leaving the refactoring work to be addressed in a separate follow-up PR.
This PR resolves #179. Now, when a
BodyParser
middleware is loaded, and the request’s content type does not match any of the loaded parser, it does not attempt to parse and symbolize the body. This ensures there will be no unexpected content in the resulting request env hash.To make this concrete, given a
BodyParser
loaded, with:json
as its only configured content type, when an ordinary x-www-form-urlencoded request comes through, it's body will not be parsed, allowing Rack to parse it properly later on. This means we end up with params like this:And not like this:
More details of the bug this fixes are in #179.
@jodosha Hopefully this is focused enough for you to review and merge? Once this is merged I'll follow up with the refactoring PR.
Fixes https://github.com/hanami/router/issues/179