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


PHP Request::getHeaders方法代码示例

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


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

示例1: headers

 /**
  * @param string $name
  * @param mixed $default
  * @return mixed
  */
 public function headers($name, $default = null)
 {
     //The RequestInterface expects this method to also return PHP_AUTH variables
     if (strpos($name, 'PHP_AUTH_') === 0) {
         return $this->server($name, $default);
     }
     $header = $this->httpRequest->getHeaders($name);
     if (!$header) {
         return $default;
     }
     return $header->getFieldValue();
 }
开发者ID:VictorAlencar,项目名称:zf2-oauth2-provider,代码行数:17,代码来源:RequestAdapter.php

示例2: testHeadersWithMinus

 /**
  * @dataProvider serverHeaderProvider
  * @param array  $server
  * @param string $name
  * @param string $value
  */
 public function testHeadersWithMinus(array $server, $name, $value)
 {
     $_SERVER = $server;
     $request = new Request();
     $header = $request->getHeaders()->get($name);
     $this->assertNotEquals($header, false);
     $this->assertEquals($name, $header->getFieldName($value));
     $this->assertEquals($value, $header->getFieldValue($value));
 }
开发者ID:navassouza,项目名称:zf2,代码行数:15,代码来源:RequestTest.php

示例3: checkHeader

 private function checkHeader()
 {
     foreach (parent::getHeaders() as $header) {
         $name = $header->getFieldName();
         $value = $header->getFieldValue();
         $name = $this->headerToParam($name);
         $this->headerParameters[$name] = $value;
     }
 }
开发者ID:rockeinstein,项目名称:library,代码行数:9,代码来源:ApiRequestImp.php

示例4: getBrowserLocale

 /**
  * Detect language by browser headers
  *
  * @return string
  */
 private function getBrowserLocale()
 {
     $locales = $this->request->getHeaders('Accept-Language')->getPrioritized();
     foreach ($locales as $lng) {
         if (in_array($lng->type, $this->getAvailableLocales())) {
             return $lng->type;
         }
     }
     return Config::$lng;
 }
开发者ID:waydelyle,项目名称:mobicms,代码行数:15,代码来源:Locales.php

示例5: createFromRequest

 public static function createFromRequest(BaseRequest $request)
 {
     $new = static::fromString($request->toString());
     $new->setQuery($request->getQuery());
     $new->setPost($request->getPost());
     $new->setCookies($request->getCookie());
     $new->setFiles($request->getFiles());
     $new->setServer($request->getServer());
     $new->setContent($request->getContent());
     $new->setEnv($request->getEnv());
     $headers = $request->getHeaders();
     $new->setHeaders($headers);
     return $new;
 }
开发者ID:diablomedia,项目名称:oauth2-server-zendhttp-bridge,代码行数:14,代码来源:Request.php

示例6: _getBasicAuthData

 /**
  * fetch basic auth credentials
  * 
  * @param  \Zend\Http\PhpEnvironment\Request  $request
  * @return array
  */
 protected function _getBasicAuthData(\Zend\Http\PhpEnvironment\Request $request)
 {
     if ($header = $request->getHeaders('Authorization')) {
         return explode(":", base64_decode(substr($header->getFieldValue(), 6)), 2);
     } elseif ($header = $request->getServer('HTTP_AUTHORIZATION')) {
         return explode(":", base64_decode(substr($header, 6)), 2);
     } else {
         // check if (REDIRECT_)*REMOTE_USER is found in SERVER vars
         $name = 'REMOTE_USER';
         for ($i = 0; $i < 5; $i++) {
             if ($header = $request->getServer($name)) {
                 return explode(":", base64_decode(substr($header, 6)), 2);
             }
             $name = 'REDIRECT_' . $name;
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:23,代码来源:Abstract.php

示例7: write

 /**
  * Запись логов
  * @param Request $request
  * @param Response $response
  */
 public function write($request, $response)
 {
     $serverOptions = $request->getServer()->toArray();
     $requestUri = isset($serverOptions['REQUEST_URI']) ? $serverOptions['REQUEST_URI'] : null;
     // Проверка на запись от правильного запроса
     if (is_null($requestUri) || !preg_match($this->_patternRequestWriteLog, $requestUri)) {
         return;
     }
     $remoteAddr = isset($serverOptions['REMOTE_ADDR']) ? $serverOptions['REMOTE_ADDR'] : '';
     $requestTime = isset($serverOptions['REQUEST_TIME']) ? $serverOptions['REQUEST_TIME'] : 0;
     $requestTimeFloat = isset($serverOptions['REQUEST_TIME_FLOAT']) ? $serverOptions['REQUEST_TIME_FLOAT'] : 0;
     /** @var DocumentManager $dm */
     $dm = $this->getServiceLocator()->get('doctrine-document');
     $logsClient = new LogsClient();
     $logsClient->setDatetime((new \DateTime())->setTimestamp($requestTime))->setHeaders($request->getHeaders()->toString())->setRequest($request->getContent())->setResponse($response->getContent())->setIpAddress($remoteAddr)->setDuration(round(microtime(true), 4) - $requestTimeFloat);
     $dm->persist($logsClient);
     $dm->flush();
 }
开发者ID:lexx7,项目名称:course,代码行数:23,代码来源:Logs.php

示例8: testRetrievingASingleValueForParameters

 public function testRetrievingASingleValueForParameters()
 {
     $request = new Request();
     $p = new \Zend\Stdlib\Parameters(array('foo' => 'bar'));
     $request->setQuery($p);
     $request->setPost($p);
     $request->setFiles($p);
     $request->setServer($p);
     $request->setEnv($p);
     $this->assertSame('bar', $request->getQuery('foo'));
     $this->assertSame('bar', $request->getPost('foo'));
     $this->assertSame('bar', $request->getFiles('foo'));
     $this->assertSame('bar', $request->getServer('foo'));
     $this->assertSame('bar', $request->getEnv('foo'));
     $headers = new Headers();
     $h = new GenericHeader('foo', 'bar');
     $headers->addHeader($h);
     $request->setHeaders($headers);
     $this->assertSame($headers, $request->getHeaders());
     $this->assertSame($h, $request->getHeaders()->get('foo'));
     $this->assertSame($h, $request->getHeader('foo'));
 }
开发者ID:Rovak,项目名称:zf2,代码行数:22,代码来源:RequestTest.php

示例9: testRecognize_WhenShouldRedirectToRecognizedLanguageIsEnabled

 /**
  * @dataProvider dataProviderForTestRecognize_WhenShouldRedirectToRecognizedLanguageIsEnabled
  *
  * @param string $browserLangLocale
  * @param string $routeMatchLang
  * @param array  $expectedResult
  */
 public function testRecognize_WhenShouldRedirectToRecognizedLanguageIsEnabled($browserLangLocale, $routeMatchLang, $expectedResult)
 {
     $this->prepareTestedObject($this->prepareConfig(true));
     $request = new Request();
     $request->getHeaders()->addHeaderLine('Accept-Language', $browserLangLocale);
     $paramsBefore = ['__NAMESPACE__' => 'Module\\Some', 'controller' => 'TestController', 'action' => 'index', 'lang' => $routeMatchLang, '__CONTROLLER__' => 'test'];
     $routeMatch = new RouteMatch($paramsBefore);
     $matchedRouteName = 'some\\test';
     $routeMatch->setMatchedRouteName($matchedRouteName);
     $event = new MvcEvent();
     $event->setRequest($request);
     $event->setResponse(new Response());
     $event->setRouteMatch($routeMatch);
     $result = $this->testedObject->recognize($event);
     $this->assertSame($expectedResult, $result);
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:23,代码来源:LangRecognizerTest.php


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