Your IP : 18.117.91.116


Current Path : /opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/wsgi.cpython-37.pyc

B

��Y��@sNdZddlmZddlmZmZdd�Zdd�Zdd	�Zddd�Z	d
d�Z
dS)z�
This module implements WSGI related helpers adapted from ``werkzeug.wsgi``

:copyright: (c) 2010 by the Werkzeug Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_import)�	iteritems�urllib_quoteccsrxlt|�D]`\}}t|�}|�d�rL|dkrL|dd��dd���|fVq
|dkr
|�dd���|fVq
WdS)z+
    Returns only proper HTTP headers.
    ZHTTP_)ZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTH�N�_�-)ZCONTENT_TYPEZCONTENT_LENGTH)r�str�
startswith�replace�title)�environ�key�value�r�A/opt/alt/python37/lib/python3.7/site-packages/raven/utils/wsgi.py�get_headers
s rccs(x"dD]}||kr|||fVqWdS)z8
    Returns our whitelisted environment variables.
    )�REMOTE_ADDR�SERVER_NAME�SERVER_PORTNr)rr
rrr�get_environs
rcCs�|�d�}d|kr|d}n>d|kr.|d}n,|d}|t|d�fdkrZ|d|d7}|�d�rz|d	krz|d
d�}n|�d�r�|d
kr�|d
d�}|S)z�Return the real host for the given WSGI environment.  This takes care
    of the `X-Forwarded-Host` header.

    :param environ: the WSGI environment to get the host of.
    zwsgi.url_schemeZHTTP_X_FORWARDED_HOSTZ	HTTP_HOSTrr))�httpsZ443)�httpZ80�:z:80rN���z:443r���)�getr�endswith)r�scheme�resultrrr�get_host$s


rFcCs�|ddt|�g}|j}|r*d�|�dS|t|�dd��d���|rR|d�n<|td|�dd��d���|s�|�d�}|r�|d|�d�|�S)	a3A handy helper function that recreates the full URL for the current
    request or parts of it.  Here an example:

    >>> from werkzeug import create_environ
    >>> env = create_environ("/?param=foo", "http://localhost/script")
    >>> get_current_url(env)
    'http://localhost/script/?param=foo'
    >>> get_current_url(env, root_only=True)
    'http://localhost/script/'
    >>> get_current_url(env, host_only=True)
    'http://localhost/'
    >>> get_current_url(env, strip_querystring=True)
    'http://localhost/script/'

    :param environ: the WSGI environment to get the current URL from.
    :param root_only: set `True` if you only want the root URL.
    :param strip_querystring: set to `True` if you don't want the querystring.
    :param host_only: set to `True` if the host URL should be returned.
    zwsgi.url_schemez://��/ZSCRIPT_NAMEZ	PATH_INFOZQUERY_STRING�?)r�append�joinrr�rstrip�lstrip)rZ	root_onlyZstrip_querystringZ	host_only�tmp�cat�qsrrr�get_current_url<s

r*c	Cs:y|d�d�d��Sttfk
r4|�d�SXdS)z�
    Naively yank the first IP address in an X-Forwarded-For header
    and assume this is correct.

    Note: Don't use this in security sensitive situations since this
    value may be forged from a client.
    ZHTTP_X_FORWARDED_FOR�,rrN)�split�strip�KeyError�
IndexErrorr)rrrr�
get_client_ipasr0N)FFF)�__doc__�
__future__rZraven.utils.compatrrrrrr*r0rrrr�<module>s


$

?>