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


PHP Headers::has方法代码示例

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


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

示例1: testHeadersHasAndGetWorkProperly

 public function testHeadersHasAndGetWorkProperly()
 {
     $headers = new Headers();
     $headers->addHeaders(array($f = new Header\GenericHeader('Foo', 'bar'), new Header\GenericHeader('Baz', 'baz')));
     $this->assertFalse($headers->has('foobar'));
     $this->assertTrue($headers->has('foo'));
     $this->assertTrue($headers->has('Foo'));
     $this->assertSame($f, $headers->get('foo'));
 }
开发者ID:JojoBombardo,项目名称:zf2,代码行数:9,代码来源:HeadersTest.php

示例2: validateMediaType

 /**
  * Validate the passed mediatype against the appropriate header
  *
  * @param  string $match
  * @param  HttpHeaders $headers
  * @return bool
  */
 protected function validateMediaType($match, HttpHeaders $headers)
 {
     if (!$headers->has('accept')) {
         return true;
     }
     $accept = $headers->get('accept');
     if ($accept->match($match)) {
         return true;
     }
     return false;
 }
开发者ID:antarus,项目名称:mystra-pve,代码行数:18,代码来源:AcceptFilterListener.php

示例3: getBrowseAcceptLanguage

 /**
  * @param Headers $headers
  *
  * @return string|null
  */
 private function getBrowseAcceptLanguage(Headers $headers)
 {
     if ($headers->has('Accept-Language')) {
         /** @var AcceptLanguage $acceptLanguageHeader */
         $acceptLanguageHeader = $headers->get('Accept-Language');
         $locales = $acceptLanguageHeader->getPrioritized();
         $languages = $this->config->getAvailableLanguages();
         /** @var LanguageFieldValuePart $locale */
         foreach ($locales as $locale) {
             // Loop through all locales, highest priority first
             if ($browserLang = \Locale::lookup($languages, $locale->getRaw())) {
                 return $browserLang;
             }
         }
     }
     return null;
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:22,代码来源:LangRecognizer.php

示例4: getStreamPath

 /**
  * @param Headers $headers
  *
  * @return \SplFileInfo
  */
 public function getStreamPath(Headers $headers)
 {
     $filename = null;
     $directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid();
     if (!file_exists($directory)) {
         mkdir($directory, 0775, true);
     }
     if (!$this->filename) {
         if ($headers->has('content-disposition')) {
             $field = $headers->get('content-disposition')->getFieldValue();
             if (preg_match('`filename\\="(.*)"`', $field, $matches)) {
                 $this->filename = basename($matches[1]);
             }
         }
         if (null === $filename) {
             $this->filename = uniqid();
         }
     }
     return new \SplFileInfo($directory . DIRECTORY_SEPARATOR . $this->filename);
 }
开发者ID:continuousphp,项目名称:deploy-agent,代码行数:25,代码来源:Http.php

示例5: getHeaderType

 /**
  * Get the mediatype from a given header
  *
  * @param  \Zend\Http\Headers $headers
  * @param  string $header
  * @return string
  */
 protected function getHeaderType($headers, $header)
 {
     if (!$headers->has($header)) {
         return 'application/json';
     }
     $accept = $headers->get($header);
     $value = $accept->getFieldValue();
     $value = explode(';', $value, 2);
     $accept = array_shift($value);
     $accept = strtolower(trim($accept));
     switch ($accept) {
         case 'application/json':
         case 'application/vnd.zfcampus.v1.config+json':
             return $accept;
         default:
             return 'application/json';
     }
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:25,代码来源:AbstractConfigController.php

示例6: setVary

 /**
  * @param  Headers $headers
  * @return self
  */
 public function setVary(Headers $headers)
 {
     if (!empty($this->cacheConfig['vary']['value']) && (!empty($this->cacheConfig['vary']['override']) || !$headers->has('vary'))) {
         $vary = new Header\Vary($this->cacheConfig['vary']['value']);
         $headers->addHeader($vary);
     }
     return $this;
 }
开发者ID:zfcampus,项目名称:zf-http-cache,代码行数:12,代码来源:HttpCacheListener.php


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