fixing bugs in the Typhoeus response header parsing

This commit is contained in:
rick 2009-12-10 17:03:01 -08:00
parent 381c134a85
commit cd68a2e609

View File

@ -28,10 +28,11 @@ module Faraday
req = ::Typhoeus::Request.new(uri.to_s, :headers => request_headers, :method => :get) req = ::Typhoeus::Request.new(uri.to_s, :headers => request_headers, :method => :get)
req.on_complete do |response| req.on_complete do |response|
resp.process(response.body) resp.process(response.body)
resp.headers = Hash[response.headers.split(/\r\n/). resp.headers = Hash[*response.headers.split(/\r\n/).
tap(&:shift). # drop the HTTP status line tap {|a| a.shift }. # drop the HTTP status line
map {|h| h.split(/:\s+/,2) }. # split key and value map! {|h| h.split(/:\s+/,2) }. # split key and value
map {|k, v| [k.downcase, v]}] # lower-case key map! {|(k, v)| [k.downcase, v]}.
tap {|a| a.flatten!}]
resp.processed! resp.processed!
end end
@parallel_manager.queue(req) @parallel_manager.queue(req)