Skip to content

Commit

Permalink
Merge pull request #2422 from codeigniter4/dupheaders
Browse files Browse the repository at this point in the history
Don't show duplicate Date headers when running under PHPs server. Fixes #2375
  • Loading branch information
lonnieezell authored Nov 21, 2019
2 parents 0595045 + 403c333 commit a976069
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/HTTP/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ public function sendHeaders()

// Per spec, MUST be sent with each request, if possible.
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
if (! isset($this->headers['Date']))
if (! isset($this->headers['Date']) && php_sapi_name() !== 'cli-server')
{
$this->setDate(\DateTime::createFromFormat('U', (string) time()));
}
Expand All @@ -724,7 +724,7 @@ public function sendHeaders()
// Send all of our headers
foreach ($this->getHeaders() as $name => $values)
{
header($name . ': ' . $this->getHeaderLine($name), false, $this->statusCode);
header($name . ': ' . $this->getHeaderLine($name), true, $this->statusCode);
}

return $this;
Expand Down

0 comments on commit a976069

Please sign in to comment.