Fix edge case with StreamedResponse where headers are sent twice

This commit is contained in:
Tristan Darricau 2016-10-24 16:19:10 +02:00
parent 7b56cc0876
commit a79991f44a
No known key found for this signature in database
GPG Key ID: 817043C2E29DB881

View File

@ -28,6 +28,7 @@ class StreamedResponse extends Response
{
protected $callback;
protected $streamed;
private $headersSent;
/**
* Constructor.
@ -44,6 +45,7 @@ class StreamedResponse extends Response
$this->setCallback($callback);
}
$this->streamed = false;
$this->headersSent = false;
}
/**
@ -75,6 +77,22 @@ class StreamedResponse extends Response
$this->callback = $callback;
}
/**
* {@inheritdoc}
*
* This method only sends the headers once.
*/
public function sendHeaders()
{
if ($this->headersSent) {
return;
}
$this->headersSent = true;
parent::sendHeaders();
}
/**
* {@inheritdoc}
*