ó aòNc@s§dZddlZddlZddlZddlmZddlmZdZd e fd„ƒYZ ddd„Z de 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|||(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 ƒ} | | | |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ÿÿÿÿRit SCRIPT_NAMERR!R"Rs%s %sscontent-length(ROR:RPR$R%R&R'R(R)R R*R+R/R,R-R.R0R1R3R4R5R6R7R8R9R;(RR<R=R t conn_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.pyRNs   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'tpoptstriptappendtsplitR tfiltered_headers(tmessageRHt full_headert last_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.pyts&   Q \