ó
    ×›‘hLN  ã                   óú   • S r SSKJrJr  SSKJr  SSKJrJrJ	r	J
r
Jr  SSKJr  SSKJr  SSKJr   " S S	\5      r " S
 S5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      rg)z 
Test for L{twisted.web.proxy}.
é    )ÚMemoryReactorÚ StringTransportWithDisconnection)ÚTestCase)ÚProxyClientÚProxyClientFactoryÚProxyRequestÚReverseProxyRequestÚReverseProxyResource)ÚResource)ÚSite©ÚDummyRequestc                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚReverseProxyResourceTestsé   z$
Tests for L{ReverseProxyResource}.
c                 óN  • [        5       n[        5       n[        SSSU5      nUR                  SU5        [	        U5      n[        5       nUR                  S5      nUR                  U5        U R                  UR                  S5        UR                  SU-   S-   5        UR                  u  u  pšp¼nU R                  U	S5        U R                  U
S5        U R                  U[        5        U R                  UR                  U5        U R                  UR                   S   S	5        g)
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                 Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-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                 ó&   • U R                  SS5      $ )z€
Test that L{ReverseProxyResource.render} initiates a connection to the
given server with a L{ProxyClientFactory} as parameter.
s   /indexr   ©r1   ©r"   s    r0   Útest_renderÚ%ReverseProxyResourceTests.test_render8   s   € ð
 ×Ñ 	¨8Ó4Ð4r3   c                 ó&   • U R                  SS5      $ )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/page1r5   r6   s    r0   Útest_render_subpageÚ-ReverseProxyResourceTests.test_render_subpage?   s   € ð ×Ñ °Ó@Ð@r3   c                 ó&   • U R                  SS5      $ )zZ
Test that L{ReverseProxyResource.render} passes query parameters to the
created factory.
s   /index?foo=bars   /path?foo=barr5   r6   s    r0   Útest_renderWithQueryÚ.ReverseProxyResourceTests.test_renderWithQueryG   s   € ð
 ×ÑÐ 1Ð3CÓDÐDr3   c                 óx  • [        5       n[        SSSU5      nUR                  SS5      nU R                  U[        5        U R	                  UR
                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R                  UR                  UR                  5        g)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       r0   Útest_getChildÚ'ReverseProxyResourceTests.test_getChildN   s”   € ô  “/ˆÜ'¨°T¸8ÀWÓMˆØ×!Ñ! &¨$Ó/ˆà×Ñ˜eÔ%9Ô:Ø×Ñ˜Ÿ™ \Ô2Ø×Ñ˜Ÿ™ TÔ*Ø×Ñ˜Ÿ™ [Ô1Ø×Ñ˜UŸ]™]¨H×,<Ñ,<Õ=r3   c                 óz   • [        SSS5      nUR                  SS5      nU R                  UR                  S5        g)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
   rA   r   rB   )r"   r'   rD   s      r0   Útest_getChildWithSpecialÚ2ReverseProxyResourceTests.test_getChildWithSpecial_   s9   € ô
 (¨°T¸8ÓDˆØ×!Ñ! &¨$Ó/ˆØ×Ñ˜Ÿ™Ð%7Õ8r3   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r1   r7   r:   r=   rE   rH   Ú__static_attributes__rJ   r3   r0   r   r      s(   † ñòFò:5òAòEò>õ"9r3   r   c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚDummyChanneléi   zÅ
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                 ó   • Xl         SU l        g)z$
Hold a reference to the transport.
N)r)   Ú
lostReason)r"   r)   s     r0   Ú__init__ÚDummyChannel.__init__r   s   € ð #ŒØˆ�r3   c                 ó   • Xl         g)z+
Keep track of the connection lost reason.
N)rU   )r"   Úreasons     r0   r   ÚDummyChannel.connectionLosty   s	   € ð !�r3   c                 ó6   • U R                   R                  5       $ )z*
Get peer information from the transport.
)r)   ÚgetPeerr6   s    r0   r\   ÚDummyChannel.getPeer   ó   € ð �~‰~×%Ñ%Ó'Ð'r3   c                 ó6   • U R                   R                  5       $ )z*
Get host information from the transport.
)r)   ÚgetHostr6   s    r0   r`   ÚDummyChannel.getHost…   r^   r3   )rU   r)   N)
rK   rL   rM   rN   rO   rV   r   r\   r`   rP   rJ   r3   r0   rR   rR   i   s   † ñòò!ò(õ(r3   rR   c                   ó†   • \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 r   SS jrS rS rS rS rS rS rS rS rSrg)ÚProxyClientTestséŒ   z
Tests for L{ProxyClient}.
c                 ó–   • UR                  S5      u  p#UR                  S5      nUR                  S5      nU[        S U 5       5      U4$ )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   

ó   
r   c              3   óB   #   • U  H  oR                  S 5      v •  M     g7f)ó   : N)Úsplit)Ú.0Úheaders     r0   Ú	<genexpr>Ú4ProxyClientTests._parseOutHeaders.<locals>.<genexpr>�   s   é € Ð!LÂG¸&§,¡,¨u×"5Ð"5ÂGùs   ‚)ri   ÚpopÚdict)r"   Úcontentr!   ÚbodyÚrequestLines        r0   Ú_parseOutHeadersÚ!ProxyClientTests._parseOutHeaders‘   sG   € ð  Ÿ™ kÓ2‰ˆØ—-‘- Ó(ˆØ—k‘k !“nˆØœTÑ!LÁGÓ!LÓLÈdÐSÐSr3   c                 ó   • [        U5      $ )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"   rB   s     r0   ÚmakeRequestÚProxyClientTests.makeRequestŸ   s   € ô ˜DÓ!Ð!r3   Nc                 óJ   • Uc  SS0nSUR                   -   n[        X%SX4U5      $ )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!   ÚrequestBodyrB   s         r0   ÚmakeProxyClientÚ ProxyClientTests.makeProxyClient¨   s4   € ð ‰?Ø  ,Ð/ˆGØ�g×&Ñ&Ñ&ˆÜ˜6¨°gÈGÓTÐTr3   c                 óH   • [        5       nXl        UR                  U5        U$ )z›
Connect a proxy client to a L{StringTransportWithDisconnection}.

@param proxyClient: A L{ProxyClient}.
@return: The L{StringTransportWithDisconnection}.
)r   Úprotocolr   )r"   ÚproxyClientÚclientTransports      r0   ÚconnectProxyÚProxyClientTests.connectProxy¹   s&   € ô ;Ó<ˆØ#.Ô Ø×"Ñ" ?Ô3ØÐr3   c                 óÈ   • U R                  U5        UR                  R                  5       nU R                  U5      u  pVnU R	                  XR5        U R	                  Xc5        U$ )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)   Úvaluers   r   )r"   r…   rr   r!   ÚrequestContentÚreceivedLineÚreceivedHeadersrq   s           r0   ÚassertForwardsHeadersÚ&ProxyClientTests.assertForwardsHeadersÅ   s\   € ð 	×Ñ˜+Ô&Ø$×.Ñ.×4Ñ4Ó6ˆØ.2×.CÑ.CÀNÓ.SÑ+ˆ tØ×Ñ˜Ô3Ø×Ñ˜Ô2Øˆr3   c                 óè   • S[        U5      R                  S5      -   S-   U-   /nU H%  u  pgU H  nUR                  US-   U-   5        M     M'     UR                  SU/5        SR	                  U5      $ )Ns	   HTTP/1.0 Úasciió    rh   r3   rf   )ÚstrÚencodeÚappendÚextendÚjoin)	r"   ÚcodeÚmessager!   rq   Úlinesrk   ÚvaluesrŠ   s	            r0   ÚmakeResponseBytesÚ"ProxyClientTests.makeResponseBytesÖ   st   € Ø¤ D£	× 0Ñ 0°Ó 9Ñ9¸DÑ@À7ÑJÐKˆÛ%‰NˆFÛ�Ø—‘˜V e™^¨eÑ3Ö4ó  ñ &ð 	�‰�c˜4�[Ô!Ø�|‰|˜EÓ"Ð"r3   c                 ó|  • U R                  UR                  U5        U R                  UR                  U5        [        UR                  R                  5       5      nUR                  5         USS nUR                  5         U R                  Xg5        U R                  SR                  UR                  5      U5        g)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.
Nr3   )	r   ÚresponseCodeÚresponseMessageÚlistÚresponseHeadersÚgetAllRawHeadersÚsortr—   Úwritten)r"   r~   r˜   r™   r!   rq   r�   ÚexpectedHeaderss           r0   ÚassertForwardsResponseÚ'ProxyClientTests.assertForwardsResponseÞ   s•   € ð 	×Ñ˜×-Ñ-¨tÔ4Ø×Ñ˜×0Ñ0°'Ô:Ü˜w×6Ñ6×GÑGÓIÓJˆØ×ÑÔØ!¡!˜*ˆØ×ÑÔØ×Ñ˜Ô:Ø×Ñ˜Ÿ™ '§/¡/Ó2°DÕ9r3   c                 óÐ  • U R                  S5      nU R                  X…SS0U5      n	U R                  U	US-   SSS.5      n
U R                  X¦5        U	R	                  U R                  XX45      5        U R                  X�X#U5        U(       a  U	R                  R                  5         U R                  U	R                  R                  5        U R                  UR                  S5        g)	zs
Build a fake proxy connection, and send C{data} over it, checking that
it's forwarded to the originating request.
r@   ry   rz   s    /foo HTTP/1.0ó   close)ó
   connectionry   é   N)rv   r�   rŽ   r   r   rœ   r§   r)   ÚloseConnectionÚassertFalseÚ	connectedÚfinished)r"   r˜   r™   r!   rq   r   r€   r­   r~   ÚclientÚreceivedBodys              r0   Ú_testDataForwardÚ!ProxyClientTests._testDataForwardñ   sà   € ð ×"Ñ" 6Ó*ˆØ×%Ñ%Ø˜i¨Ð6¸ó
ˆð ×1Ñ1ØØÐ&Ñ&Ø$°Ñ>ó
ˆð 	×Ñ˜Ô3ð 	×Ñ˜D×2Ñ2°4À'ÓPÔQð 	×#Ñ# G°7ÀTÔJö Ø×Ñ×+Ñ+Ô-ð
 	×Ñ˜×)Ñ)×3Ñ3Ô4Ø×Ñ˜×)Ñ)¨1Õ-r3   c                 ó4   • U R                  SSSSS/4/S5      $ )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³   r6   s    r0   Útest_forwardÚProxyClientTests.test_forward  s.   € ð ×$Ñ$Ø�˜& 6¨6Ð"2Ð3Ð4Ð6Fó
ð 	
r3   c                 ó6   • U R                  SSSS/4/SSS5      $ )zf
Try to post content in the request, and check that the proxy client
forward the body of the request.
r¶   r·   r¸   r¹   rº   ó   POSTó   Some contentr»   r6   s    r0   Útest_postDataÚProxyClientTests.test_postData'  s/   € ð
 ×$Ñ$Ø�˜& 6 (Ð+Ð,Ð.>ÀÈó
ð 	
r3   c                 ó*   • U R                  SS/ S5      $ )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 Foundr3   r»   r6   s    r0   Útest_statusWithMessageÚ'ProxyClientTests.test_statusWithMessage0  s   € ð
 ×$Ñ$ S¨,¸¸CÓ@Ð@r3   c           
      óx   • SnU R                  SSS[        [        U5      5      R                  S5      /4/U5      $ )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¶   r·   ó   Content-Lengthr‘   ©r³   r“   Úlenr”   ©r"   Údatas     r0   Útest_contentLengthÚ#ProxyClientTests.test_contentLength7  sE   € ð
 ˆØ×$Ñ$Ø�Ð+¬c´#°d³)«n×.CÑ.CÀGÓ.LÐ-MÐNÐOÐQUó
ð 	
r3   c           
      óv   • SnU R                  SSS[        [        U5      5      R                  S5      /4/USS9$ )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È   r‘   F)r­   rÉ   rË   s     r0   Útest_losesConnectionÚ%ProxyClientTests.test_losesConnectionA  sN   € ð
 ˆØ×$Ñ$ØØØ¤#¤c¨$£i£.×"7Ñ"7¸Ó"@Ð!AÐBÐCØØ ð %ð 
ð 	
r3   c                 óh   • [        SSSSSS.SS5      nU R                  UR                  SS	S
.5        g)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|   rz   r@   )ry   s   proxy-connectionr3   Nrª   ©ry   r«   )r   r   r!   )r"   r±   s     r0   Útest_headersCleanupsÚ%ProxyClientTests.test_headersCleanupsO  sC   € ô ØØØØ$¸6ÑBØØó
ˆð 	×ÑØ�N‰N¨ÀXÑNõ	
r3   c                 ó†   • SSSS.nUR                  5       nSUS'   US	 [        SSS	US
S5      nU R                  USU5        g)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.
rz   s   300ó
   keep-alive)ry   rÙ   r«   rª   r«   rÓ   rÔ   r|   r3   Ns   GET /foo HTTP/1.0)Úcopyr   rŽ   )r"   r!   r¦   r±   s       r0   Útest_keepaliveNotForwardedÚ+ProxyClientTests.test_keepaliveNotForwardeda  sZ   € ð $Ø!Ø(ñ
ˆð
 "Ÿ,™,›.ˆØ)1ˆ˜Ñ&Ø˜MÐ*Ü˜V W¨k¸7ÀCÈÓNˆØ×"Ñ" 6Ð+?ÀÕQr3   c           	      óæ  • U R                  S5      nUR                  R                  SS/5        UR                  R                  SS/5        UR                  R                  SS/5        U R                  USS	0S
9nU R	                  U5        S/S/S/S.nUR                  U R                  SSUR                  5       S5      5        U R                  USS[        UR                  5       5      S5        g)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/quxry   rz   )r!   r¹   s
   2010-01-01s   application/x-baz)s   Servers   Dateó   Content-Typer¶   r·   r3   N)
rv   r¢   ÚsetRawHeadersr�   r‡   r   rœ   Úitemsr§   r¡   )r"   r~   r±   r!   s       r0   Útest_defaultHeadersOverriddenÚ.ProxyClientTests.test_defaultHeadersOverriddenr  så   € ð ×"Ñ" 6Ó*ˆØ×Ñ×-Ñ-¨i¸*¸ÔFØ×Ñ×-Ñ-¨g¸
°|ÔDØ×Ñ×-Ñ-¨oÀ
¸|ÔLØ×%Ñ% g¸	À<Ð7PÐ%ÐQˆØ×Ñ˜&Ô!à�xØ#�_Ø2Ð3ñ
ˆð
 	×Ñ˜D×2Ñ2°3¸¸w¿}¹}»ÐPSÓTÔUØ×#Ñ# G¨S°%¼¸g¿m¹m»oÓ9NÐPSÕTr3   rJ   )rÓ   Nr3   )rÓ   r3   T)rK   rL   rM   rN   rO   rs   rv   r�   r‡   rŽ   rœ   r§   r³   r¼   rÁ   rÄ   rÍ   rÐ   rÖ   rÛ   rá   rP   rJ   r3   r0   rc   rc   Œ   sh   † ñòTò"ôUò"
òò"#ò:ð2 ØØô*.òX
ò
òAò
ò
ò
ò$Rõ"Ur3   rc   c                   ó$   • \ rS rSrSrS rS rSrg)ÚProxyClientFactoryTestsi‡  z"
Tests for L{ProxyClientFactory}.
c                 óÐ  • [        S/5      n[        SSSSS0SU5      nUR                  SS5        U R                  UR                  S	5        U R                  UR
                  S
5        U R                  [        UR                  R                  5       5      SS/4/5        U R                  SR                  UR                  5      S5        U R                  UR                  S5        g)zk
Check that L{ProxyClientFactory.clientConnectionFailed} produces
a B{501} response to the parent request.
r@   rÓ   rÔ   r|   ry   rz   Ú Niõ  s   Gateway errorrÞ   r3   s   <H1>Could not connect</H1>r¬   )r   r   ÚclientConnectionFailedr   rŸ   r    r¡   r¢   r£   r—   r¥   r°   )r"   r~   r-   s      r0   Ú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Õ-r3   c                 ó\  • [        SSSSS0SS5      nUR                  S5      nU R                  U[        5        U R	                  UR
                  S5        U R	                  UR                  S5        U R	                  UR                  S5        U R	                  UR                  SSS	.5        g)
z‡
L{ProxyClientFactory.buildProtocol} should produce a L{ProxyClient}
with the same values of attributes (with updates on the headers).
rÓ   rÔ   r|   ry   rz   s	   Some dataNrª   rÕ   )	r   r   r   r   r   Úcommandr    rÌ   r!   )r"   r-   Úprotos      r0   Útest_buildProtocolÚ*ProxyClientFactoryTests.test_buildProtocol   s›   € ô
 %Ø�G˜[¨9°lÐ*CÀ\ÐSWó
ˆð ×%Ñ% dÓ+ˆØ×Ñ˜e¤[Ô1Ø×Ñ˜Ÿ™¨Ô/Ø×Ñ˜Ÿ™ WÔ-Ø×Ñ˜Ÿ™ \Ô2Ø×ÑØ�M‰M |ÀHÑMõ	
r3   rJ   N)rK   rL   rM   rN   rO   rè   rí   rP   rJ   r3   r0   rä   rä   ‡  s   † ñò.õ(
r3   rä   c                   ó:   • \ rS rSrSrS
S jrS rS rS rS r	Sr
g	)ÚProxyRequestTestsi²  z
Tests for L{ProxyRequest}.
c                 óT  • [        5       n[        U5      n[        5       n[        USU5      nUR	                  [        U5      5        UR                  U5        UR                  USU-   S5        U R                  [        UR                  5      S5        U R                  UR                  S   S   S5        U R                  UR                  S   S   S5        UR                  S   S   n	U R                  U	[        5        U R                  U	R                  U5        U R                  U	R                  S5        U R                  U	R                  S	S
05        U R                  U	R                  U5        U R                  U	R                   U5        U R                  U	R"                  U5        g)zm
Build a request pointing at C{uri}, and check that a proxied request
is created, pointing a C{expectedURI}.
Fs   http://example.comr|   r¬   r   úexample.coméP   é   r   ó   example.comN)r   rR   r   r   Ú	gotLengthrÊ   ÚhandleContentChunkÚrequestReceivedr   r   r   r   rë   Úversionr!   rÌ   r    Úfather)
r"   r#   r$   r   rÌ   r)   r*   r&   r~   r-   s
             r0   Ú_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Ø×Ñ˜Ÿ™¨Õ1r3   c                 ó&   • U R                  SS5      $ )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û   r6   s    r0   Útest_processÚProxyRequestTests.test_processÑ  s   € ð × Ñ  ¨kÓ:Ð:r3   c                 ó&   • U R                  SS5      $ )zƒ
If the incoming request doesn't contain a slash,
L{ProxyRequest.process} should add one when instantiating
L{ProxyClientFactory}.
r3   r{   rÿ   r6   s    r0   Ú test_processWithoutTrailingSlashÚ2ProxyRequestTests.test_processWithoutTrailingSlashÝ  s   € ð × Ñ   dÓ+Ð+r3   c                 ó*   • U R                  SSSS5      $ )zT
L{ProxyRequest.process} should be able to retrieve request body and
to forward it.
rþ   r¿   rÀ   rÿ   r6   s    r0   Útest_processWithDataÚ&ProxyRequestTests.test_processWithDataå  s   € ð
 × Ñ  ¨k¸7ÀOÓTÐTr3   c                 óv  • [        5       n[        U5      n[        5       n[        USU5      nUR	                  S5        UR                  SSS5        U R                  [        UR                  5      S5        U R                  UR                  S   S   S5        U R                  UR                  S   S   S5        g	)
z€
Check that L{ProxyRequest.process} correctly parse port in the incoming
URL, and create an outgoing connection with this port.
Fr   rÓ   s   http://example.com:1234/foo/barr|   r¬   rò   r   N)	r   rR   r   r   rö   rø   r   rÊ   r   )r"   r)   r*   r&   r~   s        r0   Ú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Õ8r3   rJ   N)rÓ   r3   )rK   rL   rM   rN   rO   rû   r   r  r  r	  rP   rJ   r3   r0   rð   rð   ²  s!   † ñô2ò4
;ò,òUõ9r3   rð   c                   ó   • \ rS rSrSrS rSrg)ÚDummyFactoryiþ  z6
A simple holder for C{host} and C{port} information.
c                 ó   • Xl         X l        g )N©r+   r,   )r"   r+   r,   s      r0   rV   ÚDummyFactory.__init__  s   € ØŒ	Ø�	r3   r  N)rK   rL   rM   rN   rO   rV   rP   rJ   r3   r0   r  r  þ  s   † ñõr3   r  c                   ó   • \ rS rSrSrS rSrg)ÚReverseProxyRequestTestsi  z#
Tests for L{ReverseProxyRequest}.
c                 ó$  • [        5       n[        U5      n[        5       n[        USU5      n[	        SS5      Ul        UR                  S5        UR                  SSS5        U R                  [        UR                  5      S5        U R                  UR                  S   S   S5        U R                  UR                  S   S   S5        UR                  S   S	   nU R                  U[        5        U R                  UR                  S
S05        g)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¬   rô   r   rõ   N)r   rR   r   r	   r  r-   rö   rø   r   rÊ   r   r   r   r!   )r"   r)   r*   r&   r~   r-   s         r0   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ÕDr3   rJ   N)rK   rL   rM   rN   rO   r   rP   rJ   r3   r0   r  r    s   † ñõEr3   r  N)rO   Ú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   rR   rc   rä   rð   r  r  rJ   r3   r0   Ú<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r3   