%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/paste/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyo

�
a�Nc@s�dZddlZddlZddlZddlmZddlmZdZd
e	fd��YZ
ddd�Zde	fd��YZd�Z
ddd�ZdS(s�
An application that proxies WSGI requests to a remote server.

TODO:

* Send ``Via`` header?  It's not clear to me this is a Via in the
  style of a typical proxy.

* Other headers or metadata?  I put in X-Forwarded-For, but that's it.

* Signed data of non-HTTP keys?  This would be for things like
  REMOTE_USER.

* Something to indicate what the original URL was?  The original host,
  scheme, and base path.

* Rewriting ``Location`` headers?  mod_proxy does this.

* Rewriting body?  (Probably not on this one -- that can be done with
  a different middleware that wraps this middleware)

* Example::  
    
    use = egg:Paste#proxy
    address = http://server3:8680/exist/rest/db/orgs/sch/config/
    allowed_request_methods = GET
  
i����N(thttpexceptions(tasliststransfer-encodingt
connections
keep-alivesproxy-authenticatesproxy-authorizationttettrailerstupgradetProxycBs eZddd�Zd�ZRS(cCs�||_tj|�|_|jdj�|_|jd|_|jd|_g|D]}|rX|j�^qX|_g|D]}|r�|j�^q�|_	dS(Niii(
taddressturlparseturlsplittparsedtlowertschemethosttpathtallowed_request_methodstsuppress_http_headers(tselfRRRtx((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyt__init__6s	(cCs|jr8|dj�|jkr8tjd�||�S|jdkrStj}n7|jdkrntj}ntd|j	|jf��||j
�}i}xs|j�D]e\}}|jd�r�|dj�j
dd	�}|d
ks�||jkrq�n|||<q�q�W|j
|d
<d|kr?|d|d<n|jd
�r_|d
|d<n|jd�r�|ddkr�|djd�}tt|��|d<q�|d|d<t|d�}	|dj|	�}nd}tj|d�}
|jrA|
}|r)|ddkr)|d}ntj|j|�}n|
}|jd�rk|d|d7}n|j|d|||�|j�}
t|
j�}d|
j|
jf}|||�|
jd�}	|	dk	r�|
jt|	��}n|
j�}|j!�|gS(NtREQUEST_METHODt
DisallowedthttpthttpssUnknown scheme for %r: %rtHTTP_it_t-R
tREMOTE_ADDRsx-forwarded-fortCONTENT_TYPEscontent-typetCONTENT_LENGTHs-1s
wsgi.inputi����scontent-lengthtt	PATH_INFOit/itQUERY_STRINGt?s%s %s("RRRtHTTPBadRequestRthttplibtHTTPConnectiontHTTPSConnectiont
ValueErrorRR
titemst
startswithtreplaceRtgettreadtstrtlentintturllibtquoteRRturljointrequesttgetresponset
parse_headerstmsgtstatustreasont	getheadertNonetclose(Rtenvirontstart_responset	ConnClasstconntheaderstkeytvaluetbodytlengtht	path_infotrequest_pathRtrestheaders_outR7((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyt__call__Csh	
	




(((t__name__t
__module__RRI(((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyR4sRcCs.t|�}t|�}t|d|d|�S(s�
    Make a WSGI application that proxies to another address:
    
    ``address``
        the full URL ending with a trailing ``/``
        
    ``allowed_request_methods``:
        a space seperated list of request methods (e.g., ``GET POST``)
        
    ``suppress_http_headers``
        a space seperated list of http headers (lower case, without
        the leading ``http_``) that should not be passed on to target
        host
    RR(RR(tglobal_confRRR((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyt
make_proxy�stTransparentProxycBs/eZdZddd�Zd�Zd�ZRS(s$
    A proxy that sends the request just as it was given, including
    respecting HTTP_HOST, wsgi.url_scheme, etc.

    This is a way of translating WSGI requests directly to real HTTP
    requests.  All information goes in the environment; modify it to
    modify the way the request is made.

    If you specify ``force_host`` (and optionally ``force_scheme``)
    then HTTP_HOST won't be used to determine where to connect to;
    instead a specific host will be connected to, but the ``Host``
    header in the request will remain intact.
    RcCs||_||_dS(N(t
force_hosttforce_scheme(RRORP((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyR�s	cCs,d|jjtt|��|j|jfS(Ns%<%s %s force_host=%r force_scheme=%r>(t	__class__RJthextidRORP(R((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyt__repr__�s	cCs�|d}|jdkr"|}n	|j}|dkrCtj}n(|dkr[tj}ntd|��d|kr�td��n|d}|jdkr�|}n	|j}||�}i}	xR|j�D]D\}
}|
jd�r�|
dj	�j
d	d
�}
||	|
<q�q�W||	d<d|krKd
|krK|d|	d<n|jd�rk|d|	d<n|jd�r�t|d�}|dj
|�}
|dkr�tt|
��|d<q�n'd|kr�d}
d}nd}
d}|jdd�|jdd�}tj|�}d|kr>|d|d7}n|j|d||
|	�|j�}t|j�}d|j|jf}|||�|jd�}|dk	r�|j
t|��}
n|j
�}
|j�|
gS(Nswsgi.url_schemeRRsUnknown scheme %rt	HTTP_HOSTs*WSGI environ must contain an HTTP_HOST keyRiRRR
RtHTTP_X_FORWARDED_FORsx-forwarded-forRscontent-typeRs
wsgi.inputi����RitSCRIPT_NAMERR!R"Rs%s %sscontent-length(ROR:RPR$R%R&R'R(R)RR*R+R/R,R-R.R0R1R3R4R5R6R7R8R9R;(RR<R=Rtconn_schemeR>R
t	conn_hostR?R@RARBRDRCRRGRHR7((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyRI�sn
		

		
	



N(RJRKt__doc__R:RRTRI(((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyRN�s
	cCs�g}x�|jD]�}|s"qn|dj�r�|sKtd|��n|j�\}}|d|j�}|j||f�qny|jdd�\}}Wntd|��nX|j�}|j�tkr|j||f�qqW|S(sB
    Turn a Message object into a list of WSGI-style headers.
    is%First header starts with a space (%r)t t:isInvalid header: %r(	R@tisspaceR'tpoptstriptappendtsplitRtfiltered_headers(tmessageRHtfull_headertlast_headert
last_valueRBtheader((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyR5�s(RcCstd|d|�S(s�
    Create a proxy that connects to a specific host, but does
    absolutely no other filtering, including the Host header.
    RORP(RN(RLRORP((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pytmake_transparent_proxys(stransfer-encodingRs
keep-alivesproxy-authenticatesproxy-authorizationRRR(RZR$RR0tpasteRtpaste.util.convertersRRbtobjectRRMRNR5R:Rh(((s</opt/alt/python27/lib/python2.7/site-packages/paste/proxy.pyt<module>s&Q\	

Zerion Mini Shell 1.0