Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2ad3b0d

Browse filesBrowse files
committed
[HttpFoundation] Postpone setting the date header on a Response
1 parent 567af65 commit 2ad3b0d
Copy full SHA for 2ad3b0d

File tree

Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-4
lines changed

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ public function __construct($content = '', $status = 200, $headers = array())
202202
$this->setContent($content);
203203
$this->setStatusCode($status);
204204
$this->setProtocolVersion('1.0');
205-
if (!$this->headers->has('Date')) {
206-
$this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
207-
}
208205
}
209206

210207
/**
@@ -333,6 +330,10 @@ public function sendHeaders()
333330
return $this;
334331
}
335332

333+
if (!$this->headers->has('Date')) {
334+
$this->setDate(new \DateTime());
335+
}
336+
336337
// status
337338
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
338339

@@ -644,7 +645,11 @@ public function mustRevalidate()
644645
*/
645646
public function getDate()
646647
{
647-
return $this->headers->getDate('Date', new \DateTime());
648+
if (!$this->headers->has('Date')) {
649+
$this->setDate(new \DateTime());
650+
}
651+
652+
return $this->headers->getDate('Date');
648653
}
649654

650655
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.