hackney: provide content-length header for empty requests - #239
Open
aeruder wants to merge 1 commit into
Open
Conversation
This works around a subtle change in hackney between 1.xx and 4.x.x - newer hackney does not provide the (optional by spec!) "content-length: 0" field for 0-length requests. While clients are free to not provide the content-length in these situations, amazon does require "content-length: 0" for 0-byte POSTs. Without this change some requests will fail with a 411 (like writing a 0-byte file to s3). This change adds the "content-length: 0" header for 1.xx and 4.x.x - both are fine if the header was already present. We could calculate and add for all requests but as hackney 4.x.x is written now that ends up being a bit of a waste of cycles as hackney always calculates the content-length, it just may not add the result to the headers if the header is already present.
Author
|
Fix for #238 |
Author
|
I have a small utility locally that "creates a directory" on s3 (which is really just a 0-byte put_object) and prior to this change get: afterwards it is fine. |
Author
|
I'll also note I've checked this change against hackney 1.25 and 4.6.0 and both are fine with it in place (although obviously 1.25 was fine prior to this change as well). |
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.
This works around a subtle change in hackney between 1.xx and 4.x.x - newer hackney does not provide the (optional by spec!) "content-length: 0" field for 0-length requests. While clients are free to not provide the content-length in these situations, amazon does require "content-length: 0" for 0-byte POSTs. Without this change some requests will fail with a 411 (like writing a 0-byte file to s3).
This change adds the "content-length: 0" header for 1.xx and 4.x.x - both are fine if the header was already present.
We could calculate and add for all requests but as hackney 4.x.x is written now that ends up being a bit of a waste of cycles as hackney always calculates the content-length, it just may not add the result to the headers if the header is already present.