国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

workerman4.x withFile發(fā)送文件流問題

zhqing

$response = (new Response())->withFile($file);
$response->withHeaders([
'Connection' => 'keep-alive',
'Content-Type' => 'audio/mpeg',
'Accept-Ranges' => '0-8888322',
'Last-Modified' => 'Thu, 19 Mar 2020 16:48:04 Asia/Shanghai',
'Content-Length' => '8888322',
'Content-Range' => 'bytes 0-8888321/8888322'
]);
$connection->send($response);
以上這樣設(shè)置無法使用流來發(fā)送
因為Safari瀏覽器一定要使用流才能播放mp3 mp4等.
如何解決?

3366 3 0
3個回答

zhqing

我以前在3的板本里面找了代碼出來做了一個流可以發(fā)送。但在4的板本中無法使用session
使用Response就可以使用session

  • 暫無評論
walkor 打賞

session的作用是?

  • 暫無評論
walkor 打賞

更新到主干版本 https://github.com/walkor/Workerman 4.0.3 。
4.0.3剛剛給response->withFile()增加了$offset_start, $length 參數(shù)。

$worker->onMessage = function($connection, $request)
{
    if (preg_match('/bytes=(\d*)-(\d*)/i', $request->header('range'), $match)) {
        $offset_start = (int)$match[1];
        $offset_end = $match[2];
        $length = $offset_end === '' ? 0 :  $offset_end - $offset_start + 1;
        $response = (new Response())->withFile($file, $offset_start, $length);
    } else {
        $response = (new Response())->withFile($file);
    }
    $connection->send($response);
};
  • zhqing 2020-03-21

    好的,謝謝,我試試

  • zhqing 2020-03-22

    Safari瀏覽器都測試了,完全沒那問題,我要捐贈支持

  • walkor 2020-03-22

    好的,感謝支持。

年代過于久遠(yuǎn),無法發(fā)表回答
??