[HttpFoundation] Postpone setting the date header on a Response
This commit is contained in:
parent
567af657a0
commit
2ad3b0d890
@ -202,9 +202,6 @@ class Response
|
||||
$this->setContent($content);
|
||||
$this->setStatusCode($status);
|
||||
$this->setProtocolVersion('1.0');
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,6 +330,10 @@ class Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(new \DateTime());
|
||||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
|
||||
@ -644,7 +645,11 @@ class Response
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->headers->getDate('Date', new \DateTime());
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(new \DateTime());
|
||||
}
|
||||
|
||||
return $this->headers->getDate('Date');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user