prettified and added max-age=0

pull/598/head
Austin Collier 7 months ago
parent f06febdb2d
commit ba80e047b1

@ -288,7 +288,7 @@ class Response
{
if ($expires === false) {
$this->headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$this->headers['Cache-Control'] = 'no-store, no-cache, must-revalidate';
$this->headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
$this->headers['Pragma'] = 'no-cache';
} else {
$expires = \is_int($expires) ? $expires : strtotime($expires);
@ -432,11 +432,10 @@ class Response
}
if ($this->headersSent() === false) {
// If you haven't set a Cache-Control header, we'll assume you don't want caching
if($this->getHeader('Cache-Control') === null) {
$this->cache(false);
}
// If you haven't set a Cache-Control header, we'll assume you don't want caching
if ($this->getHeader('Cache-Control') === null) {
$this->cache(false);
}
$this->sendHeaders();
}
@ -446,16 +445,16 @@ class Response
$this->sent = true;
}
/**
* Headers have been sent
*
* @return bool
* @codeCoverageIgnore
*/
public function headersSent(): bool
{
return headers_sent();
}
/**
* Headers have been sent
*
* @return bool
* @codeCoverageIgnore
*/
public function headersSent(): bool
{
return headers_sent();
}
/**
* Adds a callback to process the response body before it's sent. These are processed in the order

@ -361,8 +361,7 @@ class FlightTest extends TestCase
string $output,
array $renderParams,
string $regexp
): void
{
): void {
Flight::view()->preserveVars = false;
$this->expectOutputString($output);

@ -164,7 +164,7 @@ class ResponseTest extends TestCase
$response->cache(false);
$this->assertEquals([
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control' => 'no-store, no-cache, must-revalidate',
'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0',
'Pragma' => 'no-cache'
], $response->headers());
}
@ -235,8 +235,8 @@ class ResponseTest extends TestCase
$this->assertTrue($response->sent());
}
public function testSendWithNoHeadersSent()
{
public function testSendWithNoHeadersSent()
{
$response = new class extends Response {
protected $test_sent_headers = [];
@ -251,16 +251,16 @@ class ResponseTest extends TestCase
return $this->test_sent_headers;
}
public function headersSent(): bool
{
return false;
}
public function headersSent(): bool
{
return false;
}
};
$response->header('Content-Type', 'text/html');
$response->header('X-Test', 'test');
$response->write('Something');
$this->expectOutputString('Something');
$this->expectOutputString('Something');
$response->send();
$sent_headers = $response->getSentHeaders();
@ -268,9 +268,9 @@ class ResponseTest extends TestCase
'HTTP/1.1 200 OK',
'Content-Type: text/html',
'X-Test: test',
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control: no-store, no-cache, must-revalidate',
'Pragma: no-cache',
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control: no-store, no-cache, must-revalidate, max-age=0',
'Pragma: no-cache',
'Content-Length: 9'
], $sent_headers);
}

Loading…
Cancel
Save