Sha256: d59feb6d6dbed7dc2b314d7dbe60fe4d2c3a9d19fccde2c1518b3593e9fdcf3a
Contents?: true
Size: 832 Bytes
Versions: 20
Compression:
Stored size: 832 Bytes
Contents
# frozen_string_literal: true require "zlib" require_relative "utils/deflater" module HTTPX module Transcoder module Deflate class Deflater < Transcoder::Deflater def deflate(chunk) @deflater ||= Zlib::Deflate.new if chunk.nil? unless @deflater.closed? last = @deflater.finish @deflater.close last.empty? ? nil : last end else @deflater.deflate(chunk) end end end module_function def encode(body) Deflater.new(body) end def decode(response, bytesize: nil) bytesize ||= response.headers.key?("content-length") ? response.headers["content-length"].to_i : Float::INFINITY GZIP::Inflater.new(bytesize) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems