Chunked transfer encoding

Elefant's handlers can do chunked transfer encoding through the Controller's flush() method. Here's an example of how to use it:


$list = array ('Item one', 'Item two', 'Item three', 'Item four');

echo '<ul>';
foreach ($list as $item) {
    printf ('<li>%s</li>', $item);
    $this->flush ();
echo '</ul>';


This will result in the following server output (some headers omitted for brevity):

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/html

<ul><li>Item one</li>
<li>Item two</li>
<li>Item three</li>
<li>Item four</li>

Note that once you call flush(), the remaining output at the end of your handler will not be cached through the Controller's automatic caching, and it will not be returned to the front controller for layout rendering, but will instead be flushed automatically and exit.

Also note that the Transfer-Encoding: chunked header will be sent automatically on the first call to flush().

Edit this page.
This documentation was generated by the Elefant Documentation Project. We're always open to new contributions *wink* *wink*