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


PHP HttpFoundation\HeaderBag类代码示例

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


在下文中一共展示了HeaderBag类的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:

 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

示例3: fixAuthHeader

 /**
  * PHP does not include HTTP_AUTHORIZATION in the $_SERVER array, so this header is missing.
  * We retrieve it from apache_request_headers()
  *
  * @see https://github.com/symfony/symfony/issues/7170
  *
  * @param HeaderBag $headers
  */
 private static function fixAuthHeader(\Symfony\Component\HttpFoundation\HeaderBag $headers)
 {
     if (!$headers->has('Authorization') && function_exists('apache_request_headers')) {
         $all = apache_request_headers();
         if (isset($all['Authorization'])) {
             $headers->set('Authorization', $all['Authorization']);
         }
     }
 }
开发者ID:vzailskas,项目名称:oauth2-server-httpfoundation-bridge,代码行数:17,代码来源:Request.php

示例4: 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

示例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: formatHeaders

 private function formatHeaders(HeaderBag $headerBag)
 {
     $headers = $headerBag->all();
     $content = '';
     foreach ($headers as $name => $values) {
         $name = implode('-', array_map('ucfirst', explode('-', $name)));
         foreach ($values as $value) {
             $content .= sprintf("%s %s; ", $name . ':', $value);
         }
     }
     return $content;
 }
开发者ID:vesax,项目名称:http-kernel-logger-bundle,代码行数:12,代码来源:Formatter.php

示例7: fixAuthHeader

 /**
  * PHP does not include HTTP_AUTHORIZATION in the $_SERVER array, so this header is missing.
  * We retrieve it from apache_request_headers()
  *
  * @param HeaderBag $headers
  */
 protected function fixAuthHeader(HeaderBag $headers)
 {
     if (!$headers->has('Authorization') && function_exists('apache_request_headers')) {
         $all = apache_request_headers();
         if (isset($all['Authorization'])) {
             $headers->set('Authorization', $all['Authorization']);
         }
         if (isset($all['authorization'])) {
             $headers->set('Authorization', $all['authorization']);
         }
     }
 }
开发者ID:profcab,项目名称:ilios,代码行数:18,代码来源:AuthenticationHeader.php

示例8: persistHeaders

 /**
  * Creates an array of cacheable and normalized request headers
  *
  * @param HeaderBag $headers
  * @return array
  */
 private function persistHeaders(HeaderBag $headers)
 {
     // Headers are excluded from the caching (see RFC 2616:13.5.1)
     static $noCache = array('age', 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailers', 'transfer-encoding', 'upgrade', 'set-cookie', 'set-cookie2');
     foreach ($headers as $key => $value) {
         if (in_array($key, $noCache) || strpos($key, 'x-') === 0) {
             $headers->remove($key);
         }
     }
     // Postman client sends a dynamic token to bypass a Chrome bug
     $headers->remove('postman-token');
     return $headers;
 }
开发者ID:stadline,项目名称:execution-cache-bundle,代码行数:19,代码来源:KeyProvider.php

示例9: testContains

 /**
  * @covers Symfony\Component\HttpFoundation\HeaderBag::contains
  */
 public function testContains()
 {
     $bag = new HeaderBag(array('foo' => 'bar', 'fuzz' => 'bizz'));
     $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
     $this->assertTrue($bag->contains('fuzz', 'bizz'), '->contains second value');
     $this->assertFalse($bag->contains('nope', 'nope'), '->contains unknown value');
     $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');
     // Multiple values
     $bag->set('foo', 'bor', false);
     $this->assertTrue($bag->contains('foo', 'bar'), '->contains first value');
     $this->assertTrue($bag->contains('foo', 'bor'), '->contains second value');
     $this->assertFalse($bag->contains('foo', 'nope'), '->contains unknown value');
 }
开发者ID:rsky,项目名称:symfony,代码行数:16,代码来源:HeaderBagTest.php

示例10: 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

示例11: 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

示例12: function

 function it_handles_communication_logging(CommunicationLogger $logger, CommunicationExtractor $extractor, Request $request, Response $response, HeaderBag $requestHeaders, IEvent $event)
 {
     $request->getMethod()->shouldBeCalled()->willReturn('POST');
     $request->getContent()->shouldBeCalled()->willReturn('request');
     $request->getUri()->shouldBeCalled()->willReturn('http://example.com');
     $request->headers = $requestHeaders;
     $requestHeaders->all()->shouldBeCalled()->willReturn([]);
     $next = function (Request $request) use($response) {
         return new Response();
     };
     $extractor->getRequest(Argument::type(GuzzleRequest::class))->shouldBeCalled()->willReturn(['request' => 'request']);
     $extractor->getResponse(Argument::type(GuzzleResponse::class))->shouldBeCalled()->willReturn(['response' => 'response']);
     $logger->begin('request', 'http://example.com', 'POST', '')->shouldBeCalled()->willReturn($event);
     $logger->end($event, 'response')->shouldBeCalled();
     $this->handle($request, $next);
 }
开发者ID:rawphp,项目名称:laravel-communication-logger,代码行数:16,代码来源:CommunicationLogSpec.php

示例13: testCacheControlDirectiveOverrideWithReplace

 public function testCacheControlDirectiveOverrideWithReplace()
 {
     $bag = new HeaderBag(array('cache-control' => 'private, max-age=100'));
     $bag->replace(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'));
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:9,代码来源:HeaderBagTest.php

示例14: 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

示例15: createRequestMock

 /**
  * @return \Symfony\Component\HttpFoundation\Request
  */
 private function createRequestMock(array $headers = null)
 {
     $headers = $this->mergeHeaders($headers);
     $headerBag = new HeaderBag();
     $headerBag->add($headers);
     $fakeReq = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->disableOriginalConstructor()->getMock();
     $fakeReq->headers = $headerBag;
     return $fakeReq;
 }
开发者ID:amyboyd,项目名称:overwatch,代码行数:12,代码来源:ApiAuthenticatorTest.php


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