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


PHP HeaderBag::get方法代码示例

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


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

示例1: it_will_create_event_from_request

 public function it_will_create_event_from_request(Request $request, HeaderBag $headerBag)
 {
     $request->headers = $headerBag;
     $headerBag->get('X-GitHub-Event')->willReturn('push');
     $headerBag->get('X-Hub-Signature')->willReturn('sha1=abc123');
     $this->create($request)->shouldReturnAnInstanceOf('DevBoard\\Notify\\Event');
 }
开发者ID:devboard,项目名称:devboard-notify,代码行数:7,代码来源:EventFactorySpec.php

示例2: it_will_create_pull_request_event

 public function it_will_create_pull_request_event($signatureFactory, WebHookSignature $signature, Request $request, HeaderBag $headerBag)
 {
     $request->headers = $headerBag;
     $headerBag->get('X-GitHub-Event')->willReturn('pull_request');
     $headerBag->get('X-Hub-Signature')->willReturn('sha1=abc123');
     $signatureFactory->create('sha1=abc123')->willReturn($signature);
     $request->getContent()->willReturn('{}');
     $this->create($request)->shouldReturnAnInstanceOf('DevBoard\\Github\\WebHook\\Data\\PullRequestEvent');
 }
开发者ID:brankol,项目名称:devboard,代码行数:9,代码来源:WebHookFactorySpec.php

示例3: prepareRequestUri

 protected function prepareRequestUri()
 {
     $requestUri = '';
     if ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) {
         // check this first so IIS will catch
         $requestUri = $this->headers->get('X_REWRITE_URL');
     } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
         // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
         $requestUri = $this->server->get('UNENCODED_URL');
     } elseif ($this->server->has('REQUEST_URI')) {
         $requestUri = $this->server->get('REQUEST_URI');
         // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
         $schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();
         if (strpos($requestUri, $schemeAndHttpHost) === 0) {
             $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
         }
     } elseif ($this->server->has('ORIG_PATH_INFO')) {
         // IIS 5.0, PHP as CGI
         $requestUri = $this->server->get('ORIG_PATH_INFO');
         if ($this->server->get('QUERY_STRING')) {
             $requestUri .= '?' . $this->server->get('QUERY_STRING');
         }
     }
     return $requestUri;
 }
开发者ID:krisldz,项目名称:Gekosale2,代码行数:25,代码来源:Request.php

示例4:

 function it_gets_an_item_from_the_header(Request $request, HeaderBag $headerBag)
 {
     $item = 'foo';
     $return = 'bar';
     $request->headers = $headerBag;
     $headerBag->get($item)->shouldBeCalled(1)->willReturn($return);
     $this->header($item)->shouldReturn($return);
 }
开发者ID:larapackage,项目名称:api,代码行数:8,代码来源:ParserSpec.php

示例5:

 function it_invalidates_signature(Request $request, HeaderBag $headers)
 {
     $headers->get('X-Shopify-Hmac-Sha256')->willReturn(self::HMAC_HEADER_WRONG)->shouldbeCalled();
     $request->headers = $headers;
     $request->getContent()->willReturn(self::DATA)->shouldbeCalled();
     $this->setHttpRequest($request);
     $this->verify()->shouldBeBool();
     $this->verify()->shouldReturn(false);
 }
开发者ID:loicm,项目名称:shopify-webhook,代码行数:9,代码来源:WebHookSpec.php

示例6: testGet

 /**
  * @covers Symfony\Component\HttpFoundation\HeaderBag::get
  */
 public function testGet()
 {
     $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz'));
     $this->assertEquals('bar', $bag->get('foo'), '->get return current value');
     $this->assertEquals('bar', $bag->get('FoO'), '->get key in case insensitive');
     $this->assertEquals(array('bar'), $bag->get('foo', 'nope', false), '->get return the value as array');
     // defaults
     $this->assertNull($bag->get('none'), '->get unknown values returns null');
     $this->assertEquals('default', $bag->get('none', 'default'), '->get unknown values returns default');
     $this->assertEquals(array('default'), $bag->get('none', 'default', false), '->get unknown values returns default as array');
     $bag->set('foo', 'bor', false);
     $this->assertEquals('bar', $bag->get('foo'), '->get return first value');
     $this->assertEquals(array('bar', 'bor'), $bag->get('foo', 'nope', false), '->get return all values as array');
 }
开发者ID:rsky,项目名称:symfony,代码行数:17,代码来源:HeaderBagTest.php

示例7: let

 public function let(AngularCsrfTokenManager $tokenManager, RouteMatcherInterface $routeMatcher, Request $secureValidRequest, Request $secureInvalidRequest, Request $unsecureRequest, HeaderBag $validHeaders, HeaderBag $invalidHeaders)
 {
     $tokenManager->isTokenValid(self::VALID_TOKEN)->willReturn(true);
     $tokenManager->isTokenValid(self::INVALID_TOKEN)->willReturn(false);
     $this->secureValidRequest = $secureValidRequest;
     $validHeaders->get(self::HEADER_NAME)->willReturn(self::VALID_TOKEN);
     $this->secureValidRequest->headers = $validHeaders;
     $this->secureInvalidRequest = $secureInvalidRequest;
     $invalidHeaders->get(self::HEADER_NAME)->willReturn(self::INVALID_TOKEN);
     $this->secureInvalidRequest->headers = $invalidHeaders;
     $this->unsecureRequest = $unsecureRequest;
     $routeMatcher->match($this->secureValidRequest, $this->routes)->willReturn(true);
     $routeMatcher->match($this->secureInvalidRequest, $this->routes)->willReturn(true);
     $routeMatcher->match($this->unsecureRequest, $this->routes)->willReturn(false);
     $this->beConstructedWith($tokenManager, $routeMatcher, $this->routes, self::HEADER_NAME);
 }
开发者ID:AbdoulNdiaye,项目名称:DunglasAngularCsrfBundle,代码行数:16,代码来源:AngularCsrfValidationListenerSpec.php

示例8: validateField

 /**
  * Verifies that the provided header has the expected/mandatory fields.
  *
  * @param ParameterBag|HeaderBag $header    object representation of the request header.
  * @param string                 $fieldName Name of the header field to be validated.
  *
  * @return void
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 protected function validateField($header, $fieldName)
 {
     $passed = $header->has($fieldName);
     // return without exception so we can return a dummy user
     if (true === $passed) {
         // get rid of anything not a valid character
         $authInfo = filter_var($header->get($fieldName), FILTER_SANITIZE_STRING);
         // get rid of whitespaces
         $patterns = array("\r\n", "\n", "\r", "\\s", "\t");
         $authInfo = str_replace($patterns, "", trim($authInfo));
         // get rid of control characters
         if (empty($authInfo) || $authInfo !== preg_replace('#[[:cntrl:]]#i', '', $authInfo)) {
             throw new HttpException(Response::HTTP_NETWORK_AUTHENTICATION_REQUIRED, 'Mandatory header field (' . $fieldName . ') not provided or invalid.');
         }
     }
 }
开发者ID:alebon,项目名称:graviton,代码行数:25,代码来源:AbstractHttpStrategy.php

示例9: prepareRequestUri

 protected function prepareRequestUri()
 {
     $requestUri = '';
     if ($this->headers->has('X_ORIGINAL_URL')) {
         // IIS with Microsoft Rewrite Module
         $requestUri = $this->headers->get('X_ORIGINAL_URL');
         $this->headers->remove('X_ORIGINAL_URL');
         $this->server->remove('HTTP_X_ORIGINAL_URL');
         $this->server->remove('UNENCODED_URL');
         $this->server->remove('IIS_WasUrlRewritten');
     } elseif ($this->headers->has('X_REWRITE_URL')) {
         // IIS with ISAPI_Rewrite
         $requestUri = $this->headers->get('X_REWRITE_URL');
         $this->headers->remove('X_REWRITE_URL');
     } elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
         // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
         $requestUri = $this->server->get('UNENCODED_URL');
         $this->server->remove('UNENCODED_URL');
         $this->server->remove('IIS_WasUrlRewritten');
     } elseif ($this->server->has('REQUEST_URI')) {
         $requestUri = $this->server->get('REQUEST_URI');
         // HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
         $schemeAndHttpHost = $this->getSchemeAndHttpHost();
         if (strpos($requestUri, $schemeAndHttpHost) === 0) {
             $requestUri = substr($requestUri, strlen($schemeAndHttpHost));
         }
     } elseif ($this->server->has('ORIG_PATH_INFO')) {
         // IIS 5.0, PHP as CGI
         $requestUri = $this->server->get('ORIG_PATH_INFO');
         if ('' != $this->server->get('QUERY_STRING')) {
             $requestUri .= '?' . $this->server->get('QUERY_STRING');
         }
         $this->server->remove('ORIG_PATH_INFO');
     }
     // normalize the request URI to ease creating sub-requests from this request
     $this->server->set('REQUEST_URI', $requestUri);
     return $requestUri;
 }
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:38,代码来源:Request.php

示例10: testCacheControlDirectiveParsing

 public function testCacheControlDirectiveParsing()
 {
     $bag = new HeaderBag(array('cache-control' => 'public, max-age=10'));
     $this->assertTrue($bag->hasCacheControlDirective('public'));
     $this->assertTrue($bag->getCacheControlDirective('public'));
     $this->assertTrue($bag->hasCacheControlDirective('max-age'));
     $this->assertEquals(10, $bag->getCacheControlDirective('max-age'));
     $bag->addCacheControlDirective('s-maxage', 100);
     $this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control'));
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:10,代码来源:HeaderBagTest.php

示例11: isRedirected

 public function isRedirected($location)
 {
     return $this->isRedirect() && $location == $this->headers->get('Location');
 }
开发者ID:rsky,项目名称:symfony,代码行数:4,代码来源:Response.php

示例12: getTagsFromHeaders

 /**
  * Retrieve and decode the tag list from the response
  * headers.
  *
  * If no tags header is found then throw a \RuntimeException.
  * If the JSON is invalid then throw a \RuntimeException
  *
  * @param HeaderBag $headers
  *
  * @throws \RuntimeException
  *
  * @return string[]
  */
 private function getTagsFromHeaders(HeaderBag $headers)
 {
     $tagsRaw = $headers->get($this->options['header_tags']);
     $tags = $this->decodeTags($tagsRaw, true);
     return $tags;
 }
开发者ID:dantleech,项目名称:sf-http-cache-tagging,代码行数:19,代码来源:TaggingHandler.php

示例13: getHeader

 /**
  * @param string $name
  *
  * @return array|string
  */
 public function getHeader($name)
 {
     return $this->headers->get($name);
 }
开发者ID:treehouselabs,项目名称:swift-client,代码行数:9,代码来源:Container.php

示例14: pjax

 /**
  * Determine if the request is the result of an PJAX call.
  *
  * @return bool
  */
 public function pjax()
 {
     return $this->headers->get('X-PJAX') == true;
 }
开发者ID:bearlord,项目名称:kantphp2,代码行数:9,代码来源:Request.php

示例15: getProgramByOrigin

 protected function getProgramByOrigin(HeaderBag $headers)
 {
     $program = null;
     if ($headers->has('Origin')) {
         $host = parse_url($headers->get('Origin'), PHP_URL_HOST);
         /** @var \Petrosoft\LoyaltyBundle\Models\FrontSiteSettings\Collection $siteCol */
         $siteCol = $this->meetz->collection('Loyalty:Models\\FrontSiteSettings');
         $siteCol->addFieldToFilter('hosts', array($host), 'in');
         $siteSettings = $siteCol->getFirstItem();
         if (!$siteSettings->isObjectNew()) {
             $program = $siteSettings->getData('loyalty_program_id');
             if ($program instanceof \MongoId) {
                 $program = $program->{'$id'};
             }
         }
     }
     return $program;
 }
开发者ID:bagermen,项目名称:Examples,代码行数:18,代码来源:FrontSiteControllersListener.php


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