ZF-7092: Add a method to retrieve the remote IP


Having a method in the HTTP request object to get the client's IP would be really useful. Proposed method:

public function getClientIp()
    if (!empty($this->getServer('HTTP_CLIENT_IP'))) {
        $ip = $this->getServer('HTTP_CLIENT_IP');
    } else if (!empty($this->getServer('HTTP_X_FORWARDED_FOR'))) {
        $ip = $this->getServer('HTTP_X_FORWARDED_FOR');
    } else {
        $ip = $this->getServer('REMOTE_ADDR');

    return $ip;


Assigning back to Jurrien, as he knows the implementation desired. :) Please don't forget to write tests for the functionality. :)

Resolved in r16267. Merged to release-1.8 in r16268

Is not under "IP address spoofing"?

please check.Similar issue - cakephp's