Fix ts_http:split_body for non-chunked responses #302
Merged
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: gzip
and 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/1
did append a newline to the body.This PR changes two things:
\n
to 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/1
is used)We first wondered, why this hasn't been a big problem in our many thousand test executions because
zlib:gunzip/1
will 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/1
is used to perform the split of headers and body which does not suffer from the same problem.