Treat iolist of empty binaries as empty body - #750
Closed
pvsr wants to merge 1 commit into
Closed
Conversation
pvsr
marked this pull request as draft
January 22, 2025 05:24
pvsr
force-pushed
the
empty-req-body-detection
branch
2 times, most recently
from
January 22, 2025 05:29
37cef62 to
87f0d7e
Compare
pvsr
commented
Jan 22, 2025
| S = hackney_headers_new:get_value(<<"content-length">>, Headers), | ||
| {S, CT, Body0}; | ||
|
|
||
| _ when is_list(Body0) -> % iolist case |
Author
There was a problem hiding this comment.
This case is now handled before calling handle_body.
pvsr
marked this pull request as ready for review
January 22, 2025 05:31
pvsr
force-pushed
the
empty-req-body-detection
branch
2 times, most recently
from
October 27, 2025 05:29
1e85121 to
6e5534c
Compare
Author
|
I rebased and added some integration tests. |
pvsr
force-pushed
the
empty-req-body-detection
branch
from
October 27, 2025 05:32
6e5534c to
3580e75
Compare
benoitc
reviewed
Oct 27, 2025
| {Headers2, ReqType0, Body0, Client0}; | ||
| [] -> | ||
| {Headers2, ReqType0, Body0, Client0}; | ||
| _ when is_list(Body0) -> |
Owner
There was a problem hiding this comment.
since we don't anything specif for iolist why not doing it at first level and then check for empty or not body ?
Author
There was a problem hiding this comment.
Good point! I was trying to keep my changes isolated but that's a better way of doing it. Just pushed a new version.
pvsr
force-pushed
the
empty-req-body-detection
branch
3 times, most recently
from
October 27, 2025 21:52
72a51a9 to
011f3e8
Compare
pvsr
force-pushed
the
empty-req-body-detection
branch
from
October 27, 2025 22:00
011f3e8 to
1a118bf
Compare
Fixes non-POST/PUT requests with a body of [<<>>] receiving Content-Type and Content-Length headers despite not having a body.
pvsr
force-pushed
the
empty-req-body-detection
branch
from
October 27, 2025 22:05
1a118bf to
6ff6aba
Compare
Owner
|
Closing as outdated. The hackney codebase has been significantly refactored to use a gen_statem-based connection model ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normally when the request body is empty,
handle_bodyis only called for POST and PUT requests, since other methods shouldn't haveContent-TypeandContent-Lengthheaders for empty bodies. But one case is missed in the empty body detection, an iolist containing empty binaries. The gleam hackney wrapper represents empty bodies as[<<>>], triggering this bug and causing gleam-lang/hackney#5.This PR expands the empty body detection to check if the result of
iolist_to_binaryis empty.