8000 Fix edge case with StreamedResponse where headers are sent twice · symfony/symfony@59c8d69 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59c8d69

Browse files
committed
Fix edge case with StreamedResponse where headers are sent twice
1 parent 7b56cc0 commit 59c8d69

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class StreamedResponse extends Response
2828
{
2929
protected $callback;
3030
protected $streamed;
31+
protected $headersSent;
3132

3233
/**
3334
* Constructor.
@@ -44,6 +45,7 @@ public function __construct($callback = null, $status = 200, $headers = array())
4445
$this->setCallback($callback);
4546
}
4647
$this->streamed = false;
48+
$this->headersSent = false;
4749
}
4850

4951
/**
@@ -75,6 +77,22 @@ public function setCallback($callback)
7577
$this->callback = $callback;
7678
}
7779

80+
/**
81+
* {@inheritdoc}
82+
*
83+
* This method only sends the headers once.
84+
*/
85+
public function sendHeaders()
86+
{
87+
if ($this->headersSent) {
88+
return;
89+
}
90+
91+
$this->headersSent = true;
92+
93+
parent::sendHeaders();
94+
}
95+
7896
/**
7997
* {@inheritdoc}
8098
*

0 commit comments

Comments
 (0)
0