當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::setServer方法代碼示例

本文整理匯總了PHP中Zend\Http\PhpEnvironment\Request::setServer方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::setServer方法的具體用法?PHP Request::setServer怎麽用?PHP Request::setServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Http\PhpEnvironment\Request的用法示例。


在下文中一共展示了Request::setServer方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRequest

 public static function getRequest()
 {
     if (!isset(self::$serverParams)) {
         self::$serverParams = ['HTTP_X_FORWARDED_FOR' => '192.168.1.1', 'HTTP_CLIENT_IP' => '192.168.1.1', 'REMOTE_ADDR' => '192.168.1.1'];
     }
     $httpRequest = new HttpRequest();
     $httpRequest->setServer(new Parameters(self::$serverParams));
     return $httpRequest;
 }
開發者ID:dollyaswin,項目名稱:pyro,代碼行數:9,代碼來源:Request.php

示例2: testAssembleWithPort

 public function testAssembleWithPort()
 {
     $params = new Parameters(array('SERVER_NAME' => 'test.co.uk', 'SERVER_PORT' => 8080));
     $request = new Request();
     $request->setServer($params);
     $event = new LocaleEvent();
     $event->setLocale('de_DE');
     $event->setUri(new Uri('http://test.co.uk'));
     $event->setRequest($request);
     $strategy = new HostStrategy();
     $strategy->setOptions(array('domain' => 'test.:locale', 'aliases' => array('de' => 'de_DE', 'co.uk' => 'en_GB')));
     $result = $strategy->assemble($event)->getHost();
     $this->assertSame('test.de:8080', $result);
 }
開發者ID:SoufianeAr,項目名稱:SlmLocale,代碼行數:14,代碼來源:HostStrategyTest.php

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

示例4: testCheckRedirectsNoRedirectFound

 /**
  * Test Check Redirects Redirect Not Found
  *
  * @return void
  *
  * @covers \Rcm\EventListener\RouteListener
  */
 public function testCheckRedirectsNoRedirectFound()
 {
     $serverParams = new Parameters(['HTTP_HOST' => 'reliv.com', 'REQUEST_URI' => '/no-redirect']);
     $request = new Request();
     $request->setServer($serverParams);
     $event = new MvcEvent();
     $event->setRequest($request);
     $actual = $this->routeListener->checkRedirect($event);
     $this->assertFalse($actual instanceof Response);
     $this->assertEmpty($actual);
 }
開發者ID:reliv,項目名稱:Rcm,代碼行數:18,代碼來源:RouteListenerTest.php


注:本文中的Zend\Http\PhpEnvironment\Request::setServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。