Skip to content

Only parse request body as multipart if the request is multipart#256

Merged
rsamoilov merged 1 commit intorage-rb:mainfrom
p8:http-body
Apr 1, 2026
Merged

Only parse request body as multipart if the request is multipart#256
rsamoilov merged 1 commit intorage-rb:mainfrom
p8:http-body

Conversation

@p8
Copy link
Copy Markdown
Contributor

@p8 p8 commented Apr 1, 2026

If a request body is not json, urlencoded or multipart, there is no reason to raise an BadRequest error.

The query and url params should still be returned in this case.

This fixes an issue in the HttpArena benchmark (the successor to TechEmpower), where a plain text body should be read for one of the tests. A plain request body should be added to a sum.

Currently this is handled with a MonkeyPatch:
https://github.com/MDA2AV/HttpArena/blob/main/frameworks/rage/config/application.rb#L28-L35

If a request body is not json, urlencoded or multipart, there is no
reason to raise an BadRequest error.

The query and url params should still be returned in this case.
@p8 p8 changed the title Only parse multipart if request is multipart Only parse request body as multipart if the request is multipart Apr 1, 2026
Copy link
Copy Markdown
Member

@rsamoilov rsamoilov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @p8,

Nice one! Thank you! 💪

I think at some point we'll also need to start gracefully handling the case where content_type is nil, but this change is good to go.

Merging and releasing v1.22.1.

@rsamoilov rsamoilov merged commit 7a14447 into rage-rb:main Apr 1, 2026
12 checks passed
rsamoilov pushed a commit that referenced this pull request Apr 1, 2026
If a request body is not json, urlencoded or multipart, there is no
reason to raise an BadRequest error.

The query and url params should still be returned in this case.
@rsamoilov
Copy link
Copy Markdown
Member

Also, let me know if there's anything I can do to help with the HttpArena benchmark. I'll try to look into it at some point too.

@p8 p8 deleted the http-body branch April 1, 2026 17:00
@p8
Copy link
Copy Markdown
Contributor Author

p8 commented Apr 1, 2026

Thanks @rsamoilov . I'll let you know when I run into issues.

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.

2 participants