yii2-psr7-bridge
yii2-psr7-bridge copied to clipboard
support sendFile and sendStreamAsFile for Response
support sendFile and sendStreamAsFile for Response, it is ok with workerman ,hope to provide an idea,
use GuzzleHttp\Psr7\Utils;
class Response extends \yii\Psr7\web\Response
{
/**
* {@inheritDoc}
*/
public function sendStreamAsFile($handle, $attachmentName, $options = [])
{
$response = parent::sendStreamAsFile($handle, $attachmentName, $options);
$this->stream = Utils::streamFor($this->stream[0]);
return $response;
}
}
Hi. sendFile
and sendStreamAsFile
are outstanding items that remain to be implemented. I'd prefer not to introduce Guzzle as a dependency, however if the method you outlined is sufficient and covers all of the Yii2 tests I'd consider it.
A merge request would be welcome. I'd consider a solution that doesn't depend on Guzzle.