When tried to download via Ruby using the code below, I see that in Ruby
-2.1.2p95 the size is blown up to approx 85M. Now when trying to untar
this archive using the zlib utils [ Gem::TarReader.new(
Zlib::GzipReader.open(archive) ) do |tar| ] it fails complaining it is
not in gzip format.
But when I try the same code in Ruby-1.9.3p429 it works fine and I am
able to see a file of 25M downloaded and untarred successfully.
Any idea what is going wrong? Am I missing something?
This is happening because Net::HTTP is automatically decompressing the
data when it sees that the data is of type gzip.
Thanks to @yorickpeterse on ruby irc channel who helped on this.
But still this doesn’t help me getting it working end to end. Any one
knows how can I save this untarred content [it contains directories and
I want to preserve the tree structure] onto disk and make use of it?
Net::HTTP automatically adds Accept-Encoding for compression of response
bodies and automatically decompresses gzip and deflate responses unless
a Range header was sent.
Compression can be disabled through the Accept-Encoding: identity
header.
Also, now that this needs to work for both Ruby-1.9.3 and Ruby-2.1.2 any
idea how can I determine if the data is inflated or not in the code and
accordingly take up next action?
I should be reading headers (?) as I see the code deletes
content-encoding. If this is correct…any pointers on how can I
achieve this?
Thanks
Praveen
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.