当前位置: 首页>>代码示例>>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;未经允许,请勿转载。