-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue using Accept-Encoding: gzip
and GzipDecompressorStream
on chunked requests
#859
Comments
Using With HTTP.Stream
With IOBuffer
The problem is that eof is returning false when the decoding is done (7 bytes are remaining in the diff --git a/src/clientlayers/StreamRequest.jl b/src/clientlayers/StreamRequest.jl
index e4ea889..df5633b 100644
--- a/src/clientlayers/StreamRequest.jl
+++ b/src/clientlayers/StreamRequest.jl
@@ -103,7 +103,7 @@ writechunk(stream, body::Union{Dict, NamedTuple}) = writebodystream(stream, body
writechunk(stream, body) = write(stream, body)
function readbody(stream::Stream, res::Response, decompress)
- readstream = decompress && header(res, "Content-Encoding") == "gzip" ? GzipDecompressorStream(stream) : stream
+ readstream = decompress && header(res, "Content-Encoding") == "gzip" ? GzipDecompressorStream(stream; stop_on_end=true) : stream
if isbytes(res.body)
res.body = read(readstream)
elseif !isredirect(stream) && !retryable(stream) |
Accept-Encoding: gzip
and GZipDecompressorStream
Accept-Encoding: gzip
and GzipDecompressorStream
on chunked requests
This plugs a buffer stream in between the decompressor stream and the "user" stream. This make sure that (i) the correct number of bytes is read from the http stream and thus decoded (fixes #859) and (ii) that we can read the http stream in chunks instead of byte-by-byte (the previous code even warns about this usage). Fixes #859.
This plugs a buffer stream in between the decompressor stream and the "user" stream. This make sure that (i) the correct number of bytes is read from the http stream and thus decoded (fixes #859) and (ii) that we can read the http stream in chunks instead of byte-by-byte (the previous code even warns about this usage). Fixes #859.
This plugs a buffer stream in between the decompressor stream and the "user" stream. This make sure that (i) the correct number of bytes is read from the http stream and thus decoded (fixes #859) and (ii) that we can read the http stream in chunks instead of byte-by-byte (the previous code even warns about this usage). Fixes #859.
Thanks for the detailed investigation @Pangoraw! @fredrikekre kindly put up a PR using a BufferedStream approach that seems to work well. Thanks for reporting the issue and helping out! |
While trying the new 1.0 release, I am having an issue making a HTTP request to a website returning a gzip encoded payload. Since the
Accept-Encoding: gzip
is now set automatically this can lead to failures in the default case. To reproduce:Complete stack trace
I believe the error is caused by the combination of
HTTP.Stream
andGZipDecompressorStream
(note the warning that reading one byte from the stream is inneficient) because reading the encoded buffer and then decoding it does not fail:Please specify the following versions when submitting a bug report:
The text was updated successfully, but these errors were encountered: