Class: FaradayMiddleware::Chunked

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

Overview

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

Constant Summary collapse

TRANSFER_ENCODING =
'transfer-encoding'

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)


28
29
30
31
# File 'lib/faraday_middleware/response/chunked.rb', line 28

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

#parse_response?(env) ⇒ Boolean

Returns:

  • (Boolean)


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

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