Set Content-Length response header even for bodies not responding to to_ary#1509
Conversation
…to_ary This to_ary check was previously there to work around an infinite loop issue due to Rack::Response#to_ary being defined. Rack::Response#to_ary has been removed, so this check can be removed, and the middleware can correctly calculate Content-Length for all valid rack responses. Fixes rack#734
|
The That infinite-loop issue was only indirectly related to In fact, the See #166 and 9495207 for further related discussion. This decade-old discussion on how best to handle streaming response bodies in the Rack interface while also supporting full-response-reading middleware such as |
|
@wjordan Thanks for the providing the additional context. I guess I was misled by #734 which said the code was added to address #419 (the infinite loop issue). I'm not sure if we want to revert the behavior. We'd have to come up with another way to address #734 if we did revert it. If we decide to treat some bodies differently than other bodies, than we may want to revisit this. However, we should probably make a consistent decision that is applied across all middleware that ship with Rack. Just checking for |
|
No one should be setting the |
This to_ary check was previously there to work around an infinite
loop issue due to Rack::Response#to_ary being defined.
Rack::Response#to_ary has been removed, so this check can be removed,
and the middleware can correctly calculate Content-Length for all
valid rack responses.
Fixes #734