Class: FaradayMiddleware::Chunked

Inherits:
ResponseMiddleware show all
Defined in:
lib/faraday_middleware/response/chunked.rb

Overview

Public: Parse a Transfer-Encoding: Chunked response to just the original data

Constant Summary collapse

TRANSFER_ENCODING =
'transfer-encoding'.freeze

Constants inherited from ResponseMiddleware

ResponseMiddleware::CONTENT_TYPE

Instance Method Summary collapse

Methods inherited from ResponseMiddleware

#call, define_parser, inherited, #initialize, #parse, #preserve_raw?, #process_response, #process_response_type?, #response_type

Constructor Details

This class inherits a constructor from FaradayMiddleware::ResponseMiddleware

Instance Method Details

#chunked_encoding?(headers) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/faraday_middleware/response/chunked.rb', line 25

def chunked_encoding?(headers)
  encoding = headers[TRANSFER_ENCODING] and encoding.split(',').include?('chunked')
end

#parse_response?(env) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/faraday_middleware/response/chunked.rb', line 21

def parse_response?(env)
  super and chunked_encoding?(env[:response_headers])
end