Fix ts_http:split_body for non-chunked responses#302
Merged
Conversation
Collaborator
Author
|
Sorry for pinging, @nniclausse. But could you also have a quick look on this? Although this is a rare case, we've tested this quite a bit against different scenarios. I'd really like to narrow down the amount of patches I have to maintain :) |
Contributor
|
Merged. Don't hesitate to ping me ! |
|
Any chance of having of this fix released? |
|
For example, Go default |
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.
We observed this error a lot for a recent test:
The request was made with
Accept-Encoding: gzipand the server answered with an gzip encoded response. BUT the server did send the response withoutTransfer-Encoding: chunked. The previous implementation ofts_http:split_body/1did append a newline to the body.This PR changes two things:
\nto the extracted body. The response body does not need to be terminated by\r\n(unless the response is chunked, which is never the case whents_http:split_body/1is used)We first wondered, why this hasn't been a big problem in our many thousand test executions because
zlib:gunzip/1will always fail if you append<<10>>. The reason why this did not happen all the time is, that it is very uncommon to have a not-chunked but gzipped response. In case the response is chunkedts_http:decode_chunk/1is used to perform the split of headers and body which does not suffer from the same problem.