Module: ThreadedProxy::Controller
- Defined in:
- lib/threaded_proxy/controller.rb
Instance Method Summary collapse
-
#proxy_fetch(origin_url, options = {}) {|Client| ... } ⇒ void
Proxies a fetch request to the specified origin URL, allowing for hijacking the controller response outside of the Rack request/response cycle.
Instance Method Details
#proxy_fetch(origin_url, options = {}) {|Client| ... } ⇒ void
This method returns an undefined value.
Proxies a fetch request to the specified origin URL, allowing for hijacking the controller response outside of the Rack request/response cycle.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/threaded_proxy/controller.rb', line 25 def proxy_fetch(origin_url, = {}, &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'] .deep_merge!() if [:body] == :rack Thread.new do client = Client.new(origin_url, , &block) client.start(socket) ensure socket.close unless socket.closed? end head :ok end |