Class: HttpDecoders::GZip
Constant Summary collapse
- MAGIC_STRING =
"\x1F\x8B".force_encoding(Encoding::ASCII_8BIT).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #decompress(compressed) ⇒ Object
- #finalize ⇒ Object
-
#initialize ⇒ GZip
constructor
A new instance of GZip.
Methods inherited from Base
Constructor Details
#initialize ⇒ GZip
225 226 227 228 |
# File 'lib/http_decoders.rb', line 225 def initialize super @buffer = nil end |
Class Method Details
.encoding_names ⇒ Object
221 222 223 |
# File 'lib/http_decoders.rb', line 221 def self.encoding_names %w(gzip compressed) end |
Instance Method Details
#decompress(compressed) ⇒ Object
230 231 232 233 234 235 236 |
# File 'lib/http_decoders.rb', line 230 def decompress(compressed) compressed .force_encoding(Encoding::ASCII_8BIT) .each_line(MAGIC_STRING) .map { |chunk| decompress_chunk(chunk) } .join('') end |
#finalize ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/http_decoders.rb', line 238 def finalize if @zstream if !@zstream.finished? r = @zstream.finish end @zstream.close r else nil end rescue Zlib::Error raise DecoderError end |