We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I was wondering if it is possible to stream a chunked response using icicle.
Could someone please provide a small example of how I would write to the response's output stream line by line.
If I have this generator:
function getFileLines($file, $mode) { $f = fopen($file, $mode); try { while ($line = fgets($f)) { yield $line; } } finally { fclose($f); } }
`` then I would like to be able to send each line to the client using chunked transfer encoding
// Create some kind of response stream here ??? $responseStream = ... $mime = 'application/json'; $response = new BasicResponse(200, [ 'Content-Type' => $mime, 'Connection' => 'keep-alive', 'Transfer-Encoding' => 'chunked', 'Server' => PROD.'/'.WS_VERSION, 'Date' => gmdate('D, d M Y H:i:s T') ], $responseStream); $responseStream->seek(0); $pos = 0; foreach(getFileLines('some/file.txt') as $l) { $len = dechex(strlen($l)); $line = $len."\r\n"; $line.= $l."\r\n" $responseStream->write($line); $pos+= strlen($line); $responseStream->seek($pos); } // End the chunked transfer $responseStream->end("00\r\n\r\n");
How can I achieve this using ICICLEIO ?
Thanks in advance
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was wondering if it is possible to stream a chunked response using icicle.
Could someone please provide a small example of how I would write to the response's output stream line by line.
If I have this generator:
``
then I would like to be able to send each line to the client using chunked transfer encoding
How can I achieve this using ICICLEIO ?
Thanks in advance
The text was updated successfully, but these errors were encountered: