def get_host(environ):
    scheme = environ.get('wsgi.url_scheme')
    if 'HTTP_X_FORWARDED_HOST' in environ:
        result = environ['HTTP_X_FORWARDED_HOST']
    elif 'HTTP_HOST' in environ:
        result = environ['HTTP_HOST']
    else:
        result = environ['SERVER_NAME']
        if (scheme, str(environ['SERVER_PORT'])) not \
           in (('https', '443'), ('http', '80')):
            result += ':' + environ['SERVER_PORT']
    if result.endswith(':80') and scheme == 'http':
        result = result[:-3]
    elif result.endswith(':443') and scheme == 'https':
        result = result[:-4]
    return result


# `get_current_url` comes from `werkzeug.wsgi`
.
dataset/ETHPy150Open getsentry/raven-python/raven/utils/wsgi.py/get_host--crossover with--dataset/ETHPy150Open GoogleDeveloperExperts/experts-app-backend/services/so_tasks.py/TaskHarvestSO.post