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


PHP Response::getLastModified方法代碼示例

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


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

示例1: createRevalidationRequest

 /**
  * Creates a request to use for revalidation
  *
  * @param RequestInterface $request  Request
  * @param Response         $response Response to revalidate
  *
  * @return RequestInterface returns a revalidation request
  */
 protected function createRevalidationRequest(RequestInterface $request, Response $response)
 {
     $revalidate = clone $request;
     $revalidate->removeHeader('Pragma')->removeHeader('Cache-Control')->setHeader('If-Modified-Since', $response->getLastModified() ?: $response->getDate());
     if ($response->getEtag()) {
         $revalidate->setHeader('If-None-Match', '"' . $response->getEtag() . '"');
     }
     // Remove any cache plugins that might be on the request
     $revalidate->getEventDispatcher()->removeSubscriber($this->plugin);
     return $revalidate;
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:19,代碼來源:DefaultRevalidation.php

示例2: createRevalidationRequest

 /**
  * Creates a request to use for revalidation
  *
  * @param RequestInterface $request  Request
  * @param Response         $response Response to revalidate
  *
  * @return RequestInterface returns a revalidation request
  */
 protected function createRevalidationRequest(RequestInterface $request, Response $response)
 {
     $revalidate = clone $request;
     $revalidate->removeHeader('Pragma')->removeHeader('Cache-Control');
     if ($response->getLastModified()) {
         $revalidate->setHeader('If-Modified-Since', $response->getLastModified());
     }
     if ($response->getEtag()) {
         $revalidate->setHeader('If-None-Match', $response->getEtag());
     }
     // Remove any cache plugins that might be on the request to prevent infinite recursive revalidations
     $dispatcher = $revalidate->getEventDispatcher();
     foreach ($dispatcher->getListeners() as $eventName => $listeners) {
         foreach ($listeners as $listener) {
             if (is_array($listener) && $listener[0] instanceof CachePlugin) {
                 $dispatcher->removeListener($eventName, $listener);
             }
         }
     }
     return $revalidate;
 }
開發者ID:Trideon,項目名稱:gigolo,代碼行數:29,代碼來源:DefaultRevalidation.php

示例3: onRequestError

 /**
  * If possible, return a cache response on an error
  *
  * @param Event $event
  */
 public function onRequestError(Event $event)
 {
     $request = $event['request'];
     if (!$this->canCache->canCacheRequest($request)) {
         return;
     }
     $cacheKey = $this->keyProvider->getCacheKey($request);
     if ($cachedData = $this->storage->fetch($cacheKey)) {
         $response = new Response($cachedData[0], $cachedData[1], $cachedData[2]);
         $response->setRequest($request);
         $response->setHeader('Age', time() - strtotime($response->getLastModified() ?: $response->getDate() ?: 'now'));
         if ($this->canResponseSatisfyFailedRequest($request, $response)) {
             $request->getParams()->set('cache.hit', 'error');
             $this->addResponseHeaders($cacheKey, $request, $response);
             $event['response'] = $response;
             $event->stopPropagation();
         }
     }
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:24,代碼來源:CachePlugin.php


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