lib/threaded_proxy/controller.rb in rails-threaded-proxy-0.3.0 vs lib/threaded_proxy/controller.rb in rails-threaded-proxy-0.4.0
- old
+ new
@@ -2,11 +2,11 @@
require_relative 'client'
module ThreadedProxy
module Controller
- def proxy_fetch(origin_url, options = {})
+ def proxy_fetch(origin_url, options = {}, &block)
# hijack the response so we can take it outside of the rack request/response cycle
request.env['rack.hijack'].call
socket = request.env['rack.hijack_io']
Thread.new do
@@ -23,10 +23,10 @@
end
options[:headers]['Content-Type'] = request.env['CONTENT_TYPE'] if request.env['CONTENT_TYPE']
end
- client = Client.new(origin_url, options)
+ client = Client.new(origin_url, options, &block)
client.start(socket)
rescue Errno::EPIPE
# client disconnected before request finished; not an error
ensure
socket.close unless socket.closed?