Skip to content

Commit

Permalink
[HttpFoundation] Allow Cache-Control headers on StreamedResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Hotson authored and fabpot committed Nov 2, 2014
1 parent e19680f commit dd7a9b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/Symfony/Component/HttpFoundation/StreamedResponse.php
Expand Up @@ -79,16 +79,6 @@ public function setCallback($callback)
$this->callback = $callback;
}

/**
* {@inheritdoc}
*/
public function prepare(Request $request)
{
$this->headers->set('Cache-Control', 'no-cache');

return parent::prepare($request);
}

/**
* {@inheritdoc}
*
Expand Down
Expand Up @@ -34,7 +34,6 @@ public function testPrepareWith11Protocol()

$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()
Expand All @@ -47,7 +46,6 @@ public function testPrepareWith10Protocol()

$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()
Expand All @@ -58,6 +56,15 @@ public function testPrepareWithHeadRequest()
$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;
Expand Down

0 comments on commit dd7a9b6

Please sign in to comment.