setDate() public method

Sets the Date header.
public setDate ( DateTime $date ) : Response
$date DateTime A \DateTime instance
return Response
Exemplo n.º 1
0
 /**
  * Sends HTTP headers.
  *
  * @param ReactResponse   $response
  * @param SymfonyResponse $sf_response
  */
 private function sendHeaders(ReactResponse $response, SymfonyResponse $sf_response)
 {
     // date
     if (!$sf_response->headers->has('Date')) {
         $sf_response->setDate(\DateTime::createFromFormat('U', time()));
     }
     $headers = $sf_response->headers->allPreserveCase();
     // cookies
     foreach ($sf_response->headers->getCookies() as $cookie) {
         if (!isset($headers['Set-Cookie'])) {
             $headers['Set-Cookie'] = [];
         }
         $headers['Set-Cookie'][] = (string) $cookie;
     }
     $response->writeHead($sf_response->getStatusCode(), $headers);
 }
Exemplo n.º 2
0
 protected function assertResponseEquals(Response $expected, Response $actual)
 {
     $expected->setDate($actual->getDate());
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 3
0
 /**
  * Writes the Response to the cache.
  *
  * @param Request  $request  A Request instance
  * @param Response $response A Response instance
  *
  * @throws \Exception
  */
 protected function store(Request $request, Response $response)
 {
     if (!$response->headers->has('Date')) {
         $response->setDate(\DateTime::createFromFormat('U', time()));
     }
     try {
         $this->store->write($request, $response);
         $this->record($request, 'store');
         $response->headers->set('Age', $response->getAge());
     } catch (\Exception $e) {
         $this->record($request, 'store-failed');
         if ($this->options['debug']) {
             throw $e;
         }
     }
     // now that the response is cached, release the lock
     $this->store->unlock($request);
 }
Exemplo n.º 4
0
 public function createResponse($lMT)
 {
     $response = new Response();
     $response->setPublic();
     $response->setDate(new \DateTime("now"));
     $response->setMaxAge($this->config->getMaxAge());
     $response->setSharedMaxAge($this->config->getMaxAgeShared());
     $response->setLastModified(new \DateTime($lMT));
     return $response;
 }