-
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
Support transparent gzip decompression #256
Comments
Yes, this could be supported. Lines 395 to 401 in b602c4e
|
This is cool. You guys ok to add |
A test case could be the use of
|
I'm not sure if this is still being worked on, but regarding the method we use to decompress, there seem to be two reasonable options (that I can find). Option 1 uses (as suggested by @samoconnor above) using BenchmarkTools, TranscodingStreams, CodecZlib, Libz
function decode1(data::Vector{UInt8})
return String(transcode(GzipDecompressor, data))
end
function decode2(data::Vector{UInt8})
return String(read(ZlibInflateInputStream(data)))
end Benchmarking this, we get julia> @btime decode1(test);
1.770 μs (7 allocations: 832 bytes);
julia> @btime decode2(test);
1.517 μs (7 allocations: 9.77 KiB) Or, using the suggested test data by @Alexander-Barth: julia> @btime decode1(r.body);
4.948 μs (7 allocations: 1.31 KiB)
julia> @btime decode2(r.body);
4.417 μs (7 allocations: 9.89 KiB) Not sure if this information is useful, but thought I'd share what I've found. |
@jakewilliami this was useful, tysm!! |
Going to put this on the 1.0 milestone. I'll try to work on this soon. |
Implements #256. If the content-encoding of a response is "gzip" and the keyword argument `decompress === true`, then we'll use CodecZlib.jl to decompress the response and set as the response body. Passing `decompress=false` will leave the resposne body as-is. We also support `HTTP.decode(::Request, "gzip")` which will do the decompression.
PR is up: #838 |
* Auto decompress gzip-encoding response bodies Implements #256. If the content-encoding of a response is "gzip" and the keyword argument `decompress === true`, then we'll use CodecZlib.jl to decompress the response and set as the response body. Passing `decompress=false` will leave the resposne body as-is. We also support `HTTP.decode(::Request, "gzip")` which will do the decompression. * fixes * fix * fix * fix' * fix
Thank you very much for this great package and this new feature 🙂 |
Hello everyone! I have a problem about this topic. What about WebSocket connection? I getting packages with compress data from server, but I can't decompress it. I get
I understand, in this PR gzip decomression protocol, but in my opinion, it's not much different. |
Some server always respond with a compressed stream, e.g. the stackoverflow API:
It would be nice if I can directly access the decompressed response body.
As a workaround, I can use CodecZlib
Would it be possible to support transparent decompression, or is it already implemented?
Julia 0.6.3
HTTP.jl master 61e6b05
MbedTLS.jl 0.5.9
The text was updated successfully, but these errors were encountered: