当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getETags方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::getETags方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getETags方法的具体用法?PHP Request::getETags怎么用?PHP Request::getETags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Request的用法示例。


在下文中一共展示了Request::getETags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createContexts

 public function createContexts(Request $request)
 {
     $map = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_route' => $request->attributes->get('_route'), 'request_host' => $request->getHost(), 'request_port' => $request->getPort(), 'request_scheme' => $request->getScheme(), 'request_client_ip' => $request->getClientIp(), 'request_content_type' => $request->getContentType(), 'request_acceptable_content_types' => $request->getAcceptableContentTypes(), 'request_etags' => $request->getETags(), 'request_charsets' => $request->getCharsets(), 'request_languages' => $request->getLanguages(), 'request_locale' => $request->getLocale(), 'request_auth_user' => $request->getUser(), 'request_auth_has_password' => !is_null($request->getPassword()));
     // Attributes from newer versions.
     if (method_exists($request, 'getEncodings')) {
         $map['request_encodings'] = $request->getEncodings();
     }
     if (method_exists($request, 'getClientIps')) {
         $map['request_client_ips'] = $request->getClientIps();
     }
     return $map;
 }
开发者ID:Hexanet,项目名称:MonologExtraBundle,代码行数:12,代码来源:RequestLogger.php

示例2: logRequest

 protected function logRequest(Request $request)
 {
     $msg = 'Request "{request_method} {request_uri}"';
     $map = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_host' => $request->getHost(), 'request_port' => $request->getPort(), 'request_scheme' => $request->getScheme(), 'request_client_ip' => $request->getClientIp(), 'request_content_type' => $request->getContentType(), 'request_acceptable_content_types' => $request->getAcceptableContentTypes(), 'request_etags' => $request->getETags(), 'request_charsets' => $request->getCharsets(), 'request_languages' => $request->getLanguages(), 'request_locale' => $request->getLocale(), 'request_auth_user' => $request->getUser(), 'request_auth_has_password' => !is_null($request->getPassword()));
     // Attributes from newer versions.
     if (method_exists($request, 'getEncodings')) {
         $map['request_encodings'] = $request->getEncodings();
     }
     if (method_exists($request, 'getClientIps')) {
         $map['request_client_ips'] = $request->getClientIps();
     }
     $this->logger->log($this->logLevel, $msg, $map);
 }
开发者ID:caxy,项目名称:drupal-console-logging-middleware,代码行数:13,代码来源:RequestLoggingMiddleware.php

示例3: validate

 /**
  * Validates that a cache entry is fresh.
  *
  * The original request is used as a template for a conditional
  * GET request with the backend.
  *
  * @param Request  $request A Request instance
  * @param Response $entry   A Response instance to validate
  * @param bool     $catch   Whether to process exceptions
  *
  * @return Response A Response instance
  */
 protected function validate(Request $request, Response $entry, $catch = false)
 {
     $subRequest = clone $request;
     // send no head requests because we want content
     $subRequest->setMethod('GET');
     // add our cached last-modified validator
     $subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
     // Add our cached etag validator to the environment.
     // We keep the etags from the client to handle the case when the client
     // has a different private valid entry which is not cached here.
     $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array();
     $requestEtags = $request->getETags();
     if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
         $subRequest->headers->set('if_none_match', implode(', ', $etags));
     }
     $response = $this->forward($subRequest, $catch, $entry);
     if (304 == $response->getStatusCode()) {
         $this->record($request, 'valid');
         // return the response and not the cache entry if the response is valid but not cached
         $etag = $response->getEtag();
         if ($etag && in_array($etag, $requestEtags) && !in_array($etag, $cachedEtags)) {
             return $response;
         }
         $entry = clone $entry;
         $entry->headers->remove('Date');
         foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) {
             if ($response->headers->has($name)) {
                 $entry->headers->set($name, $response->headers->get($name));
             }
         }
         $response = $entry;
     } else {
         $this->record($request, 'invalid');
     }
     if ($response->isCacheable()) {
         $this->store($request, $response);
     }
     return $response;
 }
开发者ID:nmardones,项目名称:symfony,代码行数:51,代码来源:HttpCache.php

示例4: convertVersion

 /**
  * @param Request $request
  * @param ParamConfiguration $configuration
  * @return integer
  * @throws BadRequestHttpException
  * @throws PreconditionFailedHttpException
  */
 protected function convertVersion(Request $request, ParamConfiguration $configuration)
 {
     $eTags = (array) $request->getETags();
     $eTag = reset($eTags);
     if (empty($eTag)) {
         throw new BadRequestHttpException("Expected version header.");
     }
     $id = $request->attributes->get($configuration->getOptions()['id']);
     $retrieverMethod = $this->inflectRetrieverMethod($configuration);
     $entity = $this->{$retrieverMethod}($id);
     $tag = hash('sha256', $entity->getId() . $entity->getVersion());
     if ($eTag !== $tag) {
         throw new PreconditionFailedHttpException("Expected version does not match actual version.");
     }
     return $entity->getVersion();
 }
开发者ID:EightArmCode,项目名称:librarian,代码行数:23,代码来源:ParamConverter.php


注:本文中的Symfony\Component\HttpFoundation\Request::getETags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。