210
210
# the unpacking speed) we threw our hands in the air and declared that
211
211
# this method would use the String IO approach on all platforms at all
212
212
# times. And that's the way it is.
214
# Revisited. Here's the beginning of the long story.
215
# http://osdir.com/ml/lang.ruby.gems.devel/2007-06/msg00045.html
217
# StringIO wraping has never worked as a workaround by definition. Skipping
218
# initial 10 bytes and passing -MAX_WBITS to Zlib::Inflate luckily works as
219
# gzip reader, but it only works if the GZip header is 10 bytes long (see
220
# below) and it does not check inflated stream consistency (CRC value in the
223
# RubyGems generated Gzip Header: 10 bytes
224
# magic(2) + method(1) + flag(1) + mtime(4) + exflag(1) + os(1) +
225
# orig_name(0) + comment(0)
227
# Ideally, it must return a GZipReader without meaningless buffering. We
228
# have lots of CRuby committers around so let's fix windows build when we
214
230
def zipped_stream(entry)
215
if defined? Rubinius or defined? Maglev then
216
# these implementations have working Zlib
217
zis = Zlib::GzipReader.new entry
219
is = StringIO.new(dis)
221
# This is Jamis Buck's Zlib workaround for some unknown issue
222
entry.read(10) # skip the gzip header
223
zis = Zlib::Inflate.new(-Zlib::MAX_WBITS)
224
is = StringIO.new(zis.inflate(entry.read))
231
Zlib::GzipReader.new entry