Proposal: block_response


Archiloque <code@...>
 

Hi,

as the feature is asked time to time I was thinking about enable the users to stream the response

Instead of abstracting the response in a new interface I propose to add a new parameter to to request which would specify a block that will be called with the response, as there's a already have a :raw_response we could have a :block_reponse which would work like this:

debugger_block = Proc.new do |http_response|
http_response.read_body do |chunk|
p chunk
end
end

RestClient::Request.execute(:method => :get, :url => "http://wonderful_server.com", :block_response => debugger_block)

what do you think about it ?


A.