hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Treat iolist of empty binaries as empty body

Open pvsr opened this issue 1 year ago • 1 comments

Normally when the request body is empty, handle_body is only called for POST and PUT requests, since other methods shouldn't have Content-Type and Content-Length headers 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 https://github.com/gleam-lang/hackney/issues/5.

This PR expands the empty body detection to check if the result of iolist_to_binary is empty.

pvsr avatar Jan 22 '25 05:01 pvsr

I rebased and added some integration tests.

pvsr avatar Oct 27 '25 05:10 pvsr