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


PHP Request::getTrustedHeaderName方法代码示例

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


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

示例1: createSubRequest

 /**
  * @param string $uri
  * @param Request $request
  * @return Request
  */
 protected function createSubRequest($uri, Request $request)
 {
     $cookies = $request->cookies->all();
     $server = $request->server->all();
     // Override the arguments to emulate a sub-request.
     // Sub-request object will point to localhost as client ip and real client ip
     // will be included into trusted header for client ip
     try {
         if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
             $currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
             $server['HTTP_' . $trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor . ', ' : '') . $request->getClientIp();
         }
     } catch (\InvalidArgumentException $e) {
         // Do nothing
     }
     $server['REMOTE_ADDR'] = '127.0.0.1';
     $subRequest = TheliaRequest::create($uri, 'get', array(), $cookies, array(), $server);
     if ($request->headers->has('Surrogate-Capability')) {
         $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
     }
     if ($session = $request->getSession()) {
         $subRequest->setSession($session);
     }
     return $subRequest;
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:30,代码来源:InlineFragmentRenderer.php

示例2: testGetTrustedProxiesInvalidHeaderName

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testGetTrustedProxiesInvalidHeaderName()
 {
     Request::create('http://example.com/');
     Request::getTrustedHeaderName('bogus name');
 }
开发者ID:anderson-abc,项目名称:sf2_kowee,代码行数:8,代码来源:RequestTest.php

示例3: testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled

 public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled()
 {
     $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP);
     Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, '');
     $this->testESIHeaderIsKeptInSubrequest();
     Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:7,代码来源:InlineFragmentRendererTest.php

示例4: testESIHeaderIsKeptInSubrequest

 public function testESIHeaderIsKeptInSubrequest()
 {
     $expectedSubRequest = Request::create('/');
     $expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
     if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
         $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
         $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
     }
     $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
     $request = Request::create('/');
     $request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
     $strategy->render('/', $request);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:13,代码来源:InlineFragmentRendererTest.php

示例5: testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest

 public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
 {
     $expectedSubRequest = Request::create('/');
     if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
         $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
         $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
     }
     $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
     $request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
     $strategy->render('/', $request);
 }
开发者ID:ayoah,项目名称:symfony,代码行数:11,代码来源:InlineFragmentRendererTest.php


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