コード例 #1
0
 public function testGetForwardedIp()
 {
     $uri = Uri::createFromString('https://example.com:443/foo/bar?abc=123');
     $env = Environment::mock(['HTTP_X_FORWARDED_FOR' => '192.168.1.3, 192.168.1.2, 192.168.1.1']);
     $headers = Headers::createFromEnvironment($env);
     $cookies = [];
     $serverParams = $env->all();
     $body = new RequestBody();
     $request = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
     $this->assertEquals('192.168.1.3', $request->getIp());
 }