10000 streamed response should return $this · symfony/symfony@058fb84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 058fb84

Browse files
DQNEOnicolas-grekas
authored andcommitted
streamed response should return $this
1 parent 2fc9b57 commit 058fb84

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ public function setCallback($callback)
8383
public function sendHeaders()
8484
{
8585
if ($this->headersSent) {
86-
return;
86+
return $this;
8787
}
8888

8989
$this->headersSent = true;
9090

91-
parent::sendHeaders();
91+
return parent::sendHeaders();
9292
}
9393

9494
/**
@@ -99,7 +99,7 @@ public function sendHeaders()
9999
public function sendContent()
100100
{
101101
if ($this->streamed) {
102-
return;
102+
return $this;
103103
}
104104

105105
$this->streamed = true;
@@ -109,6 +109,8 @@ public function sendContent()
109109
}
110110

111111
call_user_func($this->callback);
112+
113+
return $this;
112114
}
113115

114116
/**

src/Symfony/Component/HttpFoundation/Tests/StreamedResponseTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,15 @@ public function testCreate()
121121
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
122122
$this->assertEquals(204, $response->getStatusCode());
123123
}
124+
125+
public function testReturnThis()
126+
{
127+
$response = new StreamedResponse(function () {});
128+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
129+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
130+
131+
$response = new StreamedResponse(function () {});
132+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
133+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
134+
}
124135
}

0 commit comments

Comments
 (0)
0