Pylons/webob — Issue #8: feature requests: host_port and client_addr
Author: mcdonc
Created: 2011-10-27 23:23:13+00:00
State: open

I'd like these features as methods of the request. What do you think Sergey?

```python

@property
def host_port(self):
"""
The port in the URL
"""
e = self.environ
if e.get('HTTP_HOST'):
host = e['HTTP_HOST']
if ':' in host:
host, port = host.split(':', 1)
else:
port = '80'
else:
port = e['SERVER_PORT']
return port
```

and

```python

@property
def client_addr(self):
e = self.environ
xff = e.get('HTTP_X_FORWARDED_FOR')
if xff is not None:
addr = xff.split(',')[0].strip()
else:
addr = e.get('REMOTE_ADDR')
return addr
```