Class: HTTP::Features::AutoInflate

Inherits:
HTTP::Feature show all
Defined in:
lib/http/features/auto_inflate.rb

Overview

Automatically decompresses response bodies

Instance Method Summary collapse

Methods inherited from HTTP::Feature

#around_request, #on_error, #on_request, #wrap_request

Instance Method Details

#stream_for(connection, encoding: Encoding::BINARY) ⇒ HTTP::Response::Body

Returns an inflating body stream for a connection

Examples:

feature.stream_for(connection)

Parameters:

  • connection (HTTP::Connection)
  • encoding (Encoding) (defaults to: Encoding::BINARY)

    encoding to use for the inflated body

Returns:



33
34
35
# File 'lib/http/features/auto_inflate.rb', line 33

def stream_for(connection, encoding: Encoding::BINARY)
  Response::Body.new(Response::Inflater.new(connection), encoding: encoding)
end

#wrap_response(response) ⇒ HTTP::Response

Wraps a response with an auto-inflating body

Examples:

feature.wrap_response(response)

Parameters:

Returns:



18
19
20
21
22
# File 'lib/http/features/auto_inflate.rb', line 18

def wrap_response(response)
  return response unless supported_encoding?(response)

  Response.new(**inflated_response_options(response)) # steep:ignore
end