This would depend if Content-Length would be set by another middleware, so depending on the order of the middlewares it might work or not.

This is just as brittle in my opinion. The proper way of handling this is through some new API in the Rack library itself to let the middlewares know whether it's a streamed response or not.

Such API would also be useful in this issue:

https://github.com/rails/rails/issues/14358

By the way, I can't find it by searching on GitHub. Any ideas why? I can only access it because I had the link stored in some e-mail of my inbox...

On 15-07-2014 08:58, ismaSan wrote:
I haven't tested this but an HTTP streaming response should *not* have a Content-Length header. Maybe that's enough to detect whether it's streaming or not? So you look at the properties of the HTTP response itself instead of the Ruby wrapper, which as you say might change in the future.


On Monday, 14 July 2014 22:14:31 UTC+1, Jason Clark wrote:

    I'm curious if there's a good way to detect from a Rack middleware
    whether a response is streaming or not.

    From what I can see, my options are:

    * In the Controller note we've included `ActionController::Live`
    somewhere the middleware can access it
    * Look at the response object coming back to Rack to see if its
    class is `ActionController::Live::Response`
    * Look at the `stream` (if available) on the response object
    returned to Rack to check if it's a `ActionController::Live::Buffer`

    All of these ideas seem pretty brittle and liable to break across
    new versions of Rails and/or new streaming mechanisms that might
    come along. Is there something I'm missing?

    Thanks!

    Jason Clark
    @jasonrclark
    New Relic, Ruby Agent engineer

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to