lib/falcon/adapters/rack.rb in falcon-0.17.1 vs lib/falcon/adapters/rack.rb in falcon-0.17.4

- old
+ new

@@ -85,12 +85,17 @@ if request.hijack? env['rack.hijack?'] = true env['rack.hijack'] = lambda do - @logger.debug(request) {"Hijacking request..."} - env['rack.hijack_io'] = request.hijack + wrapper = request.hijack + + # We dup this as it might be taken out of the normal control flow, and the io will be closed shortly after returning from this method. + io = wrapper.io.dup + wrapper.close + + env['rack.hijack_io'] = io end else env['rack.hijack?'] = false end @@ -103,12 +108,12 @@ # hijack.call(body) # end # return nil # end - if env['rack.hijack_io'] - return nil - end + # if env['rack.hijack_io'] + # return nil + # end @logger.debug(request) {"Rack response: #{status} #{headers.inspect} #{body.class}"} return Response.new(status, headers, body) rescue => exception @logger.error "#{exception.class}: #{exception.message}\n\t#{$!.backtrace.join("\n\t")}"