當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::setDate方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\Response::setDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::setDate方法的具體用法?PHP Response::setDate怎麽用?PHP Response::setDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\Response的用法示例。


在下文中一共展示了Response::setDate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendHeaders

 /**
  * 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);
 }
開發者ID:KEIII,項目名稱:react-silex,代碼行數:22,代碼來源:ResponseBridge.php

示例2: assertResponseEquals

 protected function assertResponseEquals(Response $expected, Response $actual)
 {
     $expected->setDate($actual->getDate());
     $this->assertEquals($expected, $actual);
 }
開發者ID:omusico,項目名稱:lafayettehelps.com,代碼行數:5,代碼來源:HttpKernelTest.php

示例3: store

 /**
  * 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);
 }
開發者ID:richlove1,項目名稱:avc-october,代碼行數:26,代碼來源:HttpCache.php

示例4: createResponse

 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;
 }
開發者ID:konstantin-s,項目名稱:silex-lazycache,代碼行數:10,代碼來源:LazyCache.php


注:本文中的Symfony\Component\HttpFoundation\Response::setDate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。