當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。