def get_client_ip_address(request):
    """Returns the IP address of the host which sent the
    request initally.
    """
    ips = request.environ.get('HTTP_X_FORWARDED_FOR', request.environ.get(
        'REMOTE_ADDR'))
    if ips is None:
        return ''
    elif not hasattr(ips, 'split'):
        return ips
    else:
        return ips.split(',')[0].strip()
