本文整理汇总了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'));
}
示例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;
}
示例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;
}
示例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);
}
示例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';
}
}
示例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;
}