public function testCanSpecifyWhichHeaderToUseStatically() { $this->backup(); $_SERVER['REMOTE_ADDR'] = '0.1.2.3'; $_SERVER['HTTP_X_FORWARDED_FOR'] = '2.1.2.3, 1.1.2.3'; $_SERVER['HTTP_CLIENT_IP'] = '0.1.2.4'; RemoteAddr::setUseProxy(true); RemoteAddr::setProxyHeader('Client-Ip'); $validator = new RemoteAddr(); $this->assertEquals('0.1.2.4', $validator->getData()); $this->restore(); }
public function testMultipleHttpXForwardedFor() { $this->backup(); $_SERVER['REMOTE_ADDR'] = '0.1.2.3'; $_SERVER['HTTP_X_FORWARDED_FOR'] = '2.1.2.3, 1.1.2.3'; RemoteAddr::setUseProxy(true); $validator = new RemoteAddr(); RemoteAddr::setUseProxy(false); $this->assertEquals('2.1.2.3', $validator->getData()); $this->restore(); }