class HTTP::Features::AutoInflate
Automatically decompresses response bodies
def inflated_response_options(response)
- Api: - private
Returns:
-
(Hash)-
def inflated_response_options(response) { status: response.status, version: response.version, headers: response.headers, proxy_headers: response.proxy_headers, connection: response.connection, body: stream_for(response.connection, encoding: response.body.encoding), request: response.request } end
def stream_for(connection, encoding: Encoding::BINARY)
- Api: - public
Returns:
-
(HTTP::Response::Body)-
Parameters:
-
encoding(Encoding) -- encoding to use for the inflated body -
connection(HTTP::Connection) --
def stream_for(connection, encoding: Encoding::BINARY) Response::Body.new(Response::Inflater.new(connection), encoding: encoding) end
def supported_encoding?(response)
- Api: - private
def supported_encoding?(response) content_encoding = response.headers.get(Headers::CONTENT_ENCODING).first content_encoding && SUPPORTED_ENCODING.include?(content_encoding) end
def wrap_response(response)
- Api: - public
Returns:
-
(HTTP::Response)-
Parameters:
-
response(HTTP::Response) --
def wrap_response(response) return response unless supported_encoding?(response) Response.new(**inflated_response_options(response)) # steep:ignore end