+
    üÐjLN  ã                   óü   € R t ^ RIHtHt ^ RIHt ^ RIHtHtH	t	H
t
Ht ^ RIHt ^ RIHt ^ RIHt  ! R R]4      t ! R	 R
4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R4      t ! R R]4      tR# )z 
Test for L{twisted.web.proxy}.
)ÚMemoryReactorÚ StringTransportWithDisconnection)ÚTestCase)ÚProxyClientÚProxyClientFactoryÚProxyRequestÚReverseProxyRequestÚReverseProxyResource)ÚResource)ÚSite©ÚDummyRequestc                   óH   a € ] tR t^t o RtR tR tR tR tR t	R t
RtV tR	# )
ÚReverseProxyResourceTestsz$
Tests for L{ReverseProxyResource}.
c                óh  € \        4       p\        4       p\        RRRV4      pVP                  RV4       \	        V4      p\        4       pVP                  R4      pVP                  V4       V P                  VP                  R4       VP                  RV,           R,           4       VP                  w  w  ršr¼pV P                  V	R4       V P                  V
R4       V P                  V\        4       V P                  VP                  V4       V P                  VP                   R,          R	4       R# )
zƒ
Check that a request pointing at C{uri} produce a new proxy connection,
with the path of this request pointing at C{expectedURI}.
ú	127.0.0.1éÒ  ó   /paths   indexNs   GET s     HTTP/1.1
Accept: text/html

ó   hosts   127.0.0.1:1234)r
   r   r	   ÚputChildr   r   ÚbuildProtocolÚmakeConnectionÚ
addCleanupÚconnectionLostÚdataReceivedÚ
tcpClientsÚassertEqualÚassertIsInstancer   ÚrestÚheaders)ÚselfÚuriÚexpectedURIÚrootÚreactorÚresourceÚsiteÚ	transportÚchannelÚhostÚportÚfactoryÚ_timeoutÚ
_bind_addrs   &&&           Ú=/usr/lib/python3/dist-packages/twisted/web/test/test_proxy.pyÚ_testRenderÚ%ReverseProxyResourceTests._testRender   s  € ô
 ‹zˆÜ“/ˆÜ'¨°T¸8ÀWÓMˆØ�‰�h Ô)Ü�D‹zˆä4Ó6ˆ	Ø×$Ñ$ TÓ*ˆØ×Ñ˜yÔ)à�‰˜×.Ñ.°Ô5à×Ñ˜W s�]Ð-VÕVÔWà8?×8JÑ8JÑ5Ñ	4ˆ$�g¨à×Ñ˜˜{Ô+Ø×Ñ˜˜tÔ$ð 	×Ñ˜gÔ'9Ô:Ø×Ñ˜Ÿ™ {Ô3Ø×Ñ˜Ÿ™¨Õ1Ð3DÖEó    c                ó&   € V P                  RR4      # )z€
Test that L{ReverseProxyResource.render} initiates a connection to the
given server with a L{ProxyClientFactory} as parameter.
s   /indexr   ©r/   ©r    s   &r.   Útest_renderÚ%ReverseProxyResourceTests.test_render8   s   € ð
 ×Ñ 	¨8Ó4Ð4r1   c                ó&   € V P                  RR4      # )z¦
Test that L{ReverseProxyResource.render} will instantiate a child
resource that will initiate a connection to the given server
requesting the apropiate url subpath.
s   /index/page1s   /path/page1r3   r4   s   &r.   Útest_render_subpageÚ-ReverseProxyResourceTests.test_render_subpage?   s   € ð ×Ñ °Ó@Ð@r1   c                ó&   € V P                  RR4      # )zZ
Test that L{ReverseProxyResource.render} passes query parameters to the
created factory.
s   /index?foo=bars   /path?foo=barr3   r4   s   &r.   Útest_renderWithQueryÚ.ReverseProxyResourceTests.test_renderWithQueryG   s   € ð
 ×ÑÐ 1Ð3CÓDÐDr1   c                óz  € \        4       p\        RRRV4      pVP                  RR4      pV P                  V\        4       V P	                  VP
                  R4       V P	                  VP                  R4       V P	                  VP                  R4       V P                  VP                  VP                  4       R# )zÙ
The L{ReverseProxyResource.getChild} method should return a resource
instance with the same class as the originating resource, forward
port, host, and reactor values, and update the path value with the
value passed.
r   r   r   ó   fooNs	   /path/foo)
r   r	   ÚgetChildr   r   Úpathr*   r)   ÚassertIdenticalr$   )r    r$   r%   Úchilds   &   r.   Útest_getChildÚ'ReverseProxyResourceTests.test_getChildN   s”   € ô  “/ˆÜ'¨°T¸8ÀWÓMˆØ×!Ñ! &¨$Ó/ˆà×Ñ˜eÔ%9Ô:Ø×Ñ˜Ÿ™ \Ô2Ø×Ñ˜Ÿ™ TÔ*Ø×Ñ˜Ÿ™ [Ô1Ø×Ñ˜UŸ]™]¨H×,<Ñ,<Ö=r1   c                ó|   € \        RRR4      pVP                  RR4      pV P                  VP                  R4       R# )z]
The L{ReverseProxyResource} return by C{getChild} has a path which has
already been quoted.
r   r   r   s    /%Ns   /path/%20%2F%25)r	   r?   r   r@   )r    r%   rB   s   &  r.   Útest_getChildWithSpecialÚ2ReverseProxyResourceTests.test_getChildWithSpecial_   s9   € ô
 (¨°T¸8ÓDˆØ×!Ñ! &¨$Ó/ˆØ×Ñ˜Ÿ™Ð%7Ö8r1   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r/   r5   r8   r;   rC   rF   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r.   r   r      s0   ø‡ € ñòFò:5òAòEò>÷"9ð 9r1   r   c                   ó<   a € ] tR t^it o RtR tR tR tR tRt	V t
R# )ÚDummyChannelzÅ
A dummy HTTP channel, that does nothing but holds a transport and saves
connection lost.

@ivar transport: the transport used by the client.
@ivar lostReason: the reason saved at connection lost.
c                ó    € Wn         RV n        R# )z$
Hold a reference to the transport.
N)r'   Ú
lostReason)r    r'   s   &&r.   Ú__init__ÚDummyChannel.__init__r   s   € ð #ŒØˆŽr1   c                ó   € Wn         R# )z+
Keep track of the connection lost reason.
N)rU   )r    Úreasons   &&r.   r   ÚDummyChannel.connectionLosty   s	   € ð !Žr1   c                ó6   € V P                   P                  4       # )z*
Get peer information from the transport.
)r'   ÚgetPeerr4   s   &r.   r\   ÚDummyChannel.getPeer   ó   € ð �~‰~×%Ñ%Ó'Ð'r1   c                ó6   € V P                   P                  4       # )z*
Get host information from the transport.
)r'   ÚgetHostr4   s   &r.   r`   ÚDummyChannel.getHost…   r^   r1   )rU   r'   N)rI   rJ   rK   rL   rM   rV   r   r\   r`   rN   rO   rP   s   @r.   rS   rS   i   s#   ø‡ € ñòò!ò(÷(ð (r1   rS   c                   óŒ   a € ] tR t^Œt o RtR tR tRR ltR tR t	R t
R	 tRR
 ltR tR tR tR tR tR tR tR tRtV tR# )ÚProxyClientTestsz
Tests for L{ProxyClient}.
c                ó–   € VP                  R4      w  r#VP                  R4      pVP                  ^ 4      pV\        R V 4       4      V3# )a  
Parse the headers out of some web content.

@param content: Bytes received from a web server.
@return: A tuple of (requestLine, headers, body). C{headers} is a dict
    of headers, C{requestLine} is the first line (e.g. "POST /foo ...")
    and C{body} is whatever is left.
s   

ó   
c              3   óB   "  € T F  qP                  R 4      x € K  	  R# 5i)ó   : N)Úsplit)Ú.0Úheaders   & r.   Ú	<genexpr>Ú4ProxyClientTests._parseOutHeaders.<locals>.<genexpr>�   s   é € Ð!LÁG¸&§,¡,¨u×"5Ð"5ÃGùs   ‚)rh   ÚpopÚdict)r    Úcontentr   ÚbodyÚrequestLines   &&   r.   Ú_parseOutHeadersÚ!ProxyClientTests._parseOutHeaders‘   sG   € ð  Ÿ™ kÓ2‰ˆØ—-‘- Ó(ˆØ—k‘k !“nˆØœTÑ!LÁGÓ!LÓLÈdÐSÐSr1   c                ó   € \        V4      # )z}
Make a dummy request object for the URL path.

@param path: A URL path, beginning with a slash.
@return: A L{DummyRequest}.
r   )r    r@   s   &&r.   ÚmakeRequestÚProxyClientTests.makeRequestŸ   s   € ô ˜DÓ!Ð!r1   Nc                óT   € Vf   RR/pRVP                   ,           p\        W%RW4V4      # )al  
Make a L{ProxyClient} object used for testing.

@param request: The request to use.
@param method: The HTTP method to use, GET by default.
@param headers: The HTTP headers to use expressed as a dict. If not
    provided, defaults to {'accept': 'text/html'}.
@param requestBody: The body of the request. Defaults to the empty
    string.
@return: A L{ProxyClient}
ó   acceptó	   text/htmló   /ó   HTTP/1.0)Úpostpathr   )r    ÚrequestÚmethodr   ÚrequestBodyr@   s   &&&&& r.   ÚmakeProxyClientÚ ProxyClientTests.makeProxyClient¨   s4   € ð Š?Ø  ,Ð/ˆGØ�g×&Ñ&Õ&ˆÜ˜6¨°gÈGÓTÐTr1   c                óH   € \        4       pWn        VP                  V4       V# )z›
Connect a proxy client to a L{StringTransportWithDisconnection}.

@param proxyClient: A L{ProxyClient}.
@return: The L{StringTransportWithDisconnection}.
)r   Úprotocolr   )r    ÚproxyClientÚclientTransports   && r.   ÚconnectProxyÚProxyClientTests.connectProxy¹   s&   € ô ;Ó<ˆØ#.Ô Ø×"Ñ" ?Ô3ØÐr1   c                óÈ   € V P                  V4       VP                  P                  4       pV P                  V4      w  rVpV P	                  WR4       V P	                  Wc4       V# )a(  
Assert that C{proxyClient} sends C{headers} when it connects.

@param proxyClient: A L{ProxyClient}.
@param requestLine: The request line we expect to be sent.
@param headers: A dict of headers we expect to be sent.
@return: If the assertion is successful, return the request body as
    bytes.
)r†   r'   Úvaluerr   r   )r    r„   rq   r   ÚrequestContentÚreceivedLineÚreceivedHeadersrp   s   &&&&    r.   ÚassertForwardsHeadersÚ&ProxyClientTests.assertForwardsHeadersÅ   s\   € ð 	×Ñ˜+Ô&Ø$×.Ñ.×4Ñ4Ó6ˆØ.2×.CÑ.CÀNÓ.SÑ+ˆ tØ×Ñ˜Ô3Ø×Ñ˜Ô2Øˆr1   c                ó  € R \        V4      P                  R4      ,           R,           V,           .pV F-  w  rgV F"  pVP                  VR,           V,           4       K$  	  K/  	  VP                  RV.4       RP	                  V4      # )s	   HTTP/1.0 Úasciió    rg   r1   re   )ÚstrÚencodeÚappendÚextendÚjoin)	r    ÚcodeÚmessager   rp   Úlinesrj   Úvaluesr‰   s	   &&&&&    r.   ÚmakeResponseBytesÚ"ProxyClientTests.makeResponseBytesÖ   st   € Ø¤ D£	× 0Ñ 0°Ó 9Õ9¸DÕ@À7ÕJÐKˆÛ%‰NˆFÛ�Ø—‘˜V e�^¨eÕ3Ö4ó  ñ &ð 	�‰�c˜4�[Ô!Ø�|‰|˜EÓ"Ð"r1   c                ó†  € V P                  VP                  V4       V P                  VP                  V4       \        VP                  P                  4       4      pVP                  4        VR,          pVP                  4        V P                  Wg4       V P                  RP                  VP                  4      V4       R# )a  
Assert that C{request} has forwarded a response from the server.

@param request: A L{DummyRequest}.
@param code: The expected HTTP response code.
@param message: The expected HTTP message.
@param headers: The expected HTTP headers.
@param body: The expected response body.
:NNNr1   N)	r   ÚresponseCodeÚresponseMessageÚlistÚresponseHeadersÚgetAllRawHeadersÚsortr–   Úwritten)r    r}   r—   r˜   r   rp   rŒ   ÚexpectedHeaderss   &&&&&&  r.   ÚassertForwardsResponseÚ'ProxyClientTests.assertForwardsResponseÞ   s•   € ð 	×Ñ˜×-Ñ-¨tÔ4Ø×Ñ˜×0Ñ0°'Ô:Ü˜w×6Ñ6×GÑGÓIÓJˆØ×ÑÔØ! !�*ˆØ×ÑÔØ×Ñ˜Ô:Ø×Ñ˜Ÿ™ '§/¡/Ó2°DÖ9r1   c                óÞ  € V P                  R4      pV P                  W…RR/V4      p	V P                  V	VR,           RRRR/4      p
V P                  W¦4       V	P	                  V P                  WW44      4       V P                  W�W#V4       V'       d   V	P                  P                  4        V P                  V	P                  P                  4       V P                  VP                  ^4       R# )zs
Build a fake proxy connection, and send C{data} over it, checking that
it's forwarded to the originating request.
r>   rx   ry   s    /foo HTTP/1.0ó
   connectionó   closeN)ru   r€   r�   r   r   r›   r¦   r'   ÚloseConnectionÚassertFalseÚ	connectedÚfinished)r    r—   r˜   r   rp   r~   r   r«   r}   ÚclientÚreceivedBodys   &&&&&&&&   r.   Ú_testDataForwardÚ!ProxyClientTests._testDataForwardñ   sä   € ð ×"Ñ" 6Ó*ˆØ×%Ñ%Ø˜i¨Ð6¸ó
ˆð ×1Ñ1ØØÐ&Õ&Ø˜H i°Ð>ó
ˆð 	×Ñ˜Ô3ð 	×Ñ˜D×2Ñ2°4À'ÓPÔQð 	×#Ñ# G°7ÀTÔJ÷ Ø×Ñ×+Ñ+Ô-ð
 	×Ñ˜×)Ñ)×3Ñ3Ô4Ø×Ñ˜×)Ñ)¨1Ö-r1   c                ó4   € V P                  ^ÈRRRR.3.R4      # )z£
When connected to the server, L{ProxyClient} should send the saved
request, with modifications of the headers, and then forward the result
to the parent request.
ó   OKó   Fooó   bars   bazó   Some data
©r±   r4   s   &r.   Útest_forwardÚProxyClientTests.test_forward  s.   € ð ×$Ñ$Ø�˜& 6¨6Ð"2Ð3Ð4Ð6Fó
ð 	
r1   c                ó6   € V P                  ^ÈRRR.3.RRR4      # )zf
Try to post content in the request, and check that the proxy client
forward the body of the request.
r´   rµ   r¶   r·   ó   POSTó   Some contentr¸   r4   s   &r.   Útest_postDataÚProxyClientTests.test_postData'  s/   € ð
 ×$Ñ$Ø�˜& 6 (Ð+Ð,Ð.>ÀÈó
ð 	
r1   c                ó*   € V P                  RR. R4      # )zz
If the response contains a status with a message, it should be
forwarded to the parent request with all the information.
i”  s	   Not Foundr1   r¸   r4   s   &r.   Útest_statusWithMessageÚ'ProxyClientTests.test_statusWithMessage0  s   € ð
 ×$Ñ$ S¨,¸¸CÓ@Ð@r1   c           
     óx   € RpV P                  ^ÈRR\        \        V4      4      P                  R4      .3.V4      # )z…
If the response contains a I{Content-Length} header, the inbound
request object should still only have C{finish} called on it once.
ó   foo bar bazr´   ó   Content-Lengthr�   ©r±   r’   Úlenr“   ©r    Údatas   & r.   Útest_contentLengthÚ#ProxyClientTests.test_contentLength7  sE   € ð
 ˆØ×$Ñ$Ø�Ð+¬c´#°d³)«n×.CÑ.CÀGÓ.LÐ-MÐNÐOÐQUó
ð 	
r1   c           
     ó|   € RpV P                  ^ÈRR\        \        V4      4      P                  R4      .3.VRR7      # )z‡
If the response contains a I{Content-Length} header, the outgoing
connection is closed when all response body data has been received.
rÄ   r´   rÅ   r�   F)r«   rÆ   rÈ   s   & r.   Útest_losesConnectionÚ%ProxyClientTests.test_losesConnectionA  sN   € ð
 ˆØ×$Ñ$ØØØ¤#¤c¨$£i£.×"7Ñ"7¸Ó"@Ð!AÐBÐCØØ ð %ó 
ð 	
r1   c           	     ón   € \        RRRRRRR/RR	4      pV P                  VP                  RRR
R/4       R	# )zŽ
The headers given at initialization should be modified:
B{proxy-connection} should be removed if present, and B{connection}
should be added.
ó   GETó   /foor{   rx   ry   s   proxy-connectionr>   r1   Nr©   rª   )r   r   r   )r    r¯   s   & r.   Útest_headersCleanupsÚ%ProxyClientTests.test_headersCleanupsO  sL   € ô ØØØØ˜Ð&9¸6ÐBØØó
ˆð 	×ÑØ�N‰N˜Y¨°mÀXÐNö	
r1   c                óŒ   € RRRRRR/pVP                  4       pRVR&   VR \        RRR	VR
R4      pV P                  VRV4       R# )z–
The proxy doesn't really know what to do with keepalive things from
the remote server, so we stomp over any keepalive header we get from
the client.
rx   ry   s
   keep-alives   300r©   rª   rÐ   rÑ   r{   r1   Ns   GET /foo HTTP/1.0)Úcopyr   r�   )r    r   r¥   r¯   s   &   r.   Útest_keepaliveNotForwardedÚ+ProxyClientTests.test_keepaliveNotForwardeda  s`   € ð �|Ø˜6Ø˜=ð
ˆð
 "Ÿ,™,›.ˆØ)1ˆ˜Ñ&Ø˜MÐ*Ü˜V W¨k¸7ÀCÈÓNˆØ×"Ñ" 6Ð+?ÀÖQr1   c           	     óò  € V P                  R4      pVP                  P                  RR.4       VP                  P                  RR.4       VP                  P                  RR.4       V P                  VRR	/R
7      pV P	                  V4       RR.RR.RR./pVP                  V P                  ^ÈRVP                  4       R4      4       V P                  V^ÈR\        VP                  4       4      R4       R# )z¾
L{server.Request} within the proxy sets certain response headers by
default. When we get these headers back from the remote server, the
defaults are overridden rather than simply appended.
r>   s   servers   old-bars   dates   old-bazs   content-types   old/quxrx   ry   )r   s   Serverr¶   s   Dates
   2010-01-01ó   Content-Types   application/x-bazr´   r1   N)
ru   r¡   ÚsetRawHeadersr€   r†   r   r›   Úitemsr¦   r    )r    r}   r¯   r   s   &   r.   Útest_defaultHeadersOverriddenÚ.ProxyClientTests.test_defaultHeadersOverriddenr  sì   € ð ×"Ñ" 6Ó*ˆØ×Ñ×-Ñ-¨i¸*¸ÔFØ×Ñ×-Ñ-¨g¸
°|ÔDØ×Ñ×-Ñ-¨oÀ
¸|ÔLØ×%Ñ% g¸	À<Ð7PÐ%ÓQˆØ×Ñ˜&Ô!à˜�xØ�m�_ØÐ2Ð3ð
ˆð
 	×Ñ˜D×2Ñ2°3¸¸w¿}¹}»ÐPSÓTÔUØ×#Ñ# G¨S°%¼¸g¿m¹m»oÓ9NÐPSÖTr1   rH   )rÐ   Nr1   )rÐ   r1   T)rI   rJ   rK   rL   rM   rr   ru   r€   r†   r�   r›   r¦   r±   r¹   r¾   rÁ   rÊ   rÍ   rÒ   rÖ   rÜ   rN   rO   rP   s   @r.   rc   rc   Œ   sf   ø‡ € ñòTò"ôUò"
òò"#ò:ô&*.òX
ò
òAò
ò
ò
ò$R÷"Uð Ur1   rc   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚProxyClientFactoryTestsi‡  z"
Tests for L{ProxyClientFactory}.
c                óÒ  € \        R.4      p\        RRRRR/RV4      pVP                  RR4       V P                  VP                  R	4       V P                  VP
                  R
4       V P                  \        VP                  P                  4       4      RR.3.4       V P                  RP                  VP                  4      R4       V P                  VP                  ^4       R# )zk
Check that L{ProxyClientFactory.clientConnectionFailed} produces
a B{501} response to the parent request.
r>   rÐ   rÑ   r{   rx   ry   Ú Niõ  s   Gateway errorrÙ   r1   s   <H1>Could not connect</H1>)r   r   ÚclientConnectionFailedr   rž   rŸ   r    r¡   r¢   r–   r¤   r®   )r    r}   r+   s   &  r.   Útest_connectionFailedÚ-ProxyClientFactoryTests.test_connectionFailedŒ  sÓ   € ô
  ˜xÓ(ˆÜ$Ø�G˜[¨9°lÐ*CÀRÈó
ˆð 	×&Ñ& t¨TÔ2Ø×Ñ˜×-Ñ-¨sÔ3Ø×Ñ˜×0Ñ0Ð2BÔCØ×ÑÜ�×(Ñ(×9Ñ9Ó;Ó<Ø ˜~Ð.Ð/ô	
ð 	×Ñ˜Ÿ™ '§/¡/Ó2Ð4QÔRØ×Ñ˜×)Ñ)¨1Ö-r1   c                ó`  € \        RRRRR/RR4      pVP                  R4      pV P                  V\        4       V P	                  VP
                  R4       V P	                  VP                  R4       V P	                  VP                  R4       V P	                  VP                  RRRR	/4       R# )
z‡
L{ProxyClientFactory.buildProtocol} should produce a L{ProxyClient}
with the same values of attributes (with updates on the headers).
rÐ   rÑ   r{   rx   ry   s	   Some dataNr©   rª   )	r   r   r   r   r   Úcommandr   rÉ   r   )r    r+   Úprotos   &  r.   Útest_buildProtocolÚ*ProxyClientFactoryTests.test_buildProtocol   sŸ   € ô
 %Ø�G˜[¨9°lÐ*CÀ\ÐSWó
ˆð ×%Ñ% dÓ+ˆØ×Ñ˜e¤[Ô1Ø×Ñ˜Ÿ™¨Ô/Ø×Ñ˜Ÿ™ WÔ-Ø×Ñ˜Ÿ™ \Ô2Ø×ÑØ�M‰M˜I |°]ÀHÐMö	
r1   rH   N)	rI   rJ   rK   rL   rM   rã   rè   rN   rO   rP   s   @r.   rß   rß   ‡  s   ø‡ € ñò.÷(
ð 
r1   rß   c                   óF   a € ] tR tRt o RtR
R ltR tR tR tR t	Rt
V tR	# )ÚProxyRequestTestsi²  z
Tests for L{ProxyRequest}.
c                óŽ  € \        4       p\        V4      p\        4       p\        VRV4      pVP	                  \        V4      4       VP                  V4       VP                  VRV,           R4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^ ,          R4       V P                  VP                  ^ ,          ^,          ^P4       VP                  ^ ,          ^,          p	V P                  V	\        4       V P                  V	P                  V4       V P                  V	P                  R4       V P                  V	P                  RR/4       V P                  V	P                  V4       V P                  V	P                   V4       V P                  V	P"                  V4       R# )zm
Build a request pointing at C{uri}, and check that a proxied request
is created, pointing a C{expectedURI}.
Fs   http://example.comr{   úexample.comr   ó   example.comN)r   rS   r   r   Ú	gotLengthrÇ   ÚhandleContentChunkÚrequestReceivedr   r   r   r   ræ   Úversionr   rÉ   r   Úfather)
r    r!   r"   r~   rÉ   r'   r(   r$   r}   r+   s
   &&&&&     r.   Ú_testProcessÚProxyRequestTests._testProcess·  sa  € ô
 5Ó6ˆ	Ü˜yÓ)ˆÜ“/ˆÜ˜w¨¨wÓ7ˆØ×Ñœ#˜d›)Ô$Ø×"Ñ" 4Ô(Ø×Ñ Ð(=ÀÕ(CÀ[ÔQà×Ñœ˜W×/Ñ/Ó0°!Ô4Ø×Ñ˜×+Ñ+¨AÕ.¨qÕ1°=ÔAØ×Ñ˜×+Ñ+¨AÕ.¨qÕ1°2Ô6à×$Ñ$ QÕ'¨Õ*ˆØ×Ñ˜gÔ'9Ô:Ø×Ñ˜Ÿ™¨&Ô1Ø×Ñ˜Ÿ™¨+Ô6Ø×Ñ˜Ÿ™¨7°NÐ*CÔDØ×Ñ˜Ÿ™ tÔ,Ø×Ñ˜Ÿ™ {Ô3Ø×Ñ˜Ÿ™¨Ö1r1   c                ó&   € V P                  RR4      # )aA  
L{ProxyRequest.process} should create a connection to the given server,
with a L{ProxyClientFactory} as connection factory, with the correct
parameters:
    - forward comment, version and data values
    - update headers with the B{host} value
    - remove the host from the URL
    - pass the request as parent request
ó   /foo/bar©rô   r4   s   &r.   Útest_processÚProxyRequestTests.test_processÑ  s   € ð × Ñ  ¨kÓ:Ð:r1   c                ó&   € V P                  RR4      # )zƒ
If the incoming request doesn't contain a slash,
L{ProxyRequest.process} should add one when instantiating
L{ProxyClientFactory}.
r1   rz   rø   r4   s   &r.   Ú test_processWithoutTrailingSlashÚ2ProxyRequestTests.test_processWithoutTrailingSlashÝ  s   € ð × Ñ   dÓ+Ð+r1   c                ó*   € V P                  RRRR4      # )zT
L{ProxyRequest.process} should be able to retrieve request body and
to forward it.
r÷   r¼   r½   rø   r4   s   &r.   Útest_processWithDataÚ&ProxyRequestTests.test_processWithDataå  s   € ð
 × Ñ  ¨k¸7ÀOÓTÐTr1   c                ó˜  € \        4       p\        V4      p\        4       p\        VRV4      pVP	                  ^ 4       VP                  RRR4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^ ,          R4       V P                  VP                  ^ ,          ^,          R4       R# )z€
Check that L{ProxyRequest.process} correctly parse port in the incoming
URL, and create an outgoing connection with this port.
FrÐ   s   http://example.com:1234/foo/barr{   rí   r   N)	r   rS   r   r   rï   rñ   r   rÇ   r   )r    r'   r(   r$   r}   s   &    r.   Útest_processWithPortÚ&ProxyRequestTests.test_processWithPortì  s©   € ô
 5Ó6ˆ	Ü˜yÓ)ˆÜ“/ˆÜ˜w¨¨wÓ7ˆØ×Ñ˜!ÔØ×Ñ Ð(JÈKÔXð 	×Ñœ˜W×/Ñ/Ó0°!Ô4Ø×Ñ˜×+Ñ+¨AÕ.¨qÕ1°=ÔAØ×Ñ˜×+Ñ+¨AÕ.¨qÕ1°4Ö8r1   rH   N)rÐ   r1   )rI   rJ   rK   rL   rM   rô   rù   rü   rÿ   r  rN   rO   rP   s   @r.   rë   rë   ²  s)   ø‡ € ñô2ò4
;ò,òU÷9ð 9r1   rë   c                   ó*   a € ] tR tRt o RtR tRtV tR# )ÚDummyFactoryiþ  z6
A simple holder for C{host} and C{port} information.
c                ó   € Wn         W n        R # )N©r)   r*   )r    r)   r*   s   &&&r.   rV   ÚDummyFactory.__init__  s   € ØŒ	ØŽ	r1   r  N)rI   rJ   rK   rL   rM   rV   rN   rO   rP   s   @r.   r  r  þ  s   ø‡ € ñ÷ð r1   r  c                   ó*   a € ] tR tRt o RtR tRtV tR# )ÚReverseProxyRequestTestsi  z#
Tests for L{ReverseProxyRequest}.
c                óV  € \        4       p\        V4      p\        4       p\        VRV4      p\	        RR4      Vn        VP                  ^ 4       VP                  RRR4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          ^ ,          R4       V P                  VP                  ^ ,          ^,          R4       VP                  ^ ,          ^,          pV P                  V\        4       V P                  VP                  RR/4       R	# )
zÚ
L{ReverseProxyRequest.process} should create a connection to its
factory host/port, using a L{ProxyClientFactory} instantiated with the
correct parameters, and particularly set the B{host} header to the
factory host.
Frí   r   rÐ   r÷   r{   r   rî   N)r   rS   r   r   r  r+   rï   rñ   r   rÇ   r   r   r   r   )r    r'   r(   r$   r}   r+   s   &     r.   rù   Ú%ReverseProxyRequestTests.test_process  s÷   € ô 5Ó6ˆ	Ü˜yÓ)ˆÜ“/ˆÜ% g¨u°gÓ>ˆÜ& }°dÓ;ˆŒØ×Ñ˜!ÔØ×Ñ ¨°[ÔAð 	×Ñœ˜W×/Ñ/Ó0°!Ô4Ø×Ñ˜×+Ñ+¨AÕ.¨qÕ1°=ÔAØ×Ñ˜×+Ñ+¨AÕ.¨qÕ1°4Ô8ð ×$Ñ$ QÕ'¨Õ*ˆØ×Ñ˜gÔ'9Ô:Ø×Ñ˜Ÿ™¨7°NÐ*CÖDr1   rH   N)rI   rJ   rK   rL   rM   rù   rN   rO   rP   s   @r.   r
  r
    s   ø‡ € ñ÷Eð Er1   r
  N)rM   Útwisted.internet.testingr   r   Útwisted.trial.unittestr   Útwisted.web.proxyr   r   r   r   r	   Útwisted.web.resourcer
   Útwisted.web.serverr   Útwisted.web.test.test_webr   r   rS   rc   rß   rë   r  r
  rH   r1   r.   Ú<module>r     s‡   ðñ÷ UÝ +÷õ õ *Ý #Ý 2ôP9 ô P9÷f (ñ  (ôFxU�xô xUôv(
˜hô (
ôVI9˜ô I9÷Xñ ôE˜xö Er1   