AlkantarClanX12
Current Path : /opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/ |
Current File : //opt/alt/python37/lib/python3.7/site-packages/raven/utils/__pycache__/wsgi.cpython-37.pyc |
B ��Y� � @ sN d Z ddlmZ ddlmZmZ dd� 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_quotec c sr xlt | �D ]`\}}t|�}|�d�rL|dkrL|dd� �dd��� |fV q |dkr |�dd��� |fV q W dS )z+ Returns only proper HTTP headers. ZHTTP_)ZHTTP_CONTENT_TYPEZHTTP_CONTENT_LENGTH� N�_�-)ZCONTENT_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 r c c s( x"dD ]}|| kr|| | fV qW dS )z8 Returns our whitelisted environment variables. )�REMOTE_ADDR�SERVER_NAME�SERVER_PORTNr )r r r r r �get_environ s r c C s� | � d�}d| kr| d }n>d| kr.| d }n,| d }|t| d �fdkrZ|d| d 7 }|�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_HOSTr r ))�httpsZ443)�httpZ80�:z:80r N���z:443r ���)�getr �endswith)r �scheme�resultr r r �get_host$ s r Fc C s� | d dt | �g}|j}|r*d�|�d S |t| �dd��d��� |rR|d� n<|td| �dd��d� �� |s�| �d�}|r�|d| � d�|�S ) a3 A 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_INFOZQUERY_STRING�?)r �append�joinr r �rstrip�lstrip)r Z root_onlyZstrip_querystringZ host_only�tmp�cat�qsr r r �get_current_url<