streamed response should return $this
This commit is contained in:
parent
2fc9b57f65
commit
058fb84554
|
@ -83,12 +83,12 @@ class StreamedResponse extends Response
|
||||||
public function sendHeaders()
|
public function sendHeaders()
|
||||||
{
|
{
|
||||||
if ($this->headersSent) {
|
if ($this->headersSent) {
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->headersSent = true;
|
$this->headersSent = true;
|
||||||
|
|
||||||
parent::sendHeaders();
|
return parent::sendHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,7 @@ class StreamedResponse extends Response
|
||||||
public function sendContent()
|
public function sendContent()
|
||||||
{
|
{
|
||||||
if ($this->streamed) {
|
if ($this->streamed) {
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->streamed = true;
|
$this->streamed = true;
|
||||||
|
@ -109,6 +109,8 @@ class StreamedResponse extends Response
|
||||||
}
|
}
|
||||||
|
|
||||||
call_user_func($this->callback);
|
call_user_func($this->callback);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -121,4 +121,15 @@ class StreamedResponseTest extends TestCase
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
|
||||||
$this->assertEquals(204, $response->getStatusCode());
|
$this->assertEquals(204, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReturnThis()
|
||||||
|
{
|
||||||
|
$response = new StreamedResponse(function () {});
|
||||||
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
||||||
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendContent());
|
||||||
|
|
||||||
|
$response = new StreamedResponse(function () {});
|
||||||
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue