Permalink
Browse files

tweak code style in Chunked

  • Loading branch information...
1 parent d45b9e9 commit ef013d995bd0204ba35c4aa2d226b8b6a0502e3f @mislav mislav committed Jun 5, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/faraday_middleware/response/chunked.rb
@@ -5,7 +5,7 @@ module FaradayMiddleware
class Chunked < FaradayMiddleware::ResponseMiddleware
TRANSFER_ENCODING = 'transfer-encoding'.freeze
- define_parser do |body|
+ define_parser do |raw_body|
raw_body = body
decoded_body = []
until raw_body.empty?
@@ -20,8 +20,11 @@ class Chunked < FaradayMiddleware::ResponseMiddleware
end
def parse_response?(env)
- # Faraday is infected with the net/http behavior of joining multiple values of the same header
- super && env[:response_headers][TRANSFER_ENCODING] && env[:response_headers][TRANSFER_ENCODING].split(',').include?('chunked')
+ super and chunked_encoding?(env[:response_headers])
+ end
+
+ def chunked_encoding?(headers)
+ encoding = headers[TRANSFER_ENCODING] and encoding.split(',').include?('chunked')
end
end
end

0 comments on commit ef013d9

Please sign in to comment.