Your IP : 3.12.153.240


Current Path : /opt/alt/python27/lib/python2.7/site-packages/raven/utils/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pyc

�
��Yc@@sfdZddlmZddlmZmZd�Zd�Zd�Ze	e	e	d�Z
d�Zd	S(
s�
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.
i(tabsolute_import(t	iteritemsturllib_quotecc@s�x�t|�D]�\}}t|�}|jd�rd|d
krd|djdd�j�|fVq
|dkr
|jdd�j�|fVq
q
Wd	S(s+
    Returns only proper HTTP headers.
    tHTTP_tHTTP_CONTENT_TYPEtHTTP_CONTENT_LENGTHit_t-tCONTENT_TYPEtCONTENT_LENGTHN(RR(RR	(Rtstrt
startswithtreplacettitle(tenvirontkeytvalue((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pytget_headers
s	$cc@s3x,dD]$}||kr|||fVqqWdS(s8
    Returns our whitelisted environment variables.
    tREMOTE_ADDRtSERVER_NAMEtSERVER_PORTN(RRR((RR((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pytget_environs
cC@s�|jd�}d|kr(|d}nZd|krA|d}nA|d}|t|d�fddfkr�|d
|d7}n|jd�r�|dkr�|d }n(|jd
�r�|dkr�|d }n|S(s�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.
    swsgi.url_schemetHTTP_X_FORWARDED_HOSTt	HTTP_HOSTRRthttpst443thttpt80t:s:80i����s:443i����(RR(RR(tgetR
tendswith(Rtschemetresult((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pytget_host$s




cC@s�|ddt|�g}|j}|r9dj|�dS|t|jdd�jd���|rq|d�nX|td|jdd�jd���|s�|jd�}|r�|d|�q�ndj|�S(	s3A 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.
    swsgi.url_schemes://tt/tSCRIPT_NAMEt	PATH_INFOtQUERY_STRINGt?(R!tappendtjoinRRtrstriptlstrip(Rt	root_onlytstrip_querystringt	host_onlyttmptcattqs((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pytget_current_url<s	%
)cC@sGy|djd�dj�SWn!ttfk
rB|jd�SXdS(s�
    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.
    tHTTP_X_FORWARDED_FORt,iRN(tsplittstriptKeyErrort
IndexErrorR(R((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pyt
get_client_ipasN(t__doc__t
__future__Rtraven.utils.compatRRRRR!tFalseR2R9(((sA/opt/alt/python27/lib/python2.7/site-packages/raven/utils/wsgi.pyt<module>s	
	
	$

?>