Configuration
--
Transfer-Encoding: chunked
I've been unable to make this work and unable to find a definitive answer: in the above configuration, I want to stream large amounts of data to the client (in the response) - is this supported?
\r\n
, 0
etc?write
, write
, write
, flush
write
, write
, write
, flush
close
self.response_body = Enumerator.new
and response.stream.write
, etc. -- all with similar results (via curl
) - Malformed encoding found in chunked-encoding
or transfer closed with outstanding read data remaining
Can anyone show me the light?
The ActionController::Live API offers exactly what you describe: response.stream.write
and response.stream.close
. (write
flushes a chunk automatically; you'll need to do your own buffering if that doesn't work for you.)
As long as you include ActionController::Live
(and note that affects the behaviour of the entire controller, not just one action), you should then be able to write a streaming response with no further effort: you need not, and should not, set any headers etc related to chunking.
Additional reference: http://tenderlovemaking.com/2012/07/30/is-it-live.html