diff --git a/src/main/ruby/jruby/rack/response.rb b/src/main/ruby/jruby/rack/response.rb index 91467085..7504eb95 100644 --- a/src/main/ruby/jruby/rack/response.rb +++ b/src/main/ruby/jruby/rack/response.rb @@ -161,10 +161,11 @@ def write_body(response) body = @body.to_inputstream # so that we close the stream body = Channels.newChannel(body) # closing the channel closes the stream transfer_channel body, response.getOutputStream - elsif @body.respond_to?(:body_parts) && @body.body_parts.respond_to?(:to_channel) && - ! object_polluted_with_anyio?(@body.body_parts, :to_channel) + elsif @body.respond_to?(:body_parts) && ! @body.respond_to?(:stream) + && ( body_parts = @body.body_parts ).respond_to?(:to_channel) && + ! object_polluted_with_anyio?(body_parts, :to_channel) # ActionDispatch::Response "raw" body access in case it's a File - body = @body.body_parts.to_channel # so that we close the channel + body = body_parts.to_channel # so that we close the channel transfer_channel body, response.getOutputStream else if dechunk?