本文整理汇总了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;
}
示例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);
}
示例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'));
}
示例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);
}