class HTTP::Features::AutoDeflate::CompressedBody

Base class for compressed request body wrappers

def compress_all!

Other tags:
    Api: - private

Returns:
  • (void) -
def compress_all!
  @compressed = Tempfile.new("http-compressed_body", binmode: true)
  compress { |data| @compressed.write(data) }
  @compressed.rewind
end

def compressed_each

Other tags:
    Api: - private

Returns:
  • (void) -
def compressed_each
  while (data = @compressed.read(Connection::BUFFER_SIZE))
    yield data
  end
ensure
  @compressed.close!
end

def each(&block)

Other tags:
    Api: - public

Returns:
  • (self, Enumerator) -
def each(&block)
  return to_enum(:each) unless block
  if @compressed
    compressed_each(&block)
  else
    compress(&block)
  end
  self
end

def initialize(uncompressed_body)

Other tags:
    Api: - public

Returns:
  • (CompressedBody) -

Parameters:
  • uncompressed_body (HTTP::Request::Body) --
def initialize(uncompressed_body)
  super(nil)
  @body       = uncompressed_body
  @compressed = nil
end

def size

Other tags:
    Api: - public

Returns:
  • (Integer) -
def size
  compress_all! unless @compressed
  @compressed.size
end