dimanche 19 mai 2019

Continuously sending content to browser in Laravel

I need to stream content to the user browser with curl.In plain php i would just send appropriate headers at the end of header processing in CURLOPT_HEADERFUNCTION callback and then echo the data in CURLOPT_WRITEFUNCTION.

A strip down simple version of the write function callback would be

private function write_callback($handle, $data)
{
    $len = strlen($data);
    echo $data;
    return $len;

}

In plain php , i would set headers with the header function

echo $data in laravel would show the binary data in browser with a content type of text/html

I tried the following to output the data with headers in the callback:

echo response($data)->withHeaders($headers);

You may assume that $headers contain the correct headers



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire