[HttpFoundation] Allow Cache-Control headers on StreamedResponse

This commit is contained in:
Dennis Hotson 2014-10-10 11:42:05 +11:00 committed by Fabien Potencier
parent e19680f31a
commit dd7a9b6231
2 changed files with 9 additions and 12 deletions

View File

@ -79,16 +79,6 @@ class StreamedResponse extends Response
$this->callback = $callback;
}
/**
* {@inheritdoc}
*/
public function prepare(Request $request)
{
$this->headers->set('Cache-Control', 'no-cache');
return parent::prepare($request);
}
/**
* {@inheritdoc}
*

View File

@ -34,7 +34,6 @@ class StreamedResponseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('1.1', $response->getProtocolVersion());
$this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.');
$this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
}
public function testPrepareWith10Protocol()
@ -47,7 +46,6 @@ class StreamedResponseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('1.0', $response->getProtocolVersion());
$this->assertNull($response->headers->get('Transfer-Encoding'));
$this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
}
public function testPrepareWithHeadRequest()
@ -58,6 +56,15 @@ class StreamedResponseTest extends \PHPUnit_Framework_TestCase
$response->prepare($request);
}
public function testPrepareWithCacheHeaders()
{
$response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Cache-Control' => 'max-age=600, public'));
$request = Request::create('/', 'GET');
$response->prepare($request);
$this->assertEquals('max-age=600, public', $response->headers->get('Cache-Control'));
}
public function testSendContent()
{
$called = 0;