Skip to content

Add content auto decoding for download() #986

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

Merged
merged 2 commits into from
Jan 13, 2023

Conversation

AtsushiSakai
Copy link
Contributor

@AtsushiSakai AtsushiSakai commented Jan 8, 2023

This PR adds content auto decoding function for download() using TranscodingStreams.jl to fix #889

@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2023

Codecov Report

Merging #986 (85576bb) into master (fe9bf99) will decrease coverage by 0.08%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #986      +/-   ##
==========================================
- Coverage   82.53%   82.45%   -0.09%     
==========================================
  Files          37       37              
  Lines        3040     3043       +3     
==========================================
  Hits         2509     2509              
- Misses        531      534       +3     
Impacted Files Coverage Δ
src/download.jl 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

src/download.jl Outdated
@@ -121,6 +123,11 @@ function download(url::AbstractString, local_path=nothing, headers=Header[]; upd
start_time = now()
prev_time = now()

if header(resp, "Content-Encoding") == "gzip"
stream = TranscodingStream(GzipDecompressor(), stream) # auto decoding
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just be:

Suggested change
stream = TranscodingStream(GzipDecompressor(), stream) # auto decoding
stream = GzipDecompressorStream(stream) # auto decoding

and then we don't need the explicit dependency on TranscodingStreams

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I fixed.

@@ -13,6 +13,7 @@ include(joinpath(dir, "resources/TestRequest.jl"))
"chunking.jl",
"utils.jl",
"client.jl",
"download.jl",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this test file is missing.

if header(resp, "Content-Encoding") == "gzip"
filename *= ".gz"
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto decoding is added, so I think ".gz" is not needed anymore. And this change is needed to pass "test/download.jl".

@quinnj
Copy link
Member

quinnj commented Jan 13, 2023

Thanks @AtsushiSakai!

@quinnj quinnj merged commit c869d85 into JuliaWeb:master Jan 13, 2023
@AtsushiSakai AtsushiSakai deleted the issue_889 branch January 13, 2023 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP.download() does not automatically decode Content-Encoding
3 participants