Fix edge case with StreamedResponse where headers are sent twice
This commit is contained in:
parent
7b56cc0876
commit
a79991f44a
@ -28,6 +28,7 @@ class StreamedResponse extends Response
|
|||||||
{
|
{
|
||||||
protected $callback;
|
protected $callback;
|
||||||
protected $streamed;
|
protected $streamed;
|
||||||
|
private $headersSent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -44,6 +45,7 @@ class StreamedResponse extends Response
|
|||||||
$this->setCallback($callback);
|
$this->setCallback($callback);
|
||||||
}
|
}
|
||||||
$this->streamed = false;
|
$this->streamed = false;
|
||||||
|
$this->headersSent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +77,22 @@ class StreamedResponse extends Response
|
|||||||
$this->callback = $callback;
|
$this->callback = $callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* This method only sends the headers once.
|
||||||
|
*/
|
||||||
|
public function sendHeaders()
|
||||||
|
{
|
||||||
|
if ($this->headersSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->headersSent = true;
|
||||||
|
|
||||||
|
parent::sendHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user