【发布时间】:2020-02-26 14:05:06
【问题描述】:
我正在使用下面的示例代码向浏览器返回数据
$response->write($image);
return $response->withHeader('Content-Type', 'image/jpeg');
效果很好,但是如果我还想返回 Content-Length ,我该怎么做? 到目前为止,我发现的唯一选择是将响应复制到如下所示的新对象中,但如果我在响应中有 $image,我认为这不是有效的。
$response = $response->withAddedHeader('Content-Length', strlen($image));
我尝试将它作为数组但不起作用..
【问题讨论】: