ó
    ×›‘h	ß ã                  óÞ  • S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	J
r
JrJrJrJr  SSKJrJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSKJrJr  SSKJrJ r J!r!  SSK"J#r#J$r$  SSK%J&r&J'r'J(r(  SSK)J*r*  SSK+J,r,J-r-  SSK.J/r/  SSK0J1r1  SSK2J3r3J4r4J5r5J6r6  SSK7J8r8  SSK9J:r:  SSK;J<r<  SSK=J>r>  SSK?J@r@JArA  SSKBJCrC  SSKDJErEJFrF  SSKGJHrHJIrIJJrJ  SSKKJLrLJMrMJNrNJOrOJPrPJQrQJRrR  SSKSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[  SSK\J]r]  SS K^J_r_  SS!K`JaraJbrbJcrcJdrdJereJfrf  SS"KgJhrhJiri  \	(       a  \Frj\krlO\krj\Frl SS#KJmrn  \nrmS$roSS%KpJqrqJrrr  SS&KsJtrt  SS'KuJvrv  SS(KwJxrxJyry  \" \r5       " S) S*5      5       rz " S, S-\-5      r| " S. S/5      r} " S0 S1\F5      r~S2rS3r€S4r�S5r‚S6rƒS7r„ " S8 S95      r… " S: S;5      r† " S< S=5      r‡ " S> S?\,5      rˆ " S@ SA\F\…5      r‰ " SB SC5      rŠ " SD SE5      r‹\" \c5       " SF SG5      5       rŒ " SH SI\F\…\Š\‹5      r� " SJ SK\…\h\E5      rŽ " SL SM\…\i\E5      r�\" \o(       + SN5       " SO SP\F\…\‹5      5       r� " SQ SR\F5      r‘ " SS ST\F\…5      r’ " SU SV5      r“ " SW SX\F\“5      r” " SY SZ\F\“\…\Š5      r• " S[ S\\:" \f5      5      r– " S] S^\–5      r— " S_ S`\F\…\Š5      r˜ " Sa Sb\-5      r™ " Sc Sd\F\…5      rš " Se Sf\F\…\Š5      r›/ SgQrœ " Sh Si\j5      r� " Sj Sk\…\�\Š\l5      rž " Sl Sm\…\�\Š\l5      rŸ " Sn So\65      r  " Sp Sq5      r¡ " Sr Ss\¡5      r¢ " St Su\F5      r£\" \o(       + SN5       " Sv Sw\F5      5       r¤ " Sx Sy\h\E5      r¥ " Sz S{\h\E5      r¦ " S| S}\i\E5      r§ " S~ S\i\E5      r¨g! \{ a    SrmS+ro GNf = f)€zD
Tests for L{twisted.web.client.Agent} and related new client APIs.
é    )ÚannotationsN)Ú	CookieJar)ÚBytesIO)ÚTYPE_CHECKINGÚDictÚListÚOptionalÚSequenceÚTuple)ÚSkipTestÚskipIf©Úimplementer)ÚverifyObject)ÚVersion)ÚdeferÚtask)ÚIPv4AddressÚIPv6Address)ÚCancelledErrorÚDeferredÚsucceed)ÚHostnameEndpointÚTCP4ClientEndpoint)ÚConnectionDoneÚConnectionLostÚConnectionRefusedError)ÚIOpenSSLClientConnectionCreator)ÚFactoryÚProtocol)ÚClock)ÚdeterministicResolvingReactor)ÚAccumulatingProtocolÚEventLoggingObserverÚMemoryReactorClockÚStringTransport)ÚglobalLogPublisher)ÚproxyForInterface)ÚgetDeprecationWarningString)ÚFailure)ÚFakeTransportÚIOPump)Ú!certificatesForAuthorityAndServer)ÚSynchronousTestCaseÚTestCase)ÚclientÚerrorÚhttp_headers)ÚHTTP11ClientProtocolÚPotentialDataLossÚRequestNotSentÚRequestTransmissionFailedÚResponseÚResponseFailedÚResponseNeverReceived)ÚURIÚBrowserLikePolicyForHTTPSÚFileBodyProducerÚHostnameCachingHTTPSPolicyÚHTTPConnectionPoolÚRequestÚResponseDoneÚ_HTTP11ClientFactory)ÚSchemeNotSupported)ÚHeaders)ÚUNKNOWN_LENGTHÚIAgentÚIAgentEndpointFactoryÚIBodyProducerÚIPolicyForHTTPSÚ	IResponse)ÚMethodInjectionTestsMixinÚURIInjectionTestsMixin)ÚsslT)ÚClientTLSOptionsÚIOpenSSLTrustRoot)ÚoptionsForClientTLS)Útls)ÚTLSMemoryBIOFactoryÚTLSMemoryBIOProtocolc                  ó"   • \ rS rSrSrSrS rSrg)ÚCustomOpenSSLTrustRootéh   FNc                ó   • SU l         Xl        g ©NT©ÚcalledÚcontext)ÚselfrZ   s     Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/test/test_agent.pyÚ_addCACertsToContextÚ+CustomOpenSSLTrustRoot._addCACertsToContextm   s   € ØˆDŒKØ"�Ló    rX   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rY   rZ   r]   Ú__static_attributes__© r_   r\   rT   rT   h   s   † àˆØˆõ	#r_   rT   Fc                  ó(   • \ rS rSrSrSS jrS rSrg)ÚStubHTTPProtocolér   a:  
A protocol like L{HTTP11ClientProtocol} but which does not actually know
HTTP/1.1 and only collects requests in a list.

@ivar requests: A C{list} of two-tuples.  Each time a request is made, a
    tuple consisting of the request and the L{Deferred} returned from the
    request method is appended to this list.
c                ó    • / U l         SU l        g )NÚ	QUIESCENT©ÚrequestsÚstate©r[   s    r\   Ú__init__ÚStubHTTPProtocol.__init__|   s   € ØCEˆŒØ ˆ�
r_   c                óR   • [        5       nU R                  R                  X45        U$ )zj
Capture the given request for later inspection.

@return: A L{Deferred} which this code will never fire.
)r   rl   Úappend)r[   ÚrequestÚresults      r\   rs   ÚStubHTTPProtocol.request€   s%   € ô “ˆØ�‰×Ñ˜gÐ.Ô/Øˆr_   rk   N©ÚreturnÚNone)r`   ra   rb   rc   Ú__doc__ro   rs   rd   re   r_   r\   rg   rg   r   s   † ñô!õr_   rg   c                  ó    • \ rS rSrS rS rSrg)ÚFileConsumeré‹   c                ó   • Xl         g ©N©Ú
outputFile)r[   r€   s     r\   ro   ÚFileConsumer.__init__Œ   s   € Ø$�r_   c                ó:   • U R                   R                  U5        g r~   )r€   Úwrite)r[   Úbytess     r\   rƒ   ÚFileConsumer.write�   s   € Ø�‰×Ñ˜eÕ$r_   r   N)r`   ra   rb   rc   ro   rƒ   rd   re   r_   r\   r{   r{   ‹   s   † ò%õ%r_   r{   c                  ól   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rSrg)ÚFileBodyProducerTestsé“   ze
Tests for the L{FileBodyProducer} which reads bytes from a file and writes
them to an L{IConsumer}.
c                ó   • S $ )a<  
This method can be used as the C{terminationPredicateFactory} for a
L{Cooperator}.  It returns a predicate which immediately returns
C{False}, indicating that no more work should be done this iteration.
This has the result of only allowing one iteration of a cooperative
task to be run per L{Cooperator} iteration.
c                 ó   • grW   re   re   r_   r\   Ú<lambda>Ú4FileBodyProducerTests._termination.<locals>.<lambda>¡   s   € �tr_   re   rn   s    r\   Ú_terminationÚ"FileBodyProducerTests._termination™   s
   € ñ Ðr_   c                ó†   • / U l         [        R                  " U R                  U R                   R                  5      U l        g)zt
Create a L{Cooperator} hooked up to an easily controlled, deterministic
scheduler to use with L{FileBodyProducer}.
N)Ú
_scheduledr   Ú
Cooperatorr�   rr   Ú
cooperatorrn   s    r\   ÚsetUpÚFileBodyProducerTests.setUp£   s-   € ð
 ˆŒÜŸ/š/¨$×*;Ñ*;¸T¿_¹_×=SÑ=SÓTˆ�r_   c           
     óf   • U R                  [        [        [        [	        S5      5      5      5        g)z9
L{FileBodyProducer} instances provide L{IBodyProducer}.
r_   N)Ú
assertTruer   rG   r<   r   rn   s    r\   Útest_interfaceÚ$FileBodyProducerTests.test_interface«   s!   € ð 	�‰œ¤]Ô4DÄWÈSÃ\Ó4RÓSÕTr_   c                óì   •  " S S5      n " S S5      n[        U" 5       5      nU R                  [        UR                  5        [        U" 5       5      nU R                  [        UR                  5        g)z¤
If the L{FileBodyProducer} is constructed with a file-like object
without either a C{seek} or C{tell} method, its C{length} attribute is
set to C{UNKNOWN_LENGTH}.
c                  ó   • \ rS rSrS rSrg)Ú9FileBodyProducerTests.test_unknownLength.<locals>.HasSeeké¸   c                ó   • g r~   re   )r[   ÚoffsetÚwhences      r\   ÚseekÚ>FileBodyProducerTests.test_unknownLength.<locals>.HasSeek.seek¹   ó   € Ør_   re   N)r`   ra   rb   rc   r    rd   re   r_   r\   ÚHasSeekr›   ¸   ó   † õr_   r£   c                  ó   • \ rS rSrS rSrg)Ú9FileBodyProducerTests.test_unknownLength.<locals>.HasTellé¼   c                ó   • g r~   re   rn   s    r\   ÚtellÚ>FileBodyProducerTests.test_unknownLength.<locals>.HasTell.tell½   r¢   r_   re   N)r`   ra   rb   rc   r©   rd   re   r_   r\   ÚHasTellr¦   ¼   r¤   r_   r«   N)r<   ÚassertEqualrD   Úlength)r[   r£   r«   Úproducers       r\   Útest_unknownLengthÚ(FileBodyProducerTests.test_unknownLength±   sX   € ÷	ñ 	÷	ñ 	ô $¡G£IÓ.ˆØ×Ñœ¨¯©Ô9Ü#¡G£IÓ.ˆØ×Ñœ¨¯©Õ9r_   c                óæ   • Sn[        U5      nUR                  S5        [        U5      nU R                  [	        U5      S-
  UR
                  5        U R                  UR                  5       S5        g)zÁ
If the L{FileBodyProducer} is constructed with a file-like object with
both C{seek} and C{tell} methods, its C{length} attribute is set to the
size of the file as determined by those methods.
s   here are some bytesé   N)r   r    r<   r¬   Úlenr­   r©   )r[   Ú
inputBytesÚ	inputFiler®   s       r\   Útest_knownLengthÚ&FileBodyProducerTests.test_knownLengthÅ   s]   € ð ,ˆ
Ü˜JÓ'ˆ	Ø�‰�qÔÜ# IÓ.ˆØ×Ñœ˜Z›¨1Ñ,¨h¯o©oÔ>Ø×Ñ˜Ÿ™Ó)¨1Õ-r_   c                ó€   • [        [        S5      5      nU R                  [        R                  UR
                  5        g)z_
If no L{Cooperator} instance is passed to L{FileBodyProducer}, the
global cooperator is used.
r_   N)r<   r   r¬   r   Ú	cooperateÚ
_cooperate)r[   r®   s     r\   Útest_defaultCooperatorÚ,FileBodyProducerTests.test_defaultCooperatorÒ   s,   € ô
 $¤G¨C£LÓ1ˆØ×ÑœŸ™¨×)<Ñ)<Õ=r_   c                óÒ  • SnSn[        5       n[        U5      n[        [        U5      U R                  U5      nUR	                  U5      n[        [        U5      U-  S-   5       H#  nU R                  R                  S5      " 5         M%     U R                  / U R                  5        U R                  XR                  5       5        U R                  SU R                  U5      5        g)z®
L{FileBodyProducer.startProducing} starts writing bytes from the input
file to the given L{IConsumer} and returns a L{Deferred} which fires
when they have all been written.
ó   hello, worldé   é   r   N)r   r{   r<   r’   ÚstartProducingÚranger³   r�   Úpopr¬   ÚgetvalueÚsuccessResultOf)r[   ÚexpectedResultÚreadSizeÚoutputÚconsumerr®   ÚcompleteÚis           r\   Útest_startProducingÚ)FileBodyProducerTests.test_startProducingÚ   s½   € ð )ˆØˆÜ“ˆÜ Ó'ˆÜ#¤G¨NÓ$;¸T¿_¹_ÈhÓWˆØ×*Ñ*¨8Ó4ˆÜ”s˜>Ó*¨hÑ6¸Ñ:Ö;ˆAØ�O‰O×Ñ Ô"Ö$ñ <à×Ñ˜˜TŸ_™_Ô-Ø×Ñ˜¯©Ó):Ô;Ø×Ñ˜˜t×3Ñ3°HÓ=Õ>r_   c                óN  • SnSn[        U5      n[        X0R                  U5      n[        [        5       5      nUR	                  U5        [        [        U5      U-  S-   5       H#  nU R                  R                  S5      " 5         M%     U R                  UR                  5        g)zg
When L{FileBodyProducer} reaches end-of-file on the input file given to
it, the input file is closed.
é   s   some friendly bytesé   r   N)r   r<   r’   r{   rÁ   rÂ   r³   r�   rÃ   r–   Úclosed)r[   rÇ   r´   rµ   r®   rÉ   rË   s          r\   Útest_inputClosedAtEOFÚ+FileBodyProducerTests.test_inputClosedAtEOFì   s†   € ð
 ˆØ+ˆ
Ü˜JÓ'ˆ	Ü# I¯©ÀÓIˆÜ¤£	Ó*ˆØ×Ñ Ô)Ü”s˜:“¨(Ñ2°QÑ6Ö7ˆAØ�O‰O×Ñ Ô"Ö$ñ 8à�‰˜	×(Ñ(Õ)r_   c                ó  •  " S S5      n[        U" 5       U R                  5      nUR                  [        [	        5       5      5      nU R
                  R                  S5      " 5         U R                  U5      R                  [        5        g)z¼
If a read from the input file fails while producing bytes to the
consumer, the L{Deferred} returned by
L{FileBodyProducer.startProducing} fires with a L{Failure} wrapping
that exception.
c                  ó   • \ rS rSrS rSrg)ÚGFileBodyProducerTests.test_failedReadWhileProducing.<locals>.BrokenFilei  c                ó   • [        S5      e)NzSimulated bad thing)ÚOSError)r[   Úcounts     r\   ÚreadÚLFileBodyProducerTests.test_failedReadWhileProducing.<locals>.BrokenFile.read  s   € ÜÐ3Ó4Ð4r_   re   N)r`   ra   rb   rc   rÚ   rd   re   r_   r\   Ú
BrokenFilerÖ     s   † õ5r_   rÜ   r   N)
r<   r’   rÁ   r{   r   r�   rÃ   ÚfailureResultOfÚtrapÚIOError)r[   rÜ   r®   rÊ   s       r\   Útest_failedReadWhileProducingÚ3FileBodyProducerTests.test_failedReadWhileProducingû   se   € ÷	5ñ 	5ô $¡J£L°$·/±/ÓBˆØ×*Ñ*¬<¼»	Ó+BÓCˆØ�‰×Ñ˜AÔÔ Ø×Ñ˜XÓ&×+Ñ+¬GÕ4r_   c                ó’  • SnSn[        5       n[        U5      n[        U5      n[        XPR                  U5      nUR	                  U5      nUR                  5         U R                  UR                  5        U R                  R                  S5      " 5         U R                  SUR                  5       5        U R                  U5        g)z…
When the L{Deferred} returned by L{FileBodyProducer.startProducing} is
cancelled, the input file is closed and the task is stopped.
r¾   r¿   r   r_   N)r   r{   r<   r’   rÁ   Úcancelr–   rÑ   r�   rÃ   r¬   rÄ   ÚassertNoResult©r[   rÆ   rÇ   rÈ   rÉ   rµ   r®   rÊ   s           r\   Útest_cancelWhileProducingÚ/FileBodyProducerTests.test_cancelWhileProducing  sŸ   € ð
 )ˆØˆÜ“ˆÜ Ó'ˆÜ˜NÓ+ˆ	Ü# I¯©ÀÓIˆØ×*Ñ*¨8Ó4ˆØ�‰ÔØ�‰˜	×(Ñ(Ô)Ø�‰×Ñ˜AÔÔ Ø×Ñ˜˜fŸo™oÓ/Ô0Ø×Ñ˜HÕ%r_   c                ó’  • SnSn[        5       n[        U5      n[        U5      n[        XPR                  U5      nUR	                  U5      nUR                  5         U R                  UR                  5        U R                  R                  S5      " 5         U R                  SUR                  5       5        U R                  U5        g)zñ
L{FileBodyProducer.stopProducing} stops the underlying L{IPullProducer}
and the cooperative task responsible for calling C{resumeProducing} and
closes the input file but does not cause the L{Deferred} returned by
C{startProducing} to fire.
r¾   r¿   r   r_   N©r   r{   r<   r’   rÁ   ÚstopProducingr–   rÑ   r�   rÃ   r¬   rÄ   rä   rå   s           r\   Útest_stopProducingÚ(FileBodyProducerTests.test_stopProducing  s¡   € ð )ˆØˆÜ“ˆÜ Ó'ˆÜ˜NÓ+ˆ	Ü# I¯©ÀÓIˆØ×*Ñ*¨8Ó4ˆØ×ÑÔ Ø�‰˜	×(Ñ(Ô)Ø�‰×Ñ˜AÔÔ Ø×Ñ˜˜fŸo™oÓ/Ô0Ø×Ñ˜HÕ%r_   c                ó  • SnSn[        5       n[        U5      n[        [        U5      U R                  U5      nUR	                  U5      nU R
                  R                  S5      " 5         U R                  UR                  5       USS 5        UR                  5         U R
                  R                  S5      " 5         U R                  UR                  5       USS 5        U R                  / U R
                  5        U R                  U5        g)zv
L{FileBodyProducer.pauseProducing} temporarily suspends writing bytes
from the input file to the given L{IConsumer}.
r¾   r²   r   N)r   r{   r<   r’   rÁ   r�   rÃ   r¬   rÄ   ÚpauseProducingrä   )r[   rÆ   rÇ   rÈ   rÉ   r®   rÊ   s          r\   Útest_pauseProducingÚ)FileBodyProducerTests.test_pauseProducing2  sÞ   € ð
 )ˆØˆÜ“ˆÜ Ó'ˆÜ#¤G¨NÓ$;¸T¿_¹_ÈhÓWˆØ×*Ñ*¨8Ó4ˆØ�‰×Ñ˜AÔÔ Ø×Ñ˜Ÿ™Ó*¨N¸2¸AÐ,>Ô?Ø×ÑÔ!ð 	�‰×Ñ˜AÔÔ ð 	×Ñ˜Ÿ™Ó*¨N¸2¸AÐ,>Ô?Ø×Ñ˜˜TŸ_™_Ô-Ø×Ñ˜HÕ%r_   c                óê  • SnSn[        5       n[        U5      n[        [        U5      U R                  U5      nUR	                  U5        U R
                  R                  S5      " 5         U R                  USU UR                  5       5        UR                  5         UR                  5         U R
                  R                  S5      " 5         U R                  USUS-   UR                  5       5        g)z¶
L{FileBodyProducer.resumeProducing} re-commences writing bytes from the
input file to the given L{IConsumer} after it was previously paused
with L{FileBodyProducer.pauseProducing}.
r¾   r²   r   NrÐ   )r   r{   r<   r’   rÁ   r�   rÃ   r¬   rÄ   rî   ÚresumeProducing)r[   rÆ   rÇ   rÈ   rÉ   r®   s         r\   Útest_resumeProducingÚ*FileBodyProducerTests.test_resumeProducingL  sÆ   € ð )ˆØˆÜ“ˆÜ Ó'ˆÜ#¤G¨NÓ$;¸T¿_¹_ÈhÓWˆØ×Ñ Ô)Ø�‰×Ñ˜AÔÔ Ø×Ñ˜¨	¨Ð2°F·O±OÓ4EÔFØ×ÑÔ!Ø× Ñ Ô"Ø�‰×Ñ˜AÔÔ Ø×Ñ˜¨¨(°Q©,Ð7¸¿¹Ó9JÕKr_   c                ó²  • SnSn[        5       n[        U5      n[        U5      n[        XPR                  U5      nUR	                  U5      nUR                  5         UR                  5         U R                  UR                  5        U R                  R                  S5      " 5         U R                  SUR                  5       5        U R                  U5        g)z^
L{FileBodyProducer.stopProducing} can be called more than once without
raising an exception.
s   testr¿   r   r_   Nré   rå   s           r\   Útest_multipleStopÚ'FileBodyProducerTests.test_multipleStop_  s­   € ð
 !ˆØˆÜ“ˆÜ Ó'ˆÜ˜NÓ+ˆ	Ü# I¯©ÀÓIˆØ×*Ñ*¨8Ó4ˆØ×ÑÔ Ø×ÑÔ Ø�‰˜	×(Ñ(Ô)Ø�‰×Ñ˜AÔÔ Ø×Ñ˜˜fŸo™oÓ/Ô0Ø×Ñ˜HÕ%r_   )r�   r’   N)r`   ra   rb   rc   ry   r�   r“   r—   r¯   r¶   r»   rÌ   rÒ   rà   ræ   rë   rï   ró   rö   rd   re   r_   r\   r‡   r‡   “   sP   † ñò
òUòUò:ò(.ò>ò?ò$*ò5ò"&ò$&ò(&ò4Lõ&&r_   r‡   ú	127.0.0.7ú::7z	127.0.0.8z	127.0.0.9z
127.0.0.10z
127.0.0.11c                  ó>   • \ rS rSrSrS r " S S5      rS rS rSr	g	)
ÚFakeReactorAndConnectMixini{  z…
A test mixin providing a testable C{Reactor} class and a dummy C{connect}
method which allows instances to pretend to be endpoints.
c                óÄ   • [        5       n[        U[        /[        /[        /[
        /[        /[        /S/S/S.S9nUR                  Ul        UR                  Ul	        U$ )a.  
Create a L{MemoryReactorClock} and give it some hostnames it can
resolve.

@return: a L{MemoryReactorClock}-like object with a slightly limited
    interface (only C{advance} and C{tcpClients} in addition to its
    formally-declared reactor interfaces), which can resolve a fixed
    set of domains.
rø   rù   )úexample.comzipv6.example.comzexample.netzexample.orgÚfoozfoo.comrø   rù   )ÚhostMap)
r%   r"   ÚEXAMPLE_COM_IPÚEXAMPLE_COM_V6_IPÚEXAMPLE_NET_IPÚEXAMPLE_ORG_IPÚFOO_LOCAL_IPÚ
FOO_COM_IPÚ
tcpClientsÚadvance)r[   ÚmrcÚdrrs      r\   ÚcreateReactorÚ(FakeReactorAndConnectMixin.createReactor�  sg   € ô !Ó"ˆÜ+Øä .Ð/Ü%6Ð$7Ü .Ð/Ü .Ð/Ü$�~Ü&˜<Ø)˜]Ø�wñ	ñ
ˆð  Ÿ™ˆŒØ—k‘kˆŒØˆ
r_   c                  ó$   • \ rS rSrSrS rS rSrg)Ú'FakeReactorAndConnectMixin.StubEndpointi   zŒ
Endpoint that wraps existing endpoint, substitutes StubHTTPProtocol, and
resulting protocol instances are attached to the given test case.
c                ó¸   ^ • UT l         UT l        S n[        U[        T R                   5      5      T l        [        5       T l        U 4S jT R                  l        g )Nc                 ó   • g)zthis function does nothingNre   re   r_   r\   ÚnothingÚAFakeReactorAndConnectMixin.StubEndpoint.__init__.<locals>.nothingª  s   � r_   c                ó   >• TR                   $ r~   ©Úprotocol)Úaddrr[   s    €r\   r‹   ÚBFakeReactorAndConnectMixin.StubEndpoint.__init__.<locals>.<lambda>¯  s	   ø€ °d·m²mr_   )ÚendpointÚtestCaserA   ÚreprÚfactoryrg   r  ÚbuildProtocol)r[   r  r  r  s   `   r\   ro   Ú0FakeReactorAndConnectMixin.StubEndpoint.__init__¦  sE   ø€ Ø$ˆDŒMØ$ˆDŒMò1ô 0°¼¸d¿m¹mÓ9LÓMˆDŒLÜ,Ó.ˆDŒMÜ)CˆD�L‰LÕ&r_   c                ó¬   • U R                   U R                  l         U R                  R                  U R                  5        [        U R                   5      $ r~   )r  r  r  Úconnectr  r   )r[   ÚignoredFactorys     r\   r  Ú/FakeReactorAndConnectMixin.StubEndpoint.connect±  s7   € Ø%)§]¡]ˆD�M‰MÔ"Ø�M‰M×!Ñ! $§,¡,Ô/Ü˜4Ÿ=™=Ó)Ð)r_   )r  r  r  r  N)r`   ra   rb   rc   ry   ro   r  rd   re   r_   r\   ÚStubEndpointr     s   † ñ	ò
		Dõ	*r_   r!  c                óf   ^ ^• [         R                  " U5      nUR                  mUU 4S jUl        U$ )zr
Return an Agent suitable for use in tests that wrap the Agent and want
both a fake reactor and StubHTTPProtocol.
c                 ó.   >• TR                  T" U 6 T5      $ r~   )r!  )ÚargsÚ_oldGetEndpointr[   s    €€r\   r‹   ÚEFakeReactorAndConnectMixin.buildAgentForWrapperTest.<locals>.<lambda>½  s   ø€ Ø×Ñ™o¨tÐ4°dÔ;r_   )r0   ÚAgentÚ_getEndpoint)r[   ÚreactorÚagentr%  s   `  @r\   ÚbuildAgentForWrapperTestÚ3FakeReactorAndConnectMixin.buildAgentForWrapperTest¶  s/   ù€ ô
 —’˜WÓ%ˆØ×,Ñ,ˆõ
ˆÔð ˆr_   c                óZ   • [        5       nUR                  S5        X l        [        U5      $ )z~
Fake implementation of an endpoint which synchronously
succeeds with an instance of L{StubHTTPProtocol} for ease of
testing.
N)rg   ÚmakeConnectionr  r   ©r[   r  r  s      r\   r  Ú"FakeReactorAndConnectMixin.connectÂ  s*   € ô $Ó%ˆØ×Ñ Ô%Ø ŒÜ�xÓ Ð r_   r  N)
r`   ra   rb   rc   ry   r
  r!  r+  r  rd   re   r_   r\   rû   rû   {  s    † ñò
÷>*ñ *ò,
õ	!r_   rû   c                  ó   • \ rS rSrSrS rSrg)ÚDummyEndpointiÎ  z)
An endpoint that uses a fake transport.
c                ól   • UR                  S 5      nUR                  [        5       5        [        U5      $ r~   ©r  r.  r&   r   r/  s      r\   r  ÚDummyEndpoint.connectÓ  s.   € Ø×(Ñ(¨Ó.ˆØ×Ñ¤Ó 1Ô2Ü�xÓ Ð r_   re   N©r`   ra   rb   rc   ry   r  rd   re   r_   r\   r2  r2  Î  s   † ñõ!r_   r2  c                  ó   • \ rS rSrSrS rSrg)ÚBadEndpointiÙ  z'
An endpoint that shouldn't be called.
c                ó   • [        S5      e)Nz(This endpoint should not have been used.)ÚRuntimeError)r[   r  s     r\   r  ÚBadEndpoint.connectÞ  s   € ÜÐEÓFÐFr_   re   Nr6  re   r_   r\   r8  r8  Ù  s   † ñõGr_   r8  c                  ó"   • \ rS rSrSrS r\rSrg)ÚDummyFactoryiâ  z'
Create C{StubHTTPProtocol} instances.
c                ó   • g r~   re   )r[   ÚquiescentCallbackÚmetadatas      r\   ro   ÚDummyFactory.__init__ç  s   € Ør_   re   N)	r`   ra   rb   rc   ry   ro   rg   r  rd   re   r_   r\   r=  r=  â  s   † ñòð  ƒHr_   r=  c                  ó`   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rSrg)ÚHTTPConnectionPoolTestsií  z,
Tests for the L{HTTPConnectionPool} class.
c                ó®   • U R                  5       U l        [        U R                  5      U l        [        U R                  l        SU R                  l        g ©NF)r
  ÚfakeReactorr>   Úpoolr=  Ú_factoryÚretryAutomaticallyrn   s    r\   r“   ÚHTTPConnectionPoolTests.setUpò  s=   € Ø×-Ñ-Ó/ˆÔÜ& t×'7Ñ'7Ó8ˆŒ	Ü)ˆ�	‰	Ôà',ˆ�	‰	Õ$r_   c                óÊ   ^ • T R                  T R                  R                  0 5        U 4S jnSnT R                  R                  U[	        5       5      nUR                  U5      $ )zc
If there are no cached connections,
L{HTTPConnectionPool.getConnection} returns a new connection.
c                óš   >• TR                  U [        5        TR                  U TR                  R                  R                  5       5        g r~   )ÚassertIsInstancerg   ÚassertNotInrG  Ú_connectionsÚvalues)Úconnr[   s    €r\   ÚgotConnectionÚMHTTPConnectionPoolTests.test_getReturnsNewIfCacheEmpty.<locals>.gotConnection   s7   ø€ Ø×!Ñ! $Ô(8Ô9à×Ñ˜T 4§9¡9×#9Ñ#9×#@Ñ#@Ó#BÕCr_   éÕ/  )r¬   rG  rO  ÚgetConnectionr2  ÚaddCallback)r[   rR  Ú
unknownKeyÚds   `   r\   Útest_getReturnsNewIfCacheEmptyÚ6HTTPConnectionPoolTests.test_getReturnsNewIfCacheEmptyù  sS   ø€ ð
 	×Ñ˜Ÿ™×/Ñ/°Ô4õ	Dð
 ˆ
Ø�I‰I×#Ñ# J´³Ó@ˆØ�}‰}˜]Ó+Ð+r_   c                óV  • [        5       nUR                  [        5       5        U R                  R	                  SU5        U R                  UR                  R                  S5        U R                  XR                  R                  S   5        U R                  R                  S5        U R                  UR                  R                  S5        U R                  XR                  R                  S   5        U R                  XR                  R                  5        U R                  R                  S5        U R                  UR                  R                  S5        U R                  XR                  R                  S   5        U R                  XR                  R                  5        g)z”
If a connection is put back to the pool, a 240-sec timeout is started.

When the timeout hits, the connection is closed and removed from the
pool.
©Úhttpó   example.coméP   Féï   gš™™™™™ñ?TN)rg   r.  r&   rG  Ú_putConnectionr¬   Ú	transportÚdisconnectingÚassertInrO  rF  r  Ú	_timeoutsrN  ©r[   r  s     r\   Útest_putStartsTimeoutÚ-HTTPConnectionPoolTests.test_putStartsTimeout	  s8  € ô $Ó%ˆØ×Ñ¤Ó 1Ô2Ø�	‰	× Ñ Ð!=¸xÔHð 	×Ñ˜×+Ñ+×9Ñ9¸5ÔAØ�‰�h§	¡	× 6Ñ 6Ð7SÑ TÔUð 	×Ñ× Ñ  Ô%Ø×Ñ˜×+Ñ+×9Ñ9¸5ÔAØ�‰�h§	¡	× 6Ñ 6Ð7SÑ TÔUØ�‰�h§	¡	× 3Ñ 3Ô4ð 	×Ñ× Ñ  Ô%Ø×Ñ˜×+Ñ+×9Ñ9¸4Ô@Ø×Ñ˜§9¡9×#9Ñ#9Ð:VÑ#WÔXØ×Ñ˜§9¡9×#6Ñ#6Õ7r_   c                óR  • U R                   n[        5       [        5       /nU H.  nUR                  [        5       5        UR	                  SU5        M0     U R                  UR                  S   U5        UR                  R                  5       n[        5       nUR                  [        5       5        UR	                  SU5        UR                  S   nU R                  [        U5      S5        U R                  XbS   U/5        U R                  U Vs/ s H  o3R                  R                  PM     snSS/5        U R                  US   R                  R                  S5        U R                  XBS      R                  5        U R                  US   UR                  5        gs  snf )z­
If an idle connection is put back in the cache and the max number of
persistent connections has been exceeded, one of the connections is
closed and removed from the cache.
r\  rÐ   rÀ   Fr   TN)rG  rg   r.  r&   ra  r¬   rO  re  Úcopyr³   rb  rc  r–   Ú	cancelledrN  )r[   rG  Ú
origCachedÚpÚtimeoutsÚnewProtocolÚ	newCacheds          r\   Útest_putExceedsMaxPersistentÚ4HTTPConnectionPoolTests.test_putExceedsMaxPersistent%  si  € ð �y‰yˆô 'Ó(Ô*:Ó*<Ð=ˆ
ÛˆAØ×Ñœ_Ó.Ô/Ø×ÑÐ <¸aÖ@ñ ð 	×Ñ˜×*Ñ*Ð+GÑHÈ*ÔUØ—>‘>×&Ñ&Ó(ˆô 'Ó(ˆØ×"Ñ"¤?Ó#4Ô5Ø×ÑÐ8¸+ÔFð ×%Ñ%Ð&BÑCˆ	Ø×Ñœ˜Y›¨Ô+Ø×Ñ˜°¡]°KÐ$@ÔAØ×Ñ¹YÓGºY¸Ÿ+™+×3Ô3¹YÑGÈ%ÐQVÈÔXØ×Ñ˜ A™×0Ñ0×>Ñ>ÀÔEØ�‰˜¨A¡Ñ/×9Ñ9Ô:Ø×Ñ˜ A™¨¯©Õ7ùò Hs   ÄF$c                ó¼  ^ • U 4S jn/ nUR                  U" SSS5      5        UR                  U" SSS5      5        U" SSS5        U" SSS5        T R                  T R                  R                  S   U5        T R                  [	        T R                  R                  S	   5      S
5        T R                  [	        T R                  R                  S   5      S
5        g)zq
C{maxPersistentPerHost} is enforced per C{(scheme, host, port)}:
different keys have different max connections.
c                óŠ   >• [        5       nUR                  [        5       5        TR                  R	                  XU4U5        U$ r~   )rg   r.  r&   rG  ra  )ÚschemeÚhostÚportrm  r[   s       €r\   ÚaddProtocolÚFHTTPConnectionPoolTests.test_maxPersistentPerHost.<locals>.addProtocolI  s:   ø€ Ü Ó"ˆAØ×Ñœ_Ó.Ô/Ø�I‰I×$Ñ$ f°DÐ%9¸1Ô=ØˆHr_   r]  r^  r_  Úhttpsé»  ó   www2.example.comr\  )rz  r^  r{  rÀ   )r]  r|  r_  N)rr   r¬   rG  rO  r³   )r[   rx  Ú
persistents   `  r\   Útest_maxPersistentPerHostÚ1HTTPConnectionPoolTests.test_maxPersistentPerHostC  sÉ   ø€ õ	ð ˆ
Ø×Ñ™+ f¨n¸bÓAÔBØ×Ñ™+ f¨n¸bÓAÔBÙ�G˜^¨SÔ1Ù�FÐ/°Ô4à×ÑØ�I‰I×"Ñ"Ð#?Ñ@À*ô	
ð 	×Ñœ˜TŸY™Y×3Ñ3Ð4RÑSÓTÐVWÔXØ×ÑÜ�—	‘	×&Ñ&Ð'HÑIÓJÈAõ	
r_   c                óø   ^ ^• [        5       mTR                  [        5       5        T R                  R	                  ST5        UU 4S jnT R                  R                  S[        5       5      R                  U5      $ )z„
Getting an address which has a cached connection returns the cached
connection, removes it from the cache and cancels its timeout.
r\  c                óJ  >• TR                  TU 5        TR                  U TR                  R                  S   5        TR                  R                  S5        TR                  U R                  R                  S5        TR                  U TR                  R                  5        g )Nr\  éñ   F)
ÚassertIdenticalrN  rG  rO  rF  r  r¬   rb  rc  re  )rQ  r  r[   s    €€r\   rR  ÚGHTTPConnectionPoolTests.test_getCachedConnection.<locals>.gotConnectiong  s{   ø€ à× Ñ  ¨4Ô0Ø×Ñ˜T 4§9¡9×#9Ñ#9Ð:VÑ#WÔXà×Ñ×$Ñ$ SÔ)Ø×Ñ˜TŸ^™^×9Ñ9¸5ÔAØ×Ñ˜T 4§9¡9×#6Ñ#6Õ7r_   )rg   r.  r&   rG  ra  rU  r8  rV  )r[   rR  r  s   ` @r\   Útest_getCachedConnectionÚ0HTTPConnectionPoolTests.test_getCachedConnection]  se   ù€ ô $Ó%ˆØ×Ñ¤Ó 1Ô2Ø�	‰	× Ñ Ð!=¸xÔHö	8ð �y‰y×&Ñ&Ø(Ü‹Mó
÷ ‰+�mÓ
$ð	%r_   c                ó  ^ ^^• [        5       mTR                  [        5       5        SmT R                  R	                  TT5        UUU 4S jnT R                  R                  T[        5       5      nUR                  U5      $ )zB
The pool's C{_newConnection} method constructs a new connection.
rT  c                óä   >• TR                  TU 5        TR                  TTR                  R                  T   5        TR	                  U TR                  R                  R                  5       5        g r~   )ÚassertNotIdenticalrd  rG  rO  rN  rP  )ÚnewConnectionÚkeyr  r[   s    €€€r\   rR  ÚAHTTPConnectionPoolTests.test_newConnection.<locals>.gotConnection  sS   ø€ à×#Ñ# H¨mÔ<à�M‰M˜( D§I¡I×$:Ñ$:¸3Ñ$?Ô@à×Ñ˜]¨D¯I©I×,BÑ,B×,IÑ,IÓ,KÕLr_   )rg   r.  r&   rG  ra  Ú_newConnectionr2  rV  )r[   rR  rX  r‹  r  s   `  @@r\   Útest_newConnectionÚ*HTTPConnectionPoolTests.test_newConnectionu  sf   ú€ ô
 $Ó%ˆØ×Ñ¤Ó 1Ô2ØˆØ�	‰	× Ñ   hÔ/÷	Mð �I‰I×$Ñ$ S¬-«/Ó:ˆØ�}‰}˜]Ó+Ð+r_   c                ó$  • U R                   nSn[        5       [        5       /nU H-  nUR                  [        5       5        UR	                  X$5        M/     U R                  UR                  U   U5        SUS   l        / nU R                   R                  U[        5       5      R                  UR                  5        U R                  US   US   5        U R                  UR                  U   / 5        U R                  UR                  0 5        g)zc
When getting connections out of the cache, disconnected connections
are removed and not returned.
r\  ÚDISCONNECTEDr   rÀ   N)rG  rg   r.  r&   ra  r¬   rO  rm   rU  r8  rV  rr   rƒ  re  )r[   rG  r‹  rl  rm  rt   s         r\   Útest_getSkipsDisconnectedÚ1HTTPConnectionPoolTests.test_getSkipsDisconnectedŠ  sî   € ð
 �y‰yˆØ*ˆô 'Ó(Ô*:Ó*<Ð=ˆ
ÛˆAØ×Ñœ_Ó.Ô/Ø×Ñ Ö'ñ ð 	×Ñ˜×*Ñ*¨3Ñ/°Ô<ð -ˆ
�1‰Ôð ˆØ�	‰	×Ñ ¤[£]Ó3×?Ñ?ÀÇÁÔNØ×Ñ˜V A™Y¨
°1©Ô6ð 	×Ñ˜×*Ñ*¨3Ñ/°Ô4Ø×Ñ˜Ÿ™¨Õ,r_   c                ó*  • [        5       nU R                  UR                  S5        [        R                  " U [
        5      nSUl        U R                  R                  SU5        U R                  S[        U5      5        US   nUS   nU R                  UR                  [        5        U R                  UR                  5       S5        U R                  SU R                  R                  R!                  S5      5        U R#                  [        5        g)	zM
If a non-quiescent connection is put back in the cache, an error is
logged.
rj   ÚNOTQUIESCENTr\  rÀ   r   Úlog_failurez5BUG: Non-quiescent protocol added to connection pool.N)rg   r¬   rm   r$   ÚcreateWithCleanupr'   rG  ra  ÚassertEqualsr³   rM  Úvaluer:  ÚgetErrorMessagerƒ  rO  ÚgetÚflushLoggedErrors)r[   r  ÚlogObserverÚeventÚfs        r\   Útest_putNotQuiescentÚ,HTTPConnectionPoolTests.test_putNotQuiescent¦  sã   € ô
 $Ó%ˆà×Ñ˜Ÿ™¨Ô5ä*×<Ò<¸TÔCUÓVˆà'ˆŒØ�	‰	× Ñ Ð!=¸xÔHØ×Ñ˜!œS Ó-Ô.à˜A‘ˆØ�-Ñ ˆà×Ñ˜aŸg™g¤|Ô4Ø×ÑØ×ÑÓÐ!Xô	
ð 	×ÑØ�$—)‘)×(Ñ(×,Ñ,Ð-IÓJô	
ð 	×Ñœ|Õ,r_   c                óª  •  " S S5      n[        U R                  S5      nSUl        / nSnUR                  XA" 5       5      R	                  UR
                  5        US   nU R                  U[        5        SUl        UR                  U5        / nUR                  XA" 5       5      R	                  UR
                  5        U R                  US   U5        g)	a  
When L{HTTPConnectionPool.getConnection} connects, it returns a
C{Deferred} that fires with an instance of L{HTTP11ClientProtocol}
that has the correct quiescent callback attached. When this callback
is called the protocol is returned to the cache correctly, using the
right key.
c                  ó   • \ rS rSrS rSrg)ÚMHTTPConnectionPoolTests.test_getUsesQuiescentCallback.<locals>.StringEndpointiÊ  c                ól   • UR                  S 5      nUR                  [        5       5        [        U5      $ r~   r4  )r[   r  rm  s      r\   r  ÚUHTTPConnectionPoolTests.test_getUsesQuiescentCallback.<locals>.StringEndpoint.connectË  s-   € Ø×)Ñ)¨$Ó/�Ø× Ñ ¤Ó!2Ô3Ü˜q“zÐ!r_   re   N©r`   ra   rb   rc   r  rd   re   r_   r\   ÚStringEndpointr¤  Ê  s   † õ"r_   r¨  TFza keyr   rj   N)r>   rF  rI  rU  rV  rr   rM  r3   Ú_stateÚ_quiescentCallbackrƒ  )r[   r¨  rG  rt   r‹  r  Úresult2s          r\   Útest_getUsesQuiescentCallbackÚ5HTTPConnectionPoolTests.test_getUsesQuiescentCallbackÁ  sÂ   € ÷	"ñ 	"ô " $×"2Ñ"2°DÓ9ˆØ"'ˆÔØˆØˆØ×Ñ˜3 Ó 0Ó1×=Ñ=¸f¿m¹mÔLØ˜!‘9ˆØ×Ñ˜hÔ(<Ô=ð &ˆŒØ×#Ñ# HÔ-ð
 ˆØ×Ñ˜3 Ó 0Ó1×=Ñ=¸g¿n¹nÔMØ×Ñ˜W Q™Z¨Õ2r_   c                ó"  ^ ^• / mUU 4S jnU" SSS5        U" SSS5        T R                   R                  5       nT H)  nT R                  UR                  R                  S5        M+     T R                  T R                   R
                  0 5        T R                  R                  5        H  nT R                  UR                  S5        M!     T R                  T R                   R                  0 5        / nUR                  UR                  5        T R                  U/ 5        TS   R                  [        [        5       5      5        T R                  U/ 5        TS   R                  [        [        5       5      5        T R                  US	/5        g	)
z¹
L{HTTPConnectionPool.closeCachedConnections} closes all cached
connections and removes them from the cache. It returns a Deferred
that fires when they have all lost their connections.
c                óª   >• [        5       nUR                  [        5       5        TR                  R	                  XU4U5        TR                  U5        g r~   )r3   r.  r&   rG  ra  rr   )ru  rv  rw  rm  r}  r[   s       €€r\   rx  ÚHHTTPConnectionPoolTests.test_closeCachedConnections.<locals>.addProtocolì  sC   ø€ Ü$Ó&ˆAØ×Ñœ_Ó.Ô/Ø�I‰I×$Ñ$ f°DÐ%9¸1Ô=Ø×Ñ˜aÕ r_   r]  r^  r_  r|  Tr   rÀ   N)rG  ÚcloseCachedConnectionsr¬   rb  rc  rO  rF  ÚgetDelayedCallsrk  re  rV  rr   ÚconnectionLostr*   r   )r[   rx  ÚdoneDeferredrm  Údcrt   r}  s   `     @r\   Útest_closeCachedConnectionsÚ3HTTPConnectionPoolTests.test_closeCachedConnectionsä  sB  ù€ ð ˆ
ö	!ñ 	�F˜N¨BÔ/Ù�FÐ/°Ô4Ø—y‘y×7Ñ7Ó9ˆó ˆAØ×Ñ˜QŸ[™[×6Ñ6¸Ö=ñ à×Ñ˜Ÿ™×/Ñ/°Ô4à×"Ñ"×2Ñ2Ö4ˆBØ×Ñ˜RŸ\™\¨4Ö0ñ 5à×Ñ˜Ÿ™×,Ñ,¨bÔ1ð ˆØ× Ñ  §¡Ô/Ø×Ñ˜ Ô$Ø�1‰×$Ñ$¤W¬^Ó-=Ó%>Ô?Ø×Ñ˜ Ô$Ø�1‰×$Ñ$¤W¬^Ó-=Ó%>Ô?Ø×Ñ˜ $ Õ(r_   c                ó@  ^• U R                  U R                  R                  0 5        [        5       m " U4S jS5      nU R                  R	                  SU" 5       5      nUR                  5         U R                  U R                  T5      R                  [        5        g)z¤
Cancelling the C{Deferred} returned from
L{HTTPConnectionPool.getConnection} cancels the C{Deferred} returned
by opening a new connection with the given endpoint.
c                  ó"   >• \ rS rSrU 4S jrSrg)ÚXHTTPConnectionPoolTests.test_cancelGetConnectionCancelsEndpointConnect.<locals>.Endpointi  c                ó   >• T$ r~   re   )r[   r  ÚconnectionResults     €r\   r  Ú`HTTPConnectionPoolTests.test_cancelGetConnectionCancelsEndpointConnect.<locals>.Endpoint.connect  s	   ø€ Ø'Ð'r_   re   Nr§  )r¼  s   €r\   ÚEndpointrº    s   ø† ÷(ð (r_   r¾  i90  N)	r¬   rG  rO  r   rU  rã   rÝ   Útyper   )r[   r¾  rX  r¼  s      @r\   Ú.test_cancelGetConnectionCancelsEndpointConnectÚFHTTPConnectionPoolTests.test_cancelGetConnectionCancelsEndpointConnect  sv   ø€ ð 	×Ñ˜Ÿ™×/Ñ/°Ô4Ü#›:Ð÷	(ô 	(ð �I‰I×#Ñ# E©8«:Ó6ˆØ	�‰Œ
Ø×Ñ˜×-Ñ-Ð.>Ó?×DÑDÄnÕUr_   )rF  rG  N)r`   ra   rb   rc   ry   r“   rY  rg  rq  r~  r…  rŽ  r’  r   r¬  r¶  rÀ  rd   re   r_   r\   rC  rC  í  sF   † ñò-ò,ò 8ò88ò<
ò4%ò0,ò*-ò8-ò6!3òF")õHVr_   rC  c                  ó   • \ rS rSrSrS rSrg)ÚAgentTestsMixini  z)
Tests for any L{IAgent} implementation.
c                ó^   • U R                  [        [        U R                  5       5      5        g)z&
The agent object provides L{IAgent}.
N)r–   r   rE   Ú	makeAgentrn   s    r\   r—   ÚAgentTestsMixin.test_interface  s   € ð 	�‰œ¤V¨T¯^©^Ó-=Ó>Õ?r_   re   N)r`   ra   rb   rc   ry   r—   rd   re   r_   r\   rÃ  rÃ    s   † ñõ@r_   rÃ  c                  óV   • \ rS rSrSrS rS rS rS rS \	R                  S4S	 jrS
rg)ÚIntegrationTestingMixini&  z?
Transport-to-Agent integration tests for both HTTP and HTTPS.
c                ó:   • U R                  S[        [        5        g)z
L{Agent} works over IPv4.
r^  N)ÚintegrationTestr   r   rn   s    r\   Útest_integrationTestIPv4Ú0IntegrationTestingMixin.test_integrationTestIPv4+  s   € ð 	×Ñ˜^¬^¼[ÕIr_   c                ó2   • U R                  SS[        5        g)z<
L{Agent} works over IPv4 when hostname is an IPv4 address.
s	   127.0.0.7rø   N)rÊ  r   rn   s    r\   Útest_integrationTestIPv4AddressÚ7IntegrationTestingMixin.test_integrationTestIPv4Address1  s   € ð 	×Ñ˜\¨;¼ÕDr_   c                ó:   • U R                  S[        [        5        g)z
L{Agent} works over IPv6.
s   ipv6.example.comN)rÊ  r  r   rn   s    r\   Útest_integrationTestIPv6Ú0IntegrationTestingMixin.test_integrationTestIPv67  s   € ð 	×ÑÐ0Ô2CÄ[ÕQr_   c                ó2   • U R                  SS[        5        g)z<
L{Agent} works over IPv6 when hostname is an IPv6 address.
s   [::7]rù   N)rÊ  r   rn   s    r\   Útest_integrationTestIPv6AddressÚ7IntegrationTestingMixin.test_integrationTestIPv6Address=  s   € ð 	×Ñ˜X u¬kÕ:r_   c                ó   • U $ r~   re   )ÚserverÚ_s     r\   r‹   Ú IntegrationTestingMixin.<lambda>H  s   € ©r_   ó   httpc           	     óÊ  ^^• U R                  5       m[        (       a  U R                  [        SU4S j5        U" T5      nUR	                  SUS-   U-   S-   5      nTR
                  S   u  pšp¼nU R                  X’5        U" SXš5      nUR                  U5      n[        USUS	9nUR                  U5        [        R                  U4S
 j5       mSTl        STl        U" TT5      R                  S5      n[        US5      nUR                  U5        [        UUUUSTS9nUR                  5         U R!                  U5        TR                  R"                  R%                  S5      nU R'                  US   R)                  S5      US   5        [+        USS  Vs/ s H  nU(       d  M  UR%                  SS5      PM      sn5      nU R                  US   U5        U R!                  U5        TR                  R,                  R/                  S5        UR                  5         U R1                  U5      nU R3                  UR4                  R7                  S5      S   S5        gs  snf )aþ  
L{Agent} will make a TCP connection, send an HTTP request, and return a
L{Deferred} that fires when the response has been received.

@param hostName: The hostname to interpolate into the URL to be
    requested.
@type hostName: L{bytes}

@param expectedAddress: The expected address string.
@type expectedAddress: L{bytes}

@param addressType: The class to construct an address out of.
@type addressType: L{type}

@param serverWrapper: A callable that takes a protocol factory and a
    ``Clock`` and returns a protocol factory; used to wrap the server /
    responder side in a TLS server.
@type serverWrapper:
    serverWrapper(L{twisted.internet.interfaces.IProtocolFactory}) ->
    L{twisted.internet.interfaces.IProtocolFactory}

@param createAgent: A callable that takes a reactor and produces an
    L{IAgent}; used to construct an agent with an appropriate trust
    root for TLS.
@type createAgent: createAgent(reactor) -> L{IAgent}

@param scheme: The scheme to test, C{http} or C{https}
@type scheme: L{bytes}
Ú_get_default_clockc                 ó   >• T $ r~   re   ©r)  s   €r\   r‹   Ú9IntegrationTestingMixin.integrationTest.<locals>.<lambda>m  s   ø€ ¹'r_   ó   GETó   ://ó   /r   ÚTCPF)ÚpeerAddressc                 ó*   >• [        5       n U Tl        U $ r~   )r#   ÚcurrentProtocol)ÚapÚaccumulators    €r\   rè  Ú<IntegrationTestingMixin.integrationTest.<locals>.accumulatorw  s   ø€ ä%Ó'ˆBØ*,ˆKÔ'ØˆIr_   NT)Úclocks   
s
   GET / HTTPrÀ   s   : ó   HostsL   HTTP/1.1 200 OK
X-An-Header: an-value

Content-length: 12

hello world!s   x-an-headers   an-value)r
  Ú
sslPresentÚpatchrP   rs   r  r¬   r  r+   r.  r   ÚforProtocolræ  ÚprotocolConnectionMader,   Úflushrä   ÚdataÚsplitr–   Ú
startswithÚdictrb  rƒ   rÅ   r˜  ÚheadersÚgetRawHeaders)r[   ÚhostNameÚexpectedAddressÚaddressTypeÚserverWrapperÚcreateAgentru  r*  Údeferredrv  rw  r  ÚtimeoutÚbindrä  ÚclientProtocolÚclientTransportÚwrapperÚserverTransportÚpumpÚlinesÚlinerõ  Úresponserè  r)  s                           @@r\   rÊ  Ú'IntegrationTestingMixin.integrationTestC  s9  ù€ ðL ×$Ñ$Ó&ˆßŠ:ð �J‰J”sÐ0´/ÔBÙ˜GÓ$ˆØ—=‘= ¨°&©¸8Ñ)CÀdÑ)JÓKˆØ-4×-?Ñ-?ÀÑ-BÑ*ˆ�G dØ×Ñ˜Ô/Ù! %¨Ó4ˆØ ×.Ñ.¨{Ó;ˆÜ'¨¸È;ÑWˆØ×%Ñ% oÔ6ä	×	Ñ	ô	ó 
ð	ð
 '+ˆÔ#Ø-1ˆÔ*Ù ¨WÓ5×CÑCÀDÓIˆÜ'¨°Ó6ˆØ×Ñ˜Ô/ÜØØØØØØñ
ˆð 	�
‰
ŒØ×Ñ˜HÔ%Ø×+Ñ+×0Ñ0×6Ñ6°wÓ?ˆØ�‰˜˜a™×+Ñ+¨MÓ:¸EÀ!¹HÔEÜ¸¸q¸r¹ÓKº°ÄdÓ,˜Ÿ
™
 5¨!Ö,¹ÑKÓLˆØ×Ñ˜ Ñ)¨8Ô4Ø×Ñ˜HÔ%Ø×#Ñ#×-Ñ-×3Ñ3ðô	
ð 	�
‰
ŒØ×'Ñ'¨Ó1ˆØ×ÑØ×Ñ×*Ñ*¨>Ó:¸1Ñ=¸{õ	
ùò Ls   ÆI Æ(I re   N)r`   ra   rb   rc   ry   rË  rÎ  rÑ  rÔ  r0   r'  rÊ  rd   re   r_   r\   rÈ  rÈ  &  s3   † ñòJòEòRò;ñ /Ø—L‘LØ÷X
r_   rÈ  c                  ó   • \ rS rSrSrS rSrg)ÚStubEndpointFactoryiž  z5
A stub L{IAgentEndpointFactory} for use in testing.
c                óH   • UR                   UR                  UR                  4$ )z¨
Testing implementation.

@param uri: A L{URI}.

@return: C{(scheme, host, port)} of passed in URI; violation of
    interface but useful for testing.
@rtype: L{tuple}
)ru  rv  rw  ©r[   Úuris     r\   ÚendpointForURIÚ"StubEndpointFactory.endpointForURI¤  s   € ð —
‘
˜CŸH™H c§h¡hÐ/Ð/r_   re   N)r`   ra   rb   rc   ry   r  rd   re   r_   r\   r	  r	  ž  s   † ñõ
0r_   r	  c                  ó  • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS r\" \(       + S5      S 5       rS r\" \(       + S5      S 5       rS rS r S r!S r"S  r#S! r$S"r%g#)$Ú
AgentTestsi±  z9
Tests for the new HTTP client API provided by L{Agent}.
c                óB   • [         R                  " U R                  5      $ )z5
@return: a new L{twisted.web.client.Agent} instance
)r0   r'  r)  rn   s    r\   rÅ  ÚAgentTests.makeAgent¸  s   € ô �|Š|˜DŸL™LÓ)Ð)r_   c                óX   • U R                  5       U l        U R                  5       U l        g©ú3
Create an L{Agent} wrapped around a fake reactor.
N©r
  r)  rÅ  r*  rn   s    r\   r“   ÚAgentTests.setUp¾  s"   € ð ×)Ñ)Ó+ˆŒØ—^‘^Ó%ˆ�
r_   c                ó0  • [         R                  " U R                  5      nU R                  UR                  [
        5        U R                  UR                  R                  S5        U R                  UR                  UR                  R                  5        g)zF
If no pool is passed in, the L{Agent} creates a non-persistent pool.
FN)
r0   r'  r)  rM  Ú_poolr>   r¬   r}  rƒ  Ú_reactor©r[   r*  s     r\   Útest_defaultPoolÚAgentTests.test_defaultPoolÅ  sc   € ô —’˜TŸ\™\Ó*ˆØ×Ñ˜eŸk™kÔ+=Ô>Ø×Ñ˜Ÿ™×/Ñ/°Ô7Ø×Ñ˜UŸ^™^¨U¯[©[×-AÑ-AÕBr_   c                ó  ^ • [        T R                  5      n[        R                  " T R                  US9nU 4S jUl        UR                  SS5        T R                  T R                  R                  S   S   R                  S5        g)z–
If C{persistent} is set to C{True} on the L{HTTPConnectionPool} (the
default), C{Request}s are created with their C{persistent} flag set to
C{True}.
©rG  c                 ó   >• T$ r~   re   ©r$  r[   s    €r\   r‹   Ú,AgentTests.test_persistent.<locals>.<lambda>Ö  ó   ø€ ©4r_   rà  ó   http://127.0.0.1r   TN©
r>   r)  r0   r'  r(  rs   r¬   r  rl   r}  ©r[   rG  r*  s   `  r\   Útest_persistentÚAgentTests.test_persistentÎ  sh   ø€ ô " $§,¡,Ó/ˆÜ—’˜TŸ\™\°Ñ5ˆÜ/ˆÔØ�‰�fÐ1Ô2Ø×Ñ˜Ÿ™×/Ñ/°Ñ2°1Ñ5×@Ñ@À$ÕGr_   c                ó  ^ • [        T R                  SS9n[        R                  " T R                  US9nU 4S jUl        UR                  SS5        T R                  T R                  R                  S   S   R                  S5        g)	ag  
If C{persistent} is set to C{False} when creating the
L{HTTPConnectionPool}, C{Request}s are created with their
C{persistent} flag set to C{False}.

Elsewhere in the tests for the underlying HTTP code we ensure that
this will result in the disconnection of the HTTP protocol once the
request is done, so that the connection will not be returned to the
pool.
F©r}  r  c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú/AgentTests.test_nonPersistent.<locals>.<lambda>ç  r#  r_   rà  r$  r   Nr%  r&  s   `  r\   Útest_nonPersistentÚAgentTests.test_nonPersistentÚ  sj   ø€ ô " $§,¡,¸5ÑAˆÜ—’˜TŸ\™\°Ñ5ˆÜ/ˆÔØ�‰�fÐ1Ô2Ø×Ñ˜Ÿ™×/Ñ/°Ñ2°1Ñ5×@Ñ@À%ÕHr_   c                ó¨  ^ ^• [        5       m " UU 4S jS[        R                  5      n " UU 4S jS5      nU" 5       nU" T R                  US9nT R	                  X4R
                  5        [        R                  " 5       nUR                  SS5        [        5       nUR                  SS	XeS
9  T R                  UR
                  R                  S5        g)z»
When a connection is made by the Agent, it uses its pool's
C{getConnection} method to do so, with the endpoint returned by
C{self._getEndpoint}. The key used is C{(scheme, host, port)}.
c                  ó$   >• \ rS rSrU U4S jrSrg)Ú:AgentTests.test_connectUsesConnectionPool.<locals>.MyAgentió  c                ón   >• TR                  UR                  UR                  UR                  4S5        T$ )N©rÚ  ó   foor_  )r¬   ru  rv  rw  )Úthisr  r  r[   s     €€r\   r(  ÚGAgentTests.test_connectUsesConnectionPool.<locals>.MyAgent._getEndpointô  s1   ø€ Ø× Ñ Ø—Z‘Z §¡¨3¯8©8Ð4Ð6Kôð  �r_   re   N)r`   ra   rb   rc   r(  rd   ©r  r[   s   €€r\   ÚMyAgentr1  ó  s   ø† ÷ ñ  r_   r8  c                  ó,   >• \ rS rSrSrSrU U4S jrSrg)Ú<AgentTests.test_connectUsesConnectionPool.<locals>.DummyPooliú  Fc                ó–   >• SU l         TR                  UT5        TR                  US5        [        R                  " [	        5       5      $ )NTr3  )Ú	connectedr¬   r   r   rg   ©r5  r‹  Úepr  r[   s      €€r\   rU  ÚJAgentTests.test_connectUsesConnectionPool.<locals>.DummyPool.getConnectionþ  s@   ø€ Ø!%�”Ø× Ñ   XÔ.ð × Ñ  Ð&;Ô<Ü—}’}Ô%5Ó%7Ó8Ð8r_   re   N©r`   ra   rb   rc   r<  r}  rU  rd   r7  s   €€r\   Ú	DummyPoolr:  ú  s   ø† ØˆIØˆJ÷9ñ 9r_   rA  r  ó   hostr4  rà  ó   http://foo/)ÚbodyProducerrõ  TN)r2  r0   r'  r)  rƒ  r  r2   rC   ÚaddRawHeaderÚobjectrs   r¬   r<  )r[   r8  rA  rG  r*  rõ  rD  r  s   `      @r\   Útest_connectUsesConnectionPoolÚ)AgentTests.test_connectUsesConnectionPoolë  s¯   ù€ ô !“?ˆ÷	 ð 	 ”f—l‘lô 	 ÷
	9õ 
	9ñ ‹{ˆÙ˜Ÿ™¨4Ñ0ˆØ×Ñ˜T§;¡;Ô/ä×&Ò&Ó(ˆØ×Ñ˜W fÔ-Ü“xˆØ�‰Ø�N°ð 	ñ 	
ð 	×Ñ˜Ÿ™×.Ñ.°Õ5r_   c                ó\   • U R                  [        U R                  R                  SS5        g)zR
L{Agent.request} raises L{TypeError} when the C{method} argument isn't
L{bytes}.
ÚGETó   http://foo.example/N©ÚassertRaisesÚ	TypeErrorr*  rs   rn   s    r\   Útest_nonBytesMethodÚAgentTests.test_nonBytesMethod  ó#   € ð
 	×Ñœ) T§Z¡Z×%7Ñ%7¸Ð@VÕWr_   c                ób   • U R                  U R                  R                  SS5      [        5      $ )z‡
L{Agent.request} returns a L{Deferred} which fails with
L{SchemeNotSupported} if the scheme of the URI passed to it is not
C{'http'}.
rà  s   mailto:alice@example.com)ÚassertFailurer*  rs   rB   rn   s    r\   Útest_unsupportedSchemeÚ!AgentTests.test_unsupportedScheme  s/   € ð ×!Ñ!Ø�J‰J×Ñ˜vÐ'BÓCÔEWó
ð 	
r_   c                ó8  • U R                   R                  SS5      nU R                  R                  R	                  5       SS u  p#nUR                  S[        [        5       5      5        U R                  R                  S5        U R                  U[        5        g)zk
The L{Deferred} returned by L{Agent.request} fires with a L{Failure} if
the TCP connection attempt fails.
rà  rC  Nr¿   é
   )
r*  rs   r)  r  rÃ   ÚclientConnectionFailedr*   r   r  rÝ   )r[   rt   rv  rw  r  s        r\   Útest_connectionFailedÚ AgentTests.test_connectionFailed#  sz   € ð
 —‘×#Ñ# F¨NÓ;ˆà"Ÿl™l×5Ñ5×9Ñ9Ó;¸B¸QÐ?Ñˆ�GØ×&Ñ& t¬WÔ5KÓ5MÓ-NÔOØ�‰×Ñ˜RÔ à×Ñ˜VÔ%;Õ<r_   c                ó  • SnSnU R                   R                  [        R                  " SX4-  5      5      nU R	                  UR
                  S5        U R	                  UR                  U5        U R                  U[        5        g)zW
L{Agent._getEndpoint} return a C{HostnameEndpoint} when passed a scheme
of C{'http'}.
r^  éÒ  s   http://%b:%drý   N)	r*  r(  r:   Ú	fromBytesr¬   Ú	_hostTextÚ_portrM  r   )r[   ÚexpectedHostÚexpectedPortr  s       r\   Útest_connectHTTPÚAgentTests.test_connectHTTP0  ss   € ð
 &ˆØˆØ—:‘:×*Ñ*Ü�MŠM˜/¨\Ð,HÑHÓIó
ˆð 	×Ñ˜×+Ñ+¨]Ô;Ø×Ñ˜Ÿ™¨Ô6Ø×Ñ˜hÔ(8Õ9r_   c                ó€  • [         R                  " S5      nSR                  5       Ul        U R	                  [
        5       nU R                  R                  U5        SSS5        U R                  WR                  R                  S   SR                  [        UR                  5      S95        g! , (       d  f       NX= f)zd
L{Agent._getEndpoint} when given a non-ASCII decodable URI will raise a
L{ValueError} saying such.
s   http://example.com:80u   â˜ƒ.comNr   zaThe host of the provided URI ({reprout}) contains non-ASCII octets, it should be ASCII decodable.)Úreprout)r:   r]  Úencoderv  rM  Ú
ValueErrorr*  r(  r¬   Ú	exceptionr$  Úformatr  )r[   r  Úes      r\   Útest_nonDecodableURIÚAgentTests.test_nonDecodableURI>  s�   € ô
 �mŠmÐ4Ó5ˆØ×&Ñ&Ó(ˆŒà×ÑœzÔ*¨aØ�J‰J×#Ñ# CÔ(÷ +ð 	×ÑØ�K‰K×Ñ˜QÑð÷ ‰fœT #§(¡(›^ˆfÐ,õ	
÷ +Õ*ús   ÁB/Â/
B=c                ó  ^ • U 4S jT R                   l        T R                   R                  SS5        T R                  R                  R                  5       u  pT R                  UR                  R                  S5      S/5        g)z›
If L{None} is passed to L{Agent.request} for the C{headers} parameter,
a L{Headers} instance is created for the request and a I{Host} header
added to it.
c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú.AgentTests.test_hostProvided.<locals>.<lambda>X  ó   ø€ ±r_   rà  ó   http://example.com/foo?barrB  r^  N©	r*  r(  rs   r  rl   rÃ   r¬   rõ  rö  ©r[   ÚreqÚress   `  r\   Útest_hostProvidedÚAgentTests.test_hostProvidedR  sb   ø€ ô #5ˆ�
‰
ÔØ�
‰
×Ñ˜6Ð#@ÔAà—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°7Ó;¸nÐ=MÕNr_   c                ó  ^ • U 4S jT R                   l        T R                   R                  SS5        T R                  R                  R                  5       u  pT R                  UR                  R                  S5      S/5        g)zy
If an IPv6 address is used in the C{uri} passed to L{Agent.request},
the computed I{Host} header needs to be bracketed.
c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú3AgentTests.test_hostIPv6Bracketed.<locals>.<lambda>c  rp  r_   rà  s   http://[::1]/rB  s   [::1]Nrr  rs  s   `  r\   Útest_hostIPv6BracketedÚ!AgentTests.test_hostIPv6Bracketed^  sa   ø€ ô
 #5ˆ�
‰
ÔØ�
‰
×Ñ˜6Ð#3Ô4à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°7Ó;¸h¸ZÕHr_   c                óD  ^ • [         R                  " S/S/S.5      nU 4S jT R                  l        T R                  R	                  SSU5        T R
                  R                  R                  5       u  p#T R                  UR                  R                  S5      S/5        g)	z®
If the headers passed to L{Agent.request} includes a value for the
I{Host} header, that value takes precedence over the one which would
otherwise be automatically provided.
ó   bars   quux©r4  rB  c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú.AgentTests.test_hostOverride.<locals>.<lambda>p  rp  r_   rà  rq  rB  N)r2   rC   r*  r(  rs   r  rl   rÃ   r¬   rõ  rö  )r[   rõ  rt  ru  s   `   r\   Útest_hostOverrideÚAgentTests.test_hostOverridei  s|   ø€ ô ×&Ò&°°ÀGÀ9Ñ'MÓNˆÜ"4ˆ�
‰
ÔØ�
‰
×Ñ˜6Ð#@À'ÔJà—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°7Ó;¸g¸YÕGr_   c                ó@  ^ • [         R                  " 5       nU 4S jT R                  l        T R                  R	                  SSU5        T R
                  nT R                  [        UR                  5      S5        T R                  U[         R                  " 5       5        g)zw
If a I{Host} header must be added to the request, the L{Headers}
instance passed to L{Agent.request} is not modified.
c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú3AgentTests.test_headersUnmodified.<locals>.<lambda>|  rp  r_   rà  ó   http://example.com/foorÀ   N)	r2   rC   r*  r(  rs   r  r¬   r³   rl   )r[   rõ  r  s   `  r\   Útest_headersUnmodifiedÚ!AgentTests.test_headersUnmodifiedv  su   ø€ ô
 ×&Ò&Ó(ˆÜ"4ˆ�
‰
ÔØ�
‰
×Ñ˜6Ð#<¸gÔFà—=‘=ˆð 	×Ñœ˜X×.Ñ.Ó/°Ô3à×Ñ˜¤,×"6Ò"6Ó"8Õ9r_   c                ó^   • U R                  U R                  R                  SSS5      S5        g)zŒ
When passed a scheme of C{'http'} and a port of C{80},
L{Agent._computeHostValue} returns a string giving just
the host name passed to it.
rÚ  r^  r_  N©r¬   r*  Ú_computeHostValuern   s    r\   Útest_hostValueStandardHTTPÚ%AgentTests.test_hostValueStandardHTTP†  s*   € ð 	×ÑØ�J‰J×(Ñ(¨°.À"ÓEÀ~õ	
r_   c                ó^   • U R                  U R                  R                  SSS5      S5        g)z¹
When passed a scheme of C{'http'} and a port other than C{80},
L{Agent._computeHostValue} returns a string giving the
host passed to it joined together with the port number by C{":"}.
rÚ  r^  é1Ô  ó   example.com:54321Nr‹  rn   s    r\   Útest_hostValueNonStandardHTTPÚ(AgentTests.test_hostValueNonStandardHTTP�  s+   € ð 	×ÑØ�J‰J×(Ñ(¨°.À%ÓHØ õ	
r_   c                ó^   • U R                  U R                  R                  SSS5      S5        g)zŽ
When passed a scheme of C{'https'} and a port of C{443},
L{Agent._computeHostValue} returns a string giving just
the host name passed to it.
ó   httpsr^  r{  Nr‹  rn   s    r\   Útest_hostValueStandardHTTPSÚ&AgentTests.test_hostValueStandardHTTPS›  s*   € ð 	×ÑØ�J‰J×(Ñ(¨°>À3ÓGÈõ	
r_   c                ó^   • U R                  U R                  R                  SSS5      S5        g)z»
When passed a scheme of C{'https'} and a port other than C{443},
L{Agent._computeHostValue} returns a string giving the
host passed to it joined together with the port number by C{":"}.
r•  r^  r�  r‘  Nr‹  rn   s    r\   Útest_hostValueNonStandardHTTPSÚ)AgentTests.test_hostValueNonStandardHTTPS¥  s+   € ð 	×ÑØ�J‰J×(Ñ(¨°>À5ÓIØ õ	
r_   c                óˆ  ^ • U 4S jT R                   l        [        R                  " SS/05      n[	        5       nT R                   R                  SSX5        T R                  nT R                  [        UR                  5      S5        UR                  R                  5       u  pET R                  U[        5        T R                  UR                  S5        T R                  UR                  S5        T R                  UR                  [        R                  " S/S/S	.5      5        T R!                  UR"                  U5        g
)a/  
L{Agent.request} establishes a new connection to the host indicated by
the host part of the URI passed to it and issues a request using the
method, the path portion of the URI, the headers, and the body producer
passed to it.  It returns a L{Deferred} which fires with an
L{IResponse} from the server.
c                 ó   >• T$ r~   re   r!  s    €r\   r‹   Ú)AgentTests.test_request.<locals>.<lambda>¸  rp  r_   r4  r~  rà  ó   http://example.com:1234/foo?barrÀ   s   /foo?baró   example.com:1234r  N)r*  r(  r2   rC   rF  rs   r  r¬   r³   rl   rÃ   rM  r?   Úmethodr  rõ  rƒ  rD  )r[   rõ  Úbodyr  rt  ru  s   `     r\   Útest_requestÚAgentTests.test_request°  s  ø€ ô #5ˆ�
‰
Ôä×&Ò&¨°°Ð'9Ó:ˆô ‹xˆØ�
‰
×Ñ˜6Ð#EÀwÔUà—=‘=ˆð 	×Ñœ˜X×.Ñ.Ó/°Ô3Ø×$Ñ$×(Ñ(Ó*‰ˆØ×Ñ˜c¤7Ô+Ø×Ñ˜Ÿ™ VÔ,Ø×Ñ˜Ÿ™ +Ô.Ø×ÑØ�K‰KÜ× Ò ¨6¨(Ð>QÐ=RÑ!SÓTô	
ð 	×Ñ˜S×-Ñ-¨tÕ4r_   c                óØ   • [         R                  " U R                  SS9nUR                  SS5        U R                  R                  R                  5       S   nU R                  SU5        g)zf
L{Agent} takes a C{connectTimeout} argument which is forwarded to the
following C{connectTCP} agent.
r²   ©ÚconnectTimeoutrà  rC  r¿   N©r0   r'  r)  rs   r  rÃ   r¬   ©r[   r*  rý  s      r\   Útest_connectTimeoutÚAgentTests.test_connectTimeoutÎ  sS   € ô
 —’˜TŸ\™\¸!Ñ<ˆØ�‰�f˜nÔ-Ø—,‘,×)Ñ)×-Ñ-Ó/°Ñ2ˆØ×Ñ˜˜GÕ$r_   ú&SSL not present, cannot run SSL tests.c                óØ   • [         R                  " U R                  SS9nUR                  SS5        U R                  R                  R                  5       S   nU R                  SU5        g)ze
L{Agent} takes a C{connectTimeout} argument which is forwarded to the
following C{connectTCP} call.
r²   r¥  rà  ó   https://foo/r¿   Nr§  r¨  s      r\   Útest_connectTimeoutHTTPSÚ#AgentTests.test_connectTimeoutHTTPSØ  sS   € ô —’˜TŸ\™\¸!Ñ<ˆØ�‰�f˜oÔ.Ø—,‘,×)Ñ)×-Ñ-Ó/°Ñ2ˆØ×Ñ˜˜GÕ$r_   c                óØ   • [         R                  " U R                  SS9nUR                  SS5        U R                  R                  R                  5       S   nU R                  SU5        g)zb
L{Agent} takes a C{bindAddress} argument which is forwarded to the
following C{connectTCP} call.
ú192.168.0.1©ÚbindAddressrà  rC  rÏ   ©r±  r   Nr§  ©r[   r*  Úaddresss      r\   Útest_bindAddressÚAgentTests.test_bindAddressã  sT   € ô
 —’˜TŸ\™\°}ÑEˆØ�‰�f˜nÔ-Ø—,‘,×)Ñ)×-Ñ-Ó/°Ñ2ˆØ×ÑÐ+¨WÕ5r_   c                óØ   • [         R                  " U R                  SS9nUR                  SS5        U R                  R                  R                  5       S   nU R                  SU5        g)zb
L{Agent} takes a C{bindAddress} argument which is forwarded to the
following C{connectSSL} call.
r±  r²  rà  r­  rÏ   r´  Nr§  rµ  s      r\   Útest_bindAddressSSLÚAgentTests.test_bindAddressSSLí  sT   € ô —’˜TŸ\™\°}ÑEˆØ�‰�f˜oÔ.Ø—,‘,×)Ñ)×-Ñ-Ó/°Ñ2ˆØ×ÑÐ+¨WÕ5r_   c                óº  • SnU R                  U R                  5      nUR                  SU5      nU R                  [	        U R
                  R                  5      S5        U R
                  R                  R                  5       u  pEU R                  U[        5        [        R                  R                  SSS[        0 5      SU5      nUR                  U5        U R                  U5      nU R                  UR                  R                   UR                  R"                  UR                  R$                  4UR                   UR"                  UR$                  45        g)zj
L{Response}s returned by L{Agent.request} have a reference to the
L{Request} that was originally issued.
ó   http://example.com/rà  rÀ   ©s   HTTPrÀ   rÀ   éÈ   ó   OKN)r+  r)  rs   r¬   r³   r  rl   rÃ   rM  r?   r0   r7   Ú
_constructrC   ÚcallbackrÅ   r   ÚabsoluteURIrõ  )r[   r  r*  rX  rt  ru  Úrespr  s           r\   Útest_responseIncludesRequestÚ'AgentTests.test_responseIncludesRequestø  s  € ð
 %ˆØ×-Ñ-¨d¯l©lÓ;ˆØ�M‰M˜& #Ó&ˆð 	×Ñœ˜TŸ]™]×3Ñ3Ó4°aÔ8Ø—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜c¤7Ô+ä�‰×)Ñ)Ø˜S %¬°«°d¸Có
ˆð 	�‰�TÔà×'Ñ'¨Ó*ˆØ×Ñà× Ñ ×'Ñ'Ø× Ñ ×,Ñ,Ø× Ñ ×(Ñ(ðð
 �Z‰Z˜Ÿ™¨#¯+©+Ð6õ	
r_   c                óp  • SnU R                  U R                  5      nUR                  SU5        U R                  [	        U R
                  R                  5      S5        U R
                  R                  R                  5       u  p4U R                  U[        5        U R                  UR                  U5        g)z<
L{Request.absoluteURI} is the absolute URI of the request.
s$   http://example.com/foo;1234?bar#fragrà  rÀ   N)r+  r)  rs   r¬   r³   r  rl   rÃ   rM  r?   rÃ  )r[   r  r*  rt  ru  s        r\   Útest_requestAbsoluteURIÚ"AgentTests.test_requestAbsoluteURI  sŠ   € ð 6ˆØ×-Ñ-¨d¯l©lÓ;ˆØ�‰�f˜cÔ"ð 	×Ñœ˜TŸ]™]×3Ñ3Ó4°aÔ8Ø—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜c¤7Ô+Ø×Ñ˜Ÿ™¨#Õ.r_   c                ó~   • [         R                  " SS[        5       S5      nU R                  UR                  S5        g)zH
L{Request.absoluteURI} is L{None} if L{Request._parsedURI} is L{None}.
ó   FOOrâ  N)r0   r?   rC   rƒ  rÃ  )r[   rs   s     r\   Útest_requestMissingAbsoluteURIÚ)AgentTests.test_requestMissingAbsoluteURI#  s0   € ô —.’. ¨¬w«y¸$Ó?ˆØ×Ñ˜W×0Ñ0°$Õ7r_   c                óÆ   • [        5       n[        R                  R                  SUS9n[        R
                  " S5      nUR                  U5      nU R                  US5        g)zd
L{Agent.usingEndpointFactory} creates an L{Agent} that uses the given
factory to create endpoints.
N)ÚendpointFactoryr½  )rÚ  r^  r_  )r	  r0   r'  ÚusingEndpointFactoryr:   r]  r(  r¬   )r[   r  r*  r  ÚreturnedEndpoints        r\   Útest_endpointFactoryÚAgentTests.test_endpointFactory*  sW   € ô
 &Ó'ˆÜ—‘×1Ñ1°$ÈÐ1ÐPˆÜ�mŠmÐ2Ó3ˆØ ×-Ñ-¨cÓ2ÐØ×ÑÐ)Ð+HÕIr_   c                ó  • [         R                  R                  U R                  [	        5       5      nUR
                  nU R                  UR                  UR                  UR                  4[        SUR                  45        g)zy
If no pool is passed in to L{Agent.usingEndpointFactory}, a default
pool is constructed with no persistent connections.
FN)r0   r'  rÐ  r)  r	  r  r¬   Ú	__class__r}  r  r>   )r[   r*  rG  s      r\   Útest_endpointFactoryDefaultPoolÚ*AgentTests.test_endpointFactoryDefaultPool5  s]   € ô
 —‘×1Ñ1°$·,±,Ô@SÓ@UÓVˆØ�{‰{ˆØ×ÑØ�^‰^˜TŸ_™_¨d¯m©mÐ<Ü ¨¯©Ð7õ	
r_   c                ó´   • [        5       n[        R                  R                  U R                  [        5       U5      nU R                  XR                  5        g)zZ
If a pool is passed in to L{Agent.usingEndpointFactory} it is used as
the L{Agent} pool.
N)rF  r0   r'  rÐ  r)  r	  ÚassertIsr  r&  s      r\   Útest_endpointFactoryPoolÚ#AgentTests.test_endpointFactoryPoolA  s@   € ô
 ‹xˆÜ—‘×1Ñ1Ø�L‰LÔ-Ó/°ó
ˆð 	�‰�dŸK™KÕ(r_   ©r*  r)  N)&r`   ra   rb   rc   ry   rÅ  r“   r  r'  r-  rG  rO  rT  rY  rb  rk  rv  r{  r‚  rˆ  r�  r’  r–  r™  r¢  r©  r   rì  r®  r·  rº  rÅ  rÈ  rÌ  rÒ  rÖ  rÚ  rd   re   r_   r\   r  r  ±  sÚ   † ñò*ò&òCò
HòIò"%6òNXò
ò=ò:ò
ò(
Oò	IòHò:ò 
ò	
ò
ò	
ò5ò<%ñ �
ŒNÐDÓEñ%ó Fð%ò6ñ �
ŒNÐDÓEñ6ó Fð6ò
ò:/ò8ò	Jò

õ	)r_   r  c                  ó   • \ rS rSrSrS rSrg)ÚAgentMethodInjectionTestsiM  z6
Test L{client.Agent} against HTTP method injections.
c                ó†   • [         R                  " U R                  5       5      nSnUR                  X[	        5       S5        g)ú^
Attempt a request with the provided method.

@param method: see L{MethodInjectionTestsMixin}
ó   http://twisted.invalidN©r0   r'  r
  rs   rC   )r[   r   r*  r  s       r\   Ú!attemptRequestWithMaliciousMethodÚ;AgentMethodInjectionTests.attemptRequestWithMaliciousMethodV  s2   € ô —’˜T×/Ñ/Ó1Ó2ˆØ'ˆØ�‰�f¤7£9¨dÕ3r_   re   N©r`   ra   rb   rc   ry   rã  rd   re   r_   r\   rÞ  rÞ  M  ó   † ñ
õ4r_   rÞ  c                  ó   • \ rS rSrSrS rSrg)ÚAgentURIInjectionTestsia  z.
Test L{client.Agent} against URI injections.
c                ó†   • [         R                  " U R                  5       5      nSnUR                  X1[	        5       S5        g)zX
Attempt a request with the provided method.

@param uri: see L{URIInjectionTestsMixin}
rà  Nrâ  )r[   r  r*  r   s       r\   ÚattemptRequestWithMaliciousURIÚ5AgentURIInjectionTests.attemptRequestWithMaliciousURIj  s2   € ô —’˜T×/Ñ/Ó1Ó2ˆØˆØ�‰�f¤7£9¨dÕ3r_   re   N©r`   ra   rb   rc   ry   rê  rd   re   r_   r\   rè  rè  a  ræ  r_   rè  r«  c                  ó`   ^ • \ 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U 4S jrSrU =r$ )ÚAgentHTTPSTestsiu  z8
Tests for the new HTTP client API that depends on SSL.
c                ó˜   • [         R                  " U R                  5       5      R                  [        R
                  " SX4-  5      5      $ )aA  
Create an L{Agent} with an https scheme and return its endpoint
created according to the arguments.

@param host: The host for the endpoint.
@type host: L{bytes}

@param port: The port for the endpoint.
@type port: L{int}

@return: An endpoint of an L{Agent} constructed according to args.
@rtype: L{SSL4ClientEndpoint}
s   https://%b:%d/)r0   r'  r
  r(  r:   r]  )r[   rv  rw  s      r\   ÚmakeEndpointÚAgentHTTPSTests.makeEndpoint{  s=   € ô �|Š|˜D×.Ñ.Ó0Ó1×>Ñ>Ü�MŠMÐ+¨t¨lÑ:Ó;ó
ð 	
r_   c                ó’   • SSK Jn  U R                  5       nU R                  X!5        U R                  UR                  [
        5        g)zZ
L{Agent._getEndpoint} return a L{SSL4ClientEndpoint} when passed a
scheme of C{'https'}.
r   )Ú_WrapperEndpointN)Útwisted.internet.endpointsró  rð  rM  Ú_wrappedEndpointr   )r[   ró  r  s      r\   Útest_endpointTypeÚ!AgentHTTPSTests.test_endpointType�  s;   € õ
 	@à×$Ñ$Ó&ˆØ×Ñ˜hÔ9Ø×Ñ˜h×7Ñ7Ô9IÕJr_   c                ón   • U R                  SS9nU R                  UR                  R                  S5        g)z0
If a host is passed, the endpoint respects it.
r^  )rv  rý   N)rð  r¬   rõ  r^  )r[   r  s     r\   Útest_hostArgumentIsRespectedÚ,AgentHTTPSTests.test_hostArgumentIsRespected˜  s3   € ð ×$Ñ$¨.Ð$Ð9ˆØ×Ñ˜×2Ñ2×<Ñ<¸mÕLr_   c                ór   • SnU R                  US9nU R                  UR                  R                  U5        g)z0
If a port is passed, the endpoint respects it.
éá  )rw  N)rð  r¬   rõ  r_  )r[   ra  r  s      r\   Útest_portArgumentIsRespectedÚ,AgentHTTPSTests.test_portArgumentIsRespectedŸ  s8   € ð ˆØ×$Ñ$¨,Ð$Ð7ˆØ×Ñ˜×2Ñ2×8Ñ8¸,ÕGr_   c                ó¾   • U R                  5       nUR                  S5      R                  nU R                  U[        5        U R                  UR                  S5        g)zI
L{Agent} wraps its connection creator creator and uses modern TLS APIs.
Nrý   )rð  Ú_wrapperFactoryÚ_connectionCreatorrM  rM   r¬   Ú	_hostname)r[   r  ÚcontextFactorys      r\   Útest_contextFactoryTypeÚ'AgentHTTPSTests.test_contextFactoryType§  sO   € ð ×$Ñ$Ó&ˆØ!×1Ñ1°$Ó7×JÑJˆØ×Ñ˜nÔ.>Ô?Ø×Ñ˜×1Ñ1°=ÕAr_   c                ó  ^^^• SnSn " S S5      n/ m[        [        5       " UU4S jS5      5       mU" 5       m[        [        5       " U4S jS5      5       nU" 5       nU R                  5       n[        R
                  " Xe5      nUR                  [        R                  " S	X4-  5      5      nUR                  [        R                  " [        5      5        UR                  S
   S   n	U	R                  S5      n
U
R                  [!        5       5        TS   S   nU R#                  U[$        5        U R'                  TS   SS X45        U R)                  TR*                  5        U R)                  TR,                  5        g)a}  
If a custom L{WebClientConnectionCreator}-like object is passed to
L{Agent.__init__} it will be used to determine the SSL parameters for
HTTPS requests.  When an HTTPS request is made, the hostname and port
number of the request URL will be passed to the connection creator's
C{creatorForNetloc} method.  The resulting context object will be used
to establish the SSL connection.
s   example.orgiÛO  c                  ó(   • \ rS rSrSrSrS rS rSrg)ÚVAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughConnectioni¼  Fc                ó   • SU l         g)z+
The handshake started.  Record that fact.
TN)ÚhandshakeStartedrn   s    r\   Údo_handshakeÚcAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughConnection.do_handshakeÀ  s   € ð )-�Õ%r_   c                ó   • SU l         g)z,
The connection started.  Record that fact.
TN)ÚconnectStatern   s    r\   Úset_connect_stateÚhAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughConnection.set_connect_stateÆ  s   € ð %)�Õ!r_   )r  r
  N)	r`   ra   rb   rc   r
  r  r  r  rd   re   r_   r\   ÚJustEnoughConnectionr  ¼  s   † Ø$ÐØ ˆLò-õ)r_   r  c                  ó*   >• \ rS rSrS rU U4S jrSrg)ÚSAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughCreatoriÎ  c                ó   • Xl         X l        g r~   ©Úhostnamerw  )r[   r  rw  s      r\   ro   Ú\AgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughCreator.__init__Ð  s   € Ø (”Ø •	r_   c                óV   >• TR                  XR                  U R                  45        T$ )z¡
Implement L{IOpenSSLClientConnectionCreator}.

@param tlsProtocol: The TLS protocol.
@type tlsProtocol: L{TLSMemoryBIOProtocol}

@return: C{expectedConnection}
)rr   r  rw  )r[   ÚtlsProtocolÚcontextArgsÚexpectedConnections     €€r\   ÚclientConnectionForTLSÚjAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.JustEnoughCreator.clientConnectionForTLSÔ  s&   ø€ ð ×"Ñ" K·±ÀÇ	Á	Ð#JÔKØ)Ð)r_   r  N)r`   ra   rb   rc   ro   r  rd   )r  r  s   €€r\   ÚJustEnoughCreatorr  Î  s   ø† ò!÷
*ñ 
*r_   r  c                  ó"   >• \ rS rSrU 4S jrSrg)Ú_AgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.StubBrowserLikePolicyForHTTPSiâ  c                ó   >• T" X5      $ )zí
Emulate L{BrowserLikePolicyForHTTPS}.

@param hostname: The hostname to verify.
@type hostname: L{bytes}

@param port: The port number.
@type port: L{int}

@return: a stub L{IOpenSSLClientConnectionCreator}
@rtype: L{JustEnoughCreator}
re   )r[   r  rw  r  s      €r\   ÚcreatorForNetlocÚpAgentHTTPSTests.test_connectHTTPSCustomConnectionCreator.<locals>.StubBrowserLikePolicyForHTTPS.creatorForNetlocä  s   ø€ ñ )¨Ó8Ð8r_   re   N©r`   ra   rb   rc   r"  rd   )r  s   €r\   ÚStubBrowserLikePolicyForHTTPSr   â  s   ø† ÷9ð 9r_   r%  s   https://%b:%déÿÿÿÿrÐ   Nr   rÀ   )r   r   rH   r
  r0   r'  r(  r:   r]  r  r   rî  r    r  r  r.  r&   rM  rR   r¬   r–   r
  r  )r[   r`  ra  r  r%  ÚexpectedCreatorCreatorr)  r*  r  Ú
tlsFactoryr  rP   r  r  r  s               @@@r\   Ú(test_connectHTTPSCustomConnectionCreatorÚ8AgentHTTPSTests.test_connectHTTPSCustomConnectionCreator°  sd  ú€ ð &ˆØˆ÷	)ñ 	)ð  ˆä	Ô4Ó	5÷	*ô 	*ó 
6ð	*ñ" 2Ó3Ðä	”_Ó	%÷	9ó 	9ó 
&ð	9ñ  "?Ó!@ÐØ×$Ñ$Ó&ˆÜ—’˜WÓ=ˆØ×%Ñ%Ü�MŠMÐ*¨lÐ-IÑIÓJó
ˆð 	×Ñœ×,Ò,¬XÓ6Ô7Ø×'Ñ'¨Ñ+¨AÑ.ˆ
Ø ×.Ñ.¨tÓ4ˆØ×"Ñ"¤?Ó#4Ô5Ø˜!‰n˜QÑˆØ×Ñ˜cÔ#7Ô8Ø×Ñ˜ Q™¨¨Ð+¨lÐ-IÔJØ�‰Ð*×;Ñ;Ô<Ø�‰Ð*×7Ñ7Õ8r_   c                óÖ   • S nU" 5         U R                  U/5      nU R                  [        U5      S5        Uu  nU R                  US   [        5        U R                  US   S5        g)a   
Passing something that duck-types I{like} a L{web client context
factory <twisted.web.client.WebClientContextFactory>} - something that
does not provide L{IPolicyForHTTPS} - to L{Agent} emits a
L{DeprecationWarning} even if you don't actually C{import
WebClientContextFactory} to do it.
c                 óT   • [         R                  " [        [        5       5      S5        g )Nz does-not-provide-IPolicyForHTTPS)r0   r'  r"   r%   re   r_   r\   ÚwarnMeÚ9AgentHTTPSTests.test_deprecatedDuckPolicy.<locals>.warnMe  s   € Ü�LŠLÜ-Ô.@Ó.BÓCØ2õr_   rÀ   ÚcategoryÚmessagezº'does-not-provide-IPolicyForHTTPS' was passed as the HTTPS policy for an Agent, but it does not provide IPolicyForHTTPS.  Since Twisted 14.0, you must pass a provider of IPolicyForHTTPS.N)ÚflushWarningsr¬   r³   ÚDeprecationWarning)r[   r-  ÚwarningsÚwarnings       r\   Útest_deprecatedDuckPolicyÚ)AgentHTTPSTests.test_deprecatedDuckPolicy  sm   € ò	ñ 	ŒØ×%Ñ% v hÓ/ˆØ×Ñœ˜X›¨Ô*Ø‰	ˆØ×Ñ˜ Ñ,Ô.@ÔAØ×ÑØ�IÑðOõ	
r_   c                óú   • [        5       n[        US9nUR                  SS5      nU R                  UR                  5        UR                  S5      nU R                  UR                  UR                  5       5        g)z�
L{BrowserLikePolicyForHTTPS.creatorForNetloc} returns an
L{IOpenSSLClientConnectionCreator} provider which will add certificates
from the given trust root.
©Ú	trustRoots   thingyrü  N)	rT   r;   r"  r–   rY   r  rÙ  rZ   Úget_context)r[   r9  ÚpolicyÚcreatorÚ
connections        r\   Útest_alternateTrustRootÚ'AgentHTTPSTests.test_alternateTrustRoot  sg   € ô +Ó,ˆ	Ü*°YÑ?ˆØ×)Ñ)¨)°TÓ:ˆØ�‰˜	×(Ñ(Ô)Ø×3Ñ3°DÓ9ˆ
Ø�‰�i×'Ñ'¨×)?Ñ)?Ó)AÕBr_   c           	     ó¢   >^^• UR                  S5      n[        UR                  S5      5      u  mmU4S jnU4S jn[        T	U ]  UUUUUSS9  g)z3
Wrap L{AgentTestsMixin.integrationTest} with TLS.
s   []Úasciic                ó:   >• [        TR                  5       SX5      $ rE  )rQ   Úoptions)ÚserverFactoryr)  r×  s     €r\   ÚtlsifyÚ/AgentHTTPSTests.integrationTest.<locals>.tlsify4  s   ø€ Ü& v§~¡~Ó'7¸ÀÓWÐWr_   c                ó~   >• SSK Jn  SSKJn  U" U5       " U4S jS5      5       n[        R
                  " X" 5       S9$ )Nr   r   )rH   c                  ó"   >• \ rS rSrU 4S jrSrg)ÚAAgentHTTPSTests.integrationTest.<locals>.tlsagent.<locals>.Policyi<  c                ó6   >• [        UR                  S5      TS9$ )NrA  r8  )rO   Údecode)r[   r  rw  Ú	authoritys      €r\   r"  ÚRAgentHTTPSTests.integrationTest.<locals>.tlsagent.<locals>.Policy.creatorForNetloc>  s   ø€ Ü.Ø Ÿ™¨Ó0¸Iñð r_   re   Nr$  )rL  s   €r\   ÚPolicyrI  <  s   ø† ÷ð r_   rN  )r  )Úzope.interfacer   Útwisted.web.iwebrH   r0   r'  )r)  r   rH   rN  rL  s       €r\   ÚtlsagentÚ1AgentHTTPSTests.integrationTest.<locals>.tlsagent7  s:   ø€ Ý2å8á˜Ó)÷ó ó *ðô —<’< ¸»ÑAÐAr_   r•  )rú  rû  ru  N)Ústripr-   rK  ÚsuperrÊ  )
r[   r÷  rø  rù  ÚcertHostNamerE  rQ  rL  r×  rÕ  s
          @@€r\   rÊ  ÚAgentHTTPSTests.integrationTest+  sb   ú€ ð  —~‘~ eÓ,ˆÜ=Ø×Ñ Ó(ó
Ñˆ	�6õ	Xõ	Bô ‰GÑ#ØØØØ$Ø$Øð $ò r_   re   )r^  r{  )r`   ra   rb   rc   ry   rð  rö  rù  rý  r  r)  r5  r>  rÊ  rd   Ú__classcell__)rÕ  s   @r\   rî  rî  u  sA   ø† ñô
ò$	KòMòHòBòQ9òf
ò6C÷#
ó #
r_   rî  c                  ó’   • \ rS rSrSrS rS r\" \S5      S 5       r	\" \(       + S5      S 5       r
\" \(       + S5      S	 5       rS
rg)ÚWebClientContextFactoryTestsiQ  zf
Tests for the context factory wrapper for web clients
L{twisted.web.client.WebClientContextFactory}.
c                óf   • SSK Jn  U R                  [        R                  /5      U l        Xl        g)zE
Get WebClientContextFactory while quashing its deprecation warning.
r   )ÚWebClientContextFactoryN)Útwisted.web.clientr[  r1  rY  r“   ÚwarnedÚwebClientContextFactory)r[   r[  s     r\   r“   Ú"WebClientContextFactoryTests.setUpW  s)   € õ 	?à×(Ñ(Ô*F×*LÑ*LÐ)MÓNˆŒØ'>Õ$r_   c                ó,  • U R                  [        U R                  5      S5        U R                  u  nU R                  US   [        5        U R                  US   [	        U R
                  [        SSSS5      [        S9R                  SS	5      5        g
)z`
L{twisted.web.client.WebClientContextFactory} is deprecated.  Importing
it displays a warning.
rÀ   r/  r0  ÚTwistedé   r   )ÚreplacementÚ;Ú:N)	r¬   r³   r]  r2  r)   r^  r   r;   Úreplace)r[   r4  s     r\   Útest_deprecatedÚ,WebClientContextFactoryTests.test_deprecated`  s„   € ð
 	×Ñœ˜TŸ[™[Ó)¨1Ô-Ø—K‘K‰	ˆØ×Ñ˜ Ñ,Ô.@ÔAØ×ÑØ�IÑÜ'Ø×,Ñ,Ü˜	 2 q¨!Ó,Ü5ñ÷ ‰W�S˜#Óõ		
r_   zSSL Present.c                ód   • U R                  [        U R                  5       R                  SS5        g)zT
If C{getContext} is called and SSL is not available, raise
L{NotImplementedError}.
r^  r{  N)rM  ÚNotImplementedErrorr^  Ú
getContextrn   s    r\   Útest_missingSSLÚ,WebClientContextFactoryTests.test_missingSSLs  s-   € ð 	×ÑÜØ×(Ñ(Ó*×5Ñ5ØØõ		
r_   r«  c                ó˜   • U R                  5       R                  SS5      nU R                  U[        R                  R
                  5        g)zD
If SSL is present, C{getContext} returns a L{OpenSSL.SSL.Context}.
rý   r{  N)r^  rk  rM  rL   ÚSSLÚContext)r[   Úctxs     r\   Útest_returnsContextÚ0WebClientContextFactoryTests.test_returnsContext€  s7   € ð
 ×*Ñ*Ó,×7Ñ7¸ÀsÓKˆØ×Ñ˜c¤3§7¡7§?¡?Õ3r_   c                óœ   • U R                  5       nUR                  SS5      nU R                  UR                  [        R
                  5        g)zL
The L{CertificateOptions} has C{trustRoot} set to the default trust
roots.
rý   r{  N)r^  Ú_getCertificateOptionsrM  r9  rL   ÚOpenSSLDefaultPaths)r[   rq  ÚcertificateOptionss      r\   Ú-test_setsTrustRootOnContextToDefaultTrustRootÚJWebClientContextFactoryTests.test_setsTrustRootOnContextToDefaultTrustRootˆ  sB   € ð ×*Ñ*Ó,ˆØ ×7Ñ7¸ÀsÓKÐØ×ÑÐ0×:Ñ:¼C×<SÑ<SÕTr_   )r]  r^  N)r`   ra   rb   rc   ry   r“   rg  r   rì  rl  rr  rx  rd   re   r_   r\   rY  rY  Q  sl   † ñò
?ò
ñ& ˆJ˜Ó'ñ

ó (ð

ñ �
ŒNÐDÓEñ4ó Fð4ñ �
ŒNÐDÓEñUó FóUr_   rY  c                  óf   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rSrg)ÚHTTPConnectionPoolRetryTestsi“  z˜
L{client.HTTPConnectionPool}, by using
L{client._RetryingHTTP11ClientProtocol}, supports retrying requests done
against previously cached connections.
c                óª  • [         R                  " S5      n[         R                  " SU5      nU R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       S5      5        g)	z?
Only GET, HEAD, OPTIONS, TRACE, DELETE methods cause a retry.
Nrà  s   HEADs   OPTIONSs   TRACEs   DELETEó   POSTs   MYMETHOD)r0   r>   Ú_RetryingHTTP11ClientProtocolr–   Ú_shouldRetryr5   ÚassertFalse©r[   rG  r=  s      r\   Útest_onlyRetryIdempotentMethodsÚ<HTTPConnectionPoolRetryTests.test_onlyRetryIdempotentMethodsš  sý   € ô ×(Ò(¨Ó.ˆÜ×9Ò9¸$ÀÓEˆ
Ø�‰˜
×/Ñ/°¼Ó8HÈ$ÓOÔPØ�‰˜
×/Ñ/°¼Ó9IÈ4ÓPÔQØ�‰˜
×/Ñ/°
¼NÓ<LÈdÓSÔTØ�‰˜
×/Ñ/°¼.Ó:JÈDÓQÔRØ�‰˜
×/Ñ/°	¼>Ó;KÈTÓRÔSØ×Ñ˜×0Ñ0°¼.Ó:JÈDÓQÔRØ×Ñ˜×0Ñ0°¼nÓ>NÐPTÓUÕVr_   c                ó  • [         R                  " S5      n[         R                  " SU5      nU R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        / 5      S5      5        U R                  UR	                  S[        / 5      S5      5        U R                  UR	                  S[        / 5      S5      5        U R                  UR	                  S[        5       S5      5        g)zm
Only L{RequestNotSent}, L{RequestTransmissionFailed} and
L{ResponseNeverReceived} exceptions cause a retry.
Nrà  )r0   r>   r~  r–   r  r5   r6   r9   r€  r8   r   r�  s      r\   Ú"test_onlyRetryIfNoResponseReceivedÚ?HTTPConnectionPoolRetryTests.test_onlyRetryIfNoResponseReceived«  sÖ   € ô
 ×(Ò(¨Ó.ˆÜ×9Ò9¸$ÀÓEˆ
Ø�‰˜
×/Ñ/°¼Ó8HÈ$ÓOÔPØ�‰Ø×#Ñ# FÔ,EÀbÓ,IÈ4ÓPô	
ð 	�‰Ø×#Ñ# FÔ,AÀ"Ó,EÀtÓLô	
ð 	×Ñ˜×0Ñ0°¼ÈÓ9KÈTÓRÔSØ×ÑØ×#Ñ# FÔ,BÓ,DÀdÓKõ	
r_   c                óò   • [         R                  " S5      n[         R                  " SU5      n[        [	        [
        R                  " 5       5      /5      nU R                  UR                  SUS5      5        g)z‹
If a request failed due to the operation being cancelled,
C{_shouldRetry} returns C{False} to indicate the request should not be
retried.
Nrà  )	r0   r>   r~  r9   r*   r   r   r€  r  )r[   rG  r=  rh  s       r\   Ú!test_dontRetryIfFailedDueToCancelÚ>HTTPConnectionPoolRetryTests.test_dontRetryIfFailedDueToCancel¾  s^   € ô ×(Ò(¨Ó.ˆÜ×9Ò9¸$ÀÓEˆ
Ü)¬7´5×3GÒ3GÓ3IÓ+JÐ*KÓLˆ	Ø×Ñ˜×0Ñ0°¸ÀDÓIÕJr_   c                óØ   • [         R                  " S5      n[         R                  " SU5      nU R                  UR	                  S[        [        [        5       5      /5      S5      5        g)zŸ
If a request failed with L{ResponseNeverReceived} due to some
arbitrary exception, C{_shouldRetry} returns C{True} to indicate the
request should be retried.
Nrà  )r0   r>   r~  r–   r  r9   r*   Ú	Exceptionr�  s      r\   Ú)test_retryIfFailedDueToNonCancelExceptionÚFHTTPConnectionPoolRetryTests.test_retryIfFailedDueToNonCancelExceptionÉ  sW   € ô ×(Ò(¨Ó.ˆÜ×9Ò9¸$ÀÓEˆ
Ø�‰Ø×#Ñ#ØÔ-¬w´y³{Ó/CÐ.DÓEÀtóõ	
r_   c                ó  ^ ^• [         R                  " [        5       5      n[        5       mTR	                  [        5       5        UR                  ST5        UR                  S[        5       5      nUU 4S jnUR                  U5      $ )z™
If L{client.HTTPConnectionPool.getConnection} returns a previously
cached connection, it will get wrapped in a
L{client._RetryingHTTP11ClientProtocol}.
é{   c                ó~   >• TR                  U [        R                  5        TR                  U R                  T5        g r~   )rM  r0   r~  rƒ  Ú_clientProtocol©r=  r  r[   s    €€r\   rR  ÚTHTTPConnectionPoolRetryTests.test_wrappedOnPersistentReturned.<locals>.gotConnectionè  s/   ø€ Ø×!Ñ! *¬f×.RÑ.RÔSØ× Ñ  ×!;Ñ!;¸XÕFr_   )
r0   r>   r!   rg   r.  r&   ra  rU  r2  rV  ©r[   rG  rX  rR  r  s   `   @r\   Ú test_wrappedOnPersistentReturnedÚ=HTTPConnectionPoolRetryTests.test_wrappedOnPersistentReturned×  so   ù€ ô ×(Ò(¬«Ó1ˆô $Ó%ˆØ×Ñ¤Ó 1Ô2Ø×Ñ˜C Ô*ð ×Ñ˜s¤M£OÓ4ˆö	Gð �}‰}˜]Ó+Ð+r_   c                ó’   ^ • [         R                  " S5      nUR                  S[        5       5      nU 4S jnUR	                  U5      $ )zd
If L{client.HTTPConnectionPool.getConnection} returns a new
connection, it will be returned as is.
Nr�  c                óF   >• TR                  U R                  [        5        g r~   )rƒ  rÕ  r3   )r=  r[   s    €r\   rR  ÚPHTTPConnectionPoolRetryTests.test_notWrappedOnNewReturned.<locals>.gotConnectionö  s   ø€ ð × Ñ  ×!5Ñ!5Ô7KÕLr_   )r0   r>   rU  r2  rV  )r[   rG  rX  rR  s   `   r\   Útest_notWrappedOnNewReturnedÚ9HTTPConnectionPoolRetryTests.test_notWrappedOnNewReturnedî  s@   ø€ ô
 ×(Ò(¨Ó.ˆØ×Ñ˜s¤M£OÓ4ˆõ	Mð
 �}‰}˜]Ó+Ð+r_   c                óÐ  ^ ^^^	• / m	U	4S jn[        5       m[        R                  " SS[        5       TSS9nU" 5         T	S   n[        R                  " XB5      nUU U4S jnXel        UR                  U5      nT R                  [        T	5      S5        T R                  [        T	S   R                  5      S5        UR                  S   S   R                  [        5       5        UT	4$ )	z@
Fail a first request, possibly retrying depending on argument.
c                 óf   >• [        5       n TR                  U 5        [        R                  " U 5      $ r~   )rg   rr   r   r   )r  Ú	protocolss    €r\   ro  Ú>HTTPConnectionPoolRetryTests.retryAttempt.<locals>.newProtocol  s(   ø€ Ü'Ó)ˆHØ×Ñ˜XÔ&Ü—=’= Ó*Ð*r_   rË  râ  Tr*  r   c                óˆ   >• TR                  U S5        TR                  UT5        TR                  U[        [        45        T$ )NrË  )r¬   rƒ  rM  r5   r9   )Úmrj  ÚbprD  r[   ÚwillWeRetrys      €€€r\   r  Ú?HTTPConnectionPoolRetryTests.retryAttempt.<locals>._shouldRetry  s?   ø€ Ø×Ñ˜Q Ô'Ø× Ñ   \Ô2Ø×!Ñ! !¤nÔ6KÐ%LÔMØÐr_   rÀ   )rF  r0   r?   rC   r~  r  rs   r¬   r³   rl   Úerrbackr5   )
r[   r£  ro  rs   r  Úretrierr  rX  rD  rž  s
   ``      @@r\   ÚretryAttemptÚ)HTTPConnectionPoolRetryTests.retryAttemptý  sÌ   û€ ð ˆ	õ	+ô
 “xˆÜ—.’. ¨¬w«y¸,ÐSWÑXˆÙŒØ˜Q‘<ˆÜ×6Ò6°xÓMˆ÷	ð  ,Ôà�O‰O˜GÓ$ˆð 	×Ñœ˜Y›¨Ô+Ø×Ñœ˜Y q™\×2Ñ2Ó3°QÔ7ð 	×Ñ˜!Ñ˜QÑ×'Ñ'¬Ó(8Ô9Ø�)ˆ|Ðr_   c                óò   • U R                  S5      u  pU R                  [        U5      S5        [        5       nUS   R                  S   S   R                  U5        UR                  U R                  U5      $ )z|
L{client._RetryingHTTP11ClientProtocol} retries when
L{client._RetryingHTTP11ClientProtocol._shouldRetry} returns C{True}.
TrÐ   rÀ   r   )r§  r¬   r³   rF  rl   rÂ  rV  rƒ  )r[   rX  rž  r  s       r\   Ú"test_retryIfShouldRetryReturnsTrueÚ?HTTPConnectionPoolRetryTests.test_retryIfShouldRetryReturnsTrue   sj   € ð
 ×(Ñ(¨Ó.‰ˆà×Ñœ˜Y›¨Ô+Ü“8ˆØ�!‰×Ñ˜aÑ  Ñ#×,Ñ,¨XÔ6Ø�}‰}˜T×1Ñ1°8Ó<Ð<r_   c                óŠ   • U R                  S5      u  pU R                  [        U5      S5        U R                  U[        5      $ )z„
L{client._RetryingHTTP11ClientProtocol} does not retry when
L{client._RetryingHTTP11ClientProtocol._shouldRetry} returns C{False}.
FrÀ   )r§  r¬   r³   rS  r5   ©r[   rX  rž  s      r\   Ú'test_dontRetryIfShouldRetryReturnsFalseÚDHTTPConnectionPoolRetryTests.test_dontRetryIfShouldRetryReturnsFalse,  s=   € ð
 ×(Ñ(¨Ó/‰ˆà×Ñœ˜Y›¨Ô+Ø×!Ñ! !¤^Ó4Ð4r_   c                ó  • [         R                  " S5      n[         R                  " SU5      nU R                  UR	                  S[        5       S5      5        U R                  UR	                  S[        5       [        5       5      5        g)zç
L{_RetryingHTTP11ClientProtocol} only retries queries that don't have
a body.

This is an implementation restriction; if the restriction is fixed,
this test should be removed and PUT added to list of methods that
support retries.
Nrà  )r0   r>   r~  r–   r  r5   r€  rF  r�  s      r\   Útest_onlyRetryWithoutBodyÚ6HTTPConnectionPoolRetryTests.test_onlyRetryWithoutBody6  sf   € ô ×(Ò(¨Ó.ˆÜ×9Ò9¸$ÀÓEˆ
Ø�‰˜
×/Ñ/°¼Ó8HÈ$ÓOÔPØ×Ñ˜×0Ñ0°¼Ó9IÌ6Ë8ÓTÕUr_   c                ó  • U R                  S5      u  pU R                  [        U5      S5        US   R                  S   S   R	                  [        / 5      5        U R                  [        U5      S5        U R                  U[
        5      $ )zŒ
If a L{client._RetryingHTTP11ClientProtocol} fails more than once on
an idempotent query before a response is received, it will not retry.
TrÐ   rÀ   r   )r§  r¬   r³   rl   r¥  r9   rS  r­  s      r\   Útest_onlyRetryOnceÚ/HTTPConnectionPoolRetryTests.test_onlyRetryOnceD  sz   € ð
 ×(Ñ(¨Ó.‰ˆØ×Ñœ˜Y›¨Ô+à�!‰×Ñ˜aÑ  Ñ#×+Ñ+Ô,AÀ"Ó,EÔFà×Ñœ˜Y›¨Ô+Ø×!Ñ! !Ô%:Ó;Ð;r_   c                ó  ^ ^• [         R                  " [        5       5      nSUl        [	        5       mTR                  [        5       5        UR                  ST5        UR                  S[        5       5      nUU 4S jnUR                  U5      $ )zm
If L{HTTPConnectionPool.retryAutomatically} is set to C{False}, don't
wrap connections with retrying logic.
Fr�  c                ó*   >• TR                  U T5        g r~   )rƒ  r’  s    €€r\   rR  Ú[HTTPConnectionPoolRetryTests.test_dontRetryIfRetryAutomaticallyFalse.<locals>.gotConnectiona  s   ø€ Ø× Ñ  ¨XÕ6r_   )r0   r>   r!   rI  rg   r.  r&   ra  rU  r2  rV  r”  s   `   @r\   Ú'test_dontRetryIfRetryAutomaticallyFalseÚDHTTPConnectionPoolRetryTests.test_dontRetryIfRetryAutomaticallyFalseQ  sv   ù€ ô
 ×(Ò(¬«Ó1ˆØ"'ˆÔô $Ó%ˆØ×Ñ¤Ó 1Ô2Ø×Ñ˜C Ô*ð ×Ñ˜s¤M£OÓ4ˆö	7ð �}‰}˜]Ó+Ð+r_   c                ó@  ^ ^^^^• [         R                  " [        5       5      nSm[        5       m/ mU4S jnX!l        [        5       mTR                  [        5       5        UR                  TT5        UR                  TT5      nUUUUU 4S jnUR                  U5      $ )zË
L{client.HTTPConnectionPool} creates
{client._RetryingHTTP11ClientProtocol} with a new connection factory
method that creates a new connection using the same key and endpoint
as the wrapped connection.
r�  c                ó*   >• TR                  X45        g r~   )rr   )Úkrj  ÚnewConnectionss     €r\   rŠ  ÚOHTTPConnectionPoolRetryTests.test_retryWithNewConnection.<locals>.newConnections  s   ø€ Ø×!Ñ! 1 &Õ)r_   c                óX  >• TR                  U [        R                  5        TR                  U R                  T5        TR                  T/ 5        U R                  5         TR                  [        T5      S5        TR                  TS   S   T5        TR                  TS   S   T5        g )NrÀ   r   )rM  r0   r~  rƒ  r‘  r¬   r�  r³   )r=  r  r‹  r¾  r  r[   s    €€€€€r\   rR  ÚOHTTPConnectionPoolRetryTests.test_retryWithNewConnection.<locals>.gotConnection�  s–   ø€ Ø×!Ñ! *¬f×.RÑ.RÔSØ× Ñ  ×!;Ñ!;¸XÔFð ×Ñ˜^¨RÔ0Ø×%Ñ%Ô'Ø×ÑœS Ó0°!Ô4Ø×Ñ˜^¨AÑ.¨qÑ1°3Ô7Ø× Ñ  °Ñ!2°1Ñ!5°xÕ@r_   )r0   r>   r!   r2  r�  rg   r.  r&   ra  rU  rV  )	r[   rG  rŠ  rX  rR  r  r‹  r¾  r  s	   `    @@@@r\   Útest_retryWithNewConnectionÚ8HTTPConnectionPoolRetryTests.test_retryWithNewConnectionf  s‘   ü€ ô ×(Ò(¬«Ó1ˆØˆÜ “?ˆØˆõ	*ð ,Ôô $Ó%ˆØ×Ñ¤Ó 1Ô2Ø×Ñ˜C Ô*ð ×Ñ˜s HÓ-ˆ÷		Añ 		Að �}‰}˜]Ó+Ð+r_   re   N)r`   ra   rb   rc   ry   r‚  r…  rˆ  rŒ  r•  rš  r§  rª  r®  r±  r´  r¹  rÂ  rd   re   r_   r\   r{  r{  “  sL   † ñòWò"
ò&	Kò
ò,ò.,ò!òF
=ò5òVò<ò,õ*&,r_   r{  c                  ó2   • \ rS rSrSr        SS jrSrg)ÚCookieTestsMixini�  z,
Mixin for unit tests dealing with cookies.
c                óÈ   • [         R                  " [         R                  " SSS[        SU05      S5      5      n[         R                  " U5      nUR                  XE5        XT4$ )z
Add a cookie to a cookie jar.
r¾  r¿  rÀ  ó
   Set-CookieN)r0   Ú_FakeStdlibResponser7   rC   Ú_FakeStdlibRequestÚextract_cookies)r[   Ú	cookieJarr  Úcookiesr  rs   s         r\   Ú
addCookiesÚCookieTestsMixin.addCookies”  sb   € ô ×-Ò-Ü�OŠOØØØÜ˜¨Ð0Ó1Øóó
ˆô ×+Ò+¨CÓ0ˆØ×!Ñ! (Ô4ØÐ Ð r_   re   N)rË  r   r  r„   rÌ  zlist[bytes]rw   z<tuple[client._FakeStdlibRequest, client._FakeStdlibResponse])r`   ra   rb   rc   ry   rÍ  rd   re   r_   r\   rÅ  rÅ  �  s,   † ñð!Ø"ð!Ø).ð!Ø9Dð!à	E÷!r_   rÅ  c                  ó:   • \ rS rSrSr  SS jrS	S jrS	S jrSrg)
ÚCookieJarTestsi¨  zŽ
Tests for L{twisted.web.client._FakeStdlibResponse} and
L{twisted.web.client._FakeStdlibRequest}'s interactions with L{CookieJar}
instances.
c                óF   • [        5       nU R                  USSS/5      nX4$ )z2
@return: a L{CookieJar} with some sample cookies
rž  s(   foo=1; cow=moo; Path=/foo; Comment=hellos   bar=2; Comment=goodbye)r   rÍ  )r[   rË  Úreqress      r\   ÚmakeCookieJarÚCookieJarTests.makeCookieJar¯  s3   € ô “Kˆ	Ø—‘ØØ.Ø8Ð:SÐTó
ˆð
 Ð Ð r_   c                ó4  • U R                  5       S   nU Vs0 s H  o"R                  U_M     nnUS   nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S5        U R                  UR
                  S5        U R                  UR                  S5        U R                  UR                  S5      S5        US   nU R                  UR                  S5        U R                  UR                  S5        U R                  UR                  S	5        U R                  UR
                  S
5        U R                  UR                  S5        U R                  UR                  S5      S5        gs  snf )z¢
L{CookieJar.extract_cookies} extracts cookie information from our
stdlib-compatibility wrappers, L{client._FakeStdlibRequest} and
L{client._FakeStdlibResponse}.
r   rþ   Ú1z/fooÚhelloÚcowÚmooÚbarÚ2Ú/ÚgoodbyeN)	rÓ  Únamer¬   Úversionr™  ÚpathÚcommentÚget_nonstandard_attrrƒ  )r[   ÚjarÚcrÌ  Úcookies        r\   Útest_extractCookiesÚ"CookieJarTests.test_extractCookies½  sF  € ð × Ñ Ó" 1Ñ%ˆÙ&)Ó*¢c —6‘6˜1’9¡cˆÐ*à˜‘ˆØ×Ñ˜Ÿ™¨Ô+Ø×Ñ˜Ÿ™ eÔ,Ø×Ñ˜Ÿ™ sÔ+Ø×Ñ˜Ÿ™ fÔ-Ø×Ñ˜Ÿ™¨Ô1Ø×Ñ˜×4Ñ4°UÓ;¸UÔCà˜‘ˆØ×Ñ˜Ÿ™¨Ô+Ø×Ñ˜Ÿ™ eÔ,Ø×Ñ˜Ÿ™ sÔ+Ø×Ñ˜Ÿ™ cÔ*Ø×Ñ˜Ÿ™¨Ô3Ø×Ñ˜V×8Ñ8¸Ó?ÀÕFùò! +s   ˜Fc                ó  • U R                  5       u  nu  p#U R                  UR                  SS5      S5        UR                  U5        U R	                  [        UR                  R                  5       5      SS/4/5        g)zx
L{CookieJar.add_cookie_header} adds a cookie header to a Twisted
request via our L{client._FakeStdlibRequest} wrapper.
ÚCookieNs   Cookies   foo=1; bar=2)rÓ  rƒ  Ú
get_headerÚadd_cookie_headerr¬   ÚlistÚ_twistedHeadersÚgetAllRawHeaders)r[   rã  rs   r  s       r\   Útest_sendCookieÚCookieJarTests.test_sendCookieÖ  sx   € ð
 $(×#5Ñ#5Ó#7Ñ ˆÑ ˆgà×Ñ˜W×/Ñ/°¸$Ó?ÀÔFà×Ñ˜gÔ&Ø×ÑÜ�×(Ñ(×9Ñ9Ó;Ó<Ø˜/Ð*Ð+Ð,õ	
r_   re   N)rw   zNtuple[CookieJar, tuple[client._FakeStdlibRequest, client._FakeStdlibResponse]]rv   )	r`   ra   rb   rc   ry   rÓ  ræ  rï  rd   re   r_   r\   rÐ  rÐ  ¨  s   † ñð!à	Wô!ôG÷2
r_   rÐ  c                  ót   • \ rS rSrSrS rS rS rSS jrS r	\
" \(       + S5      S	 5       rS
 rS rS rSrg)ÚCookieAgentTestsiæ  z.
Tests for L{twisted.web.client.CookieAgent}.
c                ór   • [         R                  " U R                  U R                  5      [	        5       5      $ )z2
@return: a new L{twisted.web.client.CookieAgent}
)r0   ÚCookieAgentr+  r)  r   rn   s    r\   rÅ  ÚCookieAgentTests.makeAgentí  s-   € ô ×!Ò!Ø×)Ñ)¨$¯,©,Ó7¼»ó
ð 	
r_   c                ó.   • U R                  5       U l        g r~   )r
  r)  rn   s    r\   r“   ÚCookieAgentTests.setUpõ  s   € Ø×)Ñ)Ó+ˆ�r_   c           	     ó  ^ ^• [        5       mT R                  [        T5      / 5        T R                  T R                  5      n[
        R                  " UT5      nUR                  SS5      nUU 4S jnUR                  U5        T R                  R                  R                  5       u  pVT R                  UR                  R                  S5      S5        [
        R                  " SSS[!        S	S
/05      S5      nUR#                  U5        U$ )zå
L{CookieAgent.request} does not insert any C{'Cookie'} header into the
L{Request} object if there is no cookie in the cookie jar for the URI
being requested. Cookies are extracted from the response and stored in
the cookie jar.
rà  rž  c                óÎ   >• [        T5      nTR                  [        U5      S5        TR                  US   R                  S5        TR                  US   R                  S5        g )NrÀ   r   rþ   rÖ  )rì  r¬   r³   rÞ  r™  )ÚignoredrÌ  rË  r[   s     €€r\   Ú_checkCookieÚACookieAgentTests.test_emptyCookieJarRequest.<locals>._checkCookie  sR   ø€ Ü˜9“oˆGØ×ÑœS ›\¨1Ô-Ø×Ñ˜W Q™ZŸ_™_¨eÔ4Ø×Ñ˜W Q™Z×-Ñ-¨sÕ3r_   ó   cookieNr¾  r¿  rÀ  rÇ  ó   foo=1)r   r¬   rì  r+  r)  r0   rô  rs   rV  r  rl   rÃ   rƒ  rõ  rö  r7   rC   rÂ  )	r[   r*  ÚcookieAgentrX  rû  rt  ru  rÄ  rË  s	   `       @r\   Útest_emptyCookieJarRequestÚ+CookieAgentTests.test_emptyCookieJarRequestø  sì   ù€ ô “Kˆ	Ø×Ñœ˜i›¨"Ô-à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨°	Ó:ˆØ×Ñ Ð(JÓKˆö	4ð 	
�‰�lÔ#à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜SŸ[™[×6Ñ6°yÓAÀ4ÔHä�ŠØØØÜà!Ø ð$ðóð ó
ˆð 	�‰�TÔàˆr_   c                óÒ  • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        U R                  U R                  5      n[        R                  " XC5      nUR                  SU[        SS/05      5        U R                  R                  R                  5       u  pgU R                  UR                  R                  S5      S/5        g	)
z¥
L{CookieAgent.request} will not insert a C{'Cookie'} header into the
L{Request} object when there is already a C{'Cookie'} header in the
request headers parameter.
rž  rþ  rÀ   rà  rå  zalready-setrý  s   already-setN)r   rÍ  r¬   r³   rì  r+  r)  r0   rô  rs   rC   r  rl   rÃ   rõ  rö  ©r[   r  rå  rË  r*  rÿ  rt  ru  s           r\   Útest_leaveExistingCookieHeaderÚ/CookieAgentTests.test_leaveExistingCookieHeader"  s¼   € ð 1ˆØˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÔ1à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨Ó:ˆØ×Ñ˜F C¬°(¸]¸OÐ1LÓ)MÔNà—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°9Ó=ÀÐ?OÕPr_   c                ó¸  • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        U R                  U R                  5      n[        R                  " XC5      nUR                  SU5        U R                  R                  R                  5       u  pgU R                  UR                  R                  S5      U/5        g)z“
L{CookieAgent.request} inserts a C{'Cookie'} header into the L{Request}
object when there is a cookie matching the request URI in the cookie
jar.
rž  rþ  rÀ   rà  rý  N©r   rÍ  r¬   r³   rì  r+  r)  r0   rô  rs   r  rl   rÃ   rõ  rö  r  s           r\   Útest_requestWithCookieÚ'CookieAgentTests.test_requestWithCookie6  s­   € ð 1ˆØˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÔ1à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨Ó:ˆØ×Ñ˜F CÔ(à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°9Ó=À¸xÕHr_   r«  c                ó¸  • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        U R                  U R                  5      n[        R                  " XC5      nUR                  SU5        U R                  R                  R                  5       u  pgU R                  UR                  R                  S5      S/5        g)zf
L{CookieAgent} is able to handle secure cookies, ie cookies which
should only be handled over https.
s    https://example.com:1234/foo?baró   foo=1;securerÀ   rà  rý  rþ  Nr  r  s           r\   Útest_secureCookieÚ"CookieAgentTests.test_secureCookieJ  s­   € ð 2ˆØ ˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÔ1à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨Ó:ˆØ×Ñ˜F CÔ(à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°9Ó=À¸zÕJr_   c                ó¶  • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        U R                  U R                  5      n[        R                  " XC5      nUR                  SU5        U R                  R                  R                  5       u  pgU R                  SUR                  R                  S5      5        g)z[
If a cookie is setup as secure, it won't be sent with the request if
it's not over HTTPS.
rq  r  rÀ   rà  Nrý  )r   rÍ  r¬   r³   rì  r+  r)  r0   rô  rs   r  rl   rÃ   rƒ  rõ  rö  r  s           r\   Ú%test_secureCookieOnInsecureConnectionÚ6CookieAgentTests.test_secureCookieOnInsecureConnection^  s«   € ð
 ,ˆØ ˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÔ1à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨Ó:ˆØ×Ñ˜F CÔ(à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜T 3§;¡;×#<Ñ#<¸YÓ#GÕHr_   c                ó¸  • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        U R                  U R                  5      n[        R                  " XC5      nUR                  SU5        U R                  R                  R                  5       u  pgU R                  UR                  R                  S5      S/5        g)zb
L{CookieAgent} supports cookies which enforces the port number they
need to be transferred upon.
rž  ó   foo=1;port=1234rÀ   rà  rý  rþ  Nr  r  s           r\   Útest_portCookieÚ CookieAgentTests.test_portCookieq  s­   € ð
 1ˆØ#ˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÔ1à×-Ñ-¨d¯l©lÓ;ˆÜ×(Ò(¨Ó:ˆØ×Ñ˜F CÔ(à—=‘=×)Ñ)×-Ñ-Ó/‰ˆØ×Ñ˜Ÿ™×2Ñ2°9Ó=À¸zÕJr_   c                óŽ   • SnSn[        5       nU R                  X1U/5        U R                  [        [	        U5      5      S5        g)z
When creating a cookie with a port directive, it won't be added to the
L{cookie.CookieJar} if the URI is on a different port.
s   http://example.com:4567/foo?barr  r   N)r   rÍ  r¬   r³   rì  )r[   r  rå  rË  s       r\   Útest_portCookieOnWrongPortÚ+CookieAgentTests.test_portCookieOnWrongPort„  s>   € ð
 1ˆØ#ˆä“Kˆ	Ø�‰˜	¨¨Ô1Ø×ÑœœT )›_Ó-¨qÕ1r_   rÞ  Nrv   )r`   ra   rb   rc   ry   rÅ  r“   r   r  r  r   rì  r  r  r  r  rd   re   r_   r\   rò  rò  æ  sU   † ñò
ò,ò(ôTQò(Iñ( �
ŒNÐDÓEñKó FðKò&Iò&Kõ&
2r_   rò  c                  ó   • \ rS rSrSrSrg)ÚDecoder1i‘  úC
A test decoder to be used by L{client.ContentDecoderAgent} tests.
re   N©r`   ra   rb   rc   ry   rd   re   r_   r\   r  r  ‘  ó   † ôr_   r  c                  ó   • \ rS rSrSrSrg)ÚDecoder2i—  r  re   Nr  re   r_   r\   r  r  —  r  r_   r  c                  óB   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)ÚContentDecoderAgentTestsi�  z*
Tests for L{client.ContentDecoderAgent}.
c                óD   • [         R                  " U R                  / 5      $ )z:
@return: a new L{twisted.web.client.ContentDecoderAgent}
)r0   ÚContentDecoderAgentr*  rn   s    r\   rÅ  Ú"ContentDecoderAgentTests.makeAgent¢  s   € ô ×)Ò)¨$¯*©*°bÓ9Ð9r_   c                ón   • U R                  5       U l        U R                  U R                  5      U l        gr  )r
  r)  r+  r*  rn   s    r\   r“   ÚContentDecoderAgentTests.setUp¨  s*   € ð ×)Ñ)Ó+ˆŒØ×2Ñ2°4·<±<Ó@ˆ�
r_   c                óx  • [         R                  " U R                  S[        4S[        4/5      nUR                  SS5        U R                  nU R                  [        UR                  5      S5        UR                  R                  5       u  p4U R                  UR                  R                  S5      S/5        g)	zq
L{client.ContentDecoderAgent} sets the I{Accept-Encoding} header to the
names of the available decoder objects.
ó   decoder1ó   decoder2rà  r‡  rÀ   ó   accept-encodingó   decoder1,decoder2N)r0   r"  r*  r  r  rs   r  r¬   r³   rl   rÃ   rõ  rö  )r[   r*  r  rt  ru  s        r\   Útest_acceptHeadersÚ+ContentDecoderAgentTests.test_acceptHeaders¯  sž   € ô
 ×*Ò*Ø�J‰J˜+¤xÐ0°;ÄÐ2IÐJó
ˆð 	�‰�fÐ7Ô8à—=‘=ˆà×Ñœ˜X×.Ñ.Ó/°Ô3Ø×$Ñ$×(Ñ(Ó*‰ˆØ×ÑØ�K‰K×%Ñ%Ð&8Ó9Ð<PÐ;Qõ	
r_   c                óæ  • [         R                  " S/S/S.5      n[        R                  " U R                  S[
        4S[        4/5      nUR                  SSUS9  U R                  nU R                  [        UR                  5      S	5        UR                  R                  5       u  pEU R                  [        [        UR                  R!                  5       5      5      S
SS/4SS/4SS/4/5        g)z…
If there are existing I{Accept-Encoding} fields,
L{client.ContentDecoderAgent} creates a new field for the decoders it
knows about.
r~  ó   fizz)r4  r)  r'  r(  rà  r‡  ©rõ  rÀ   s   Accept-Encodingr*  ó   Foorë  r^  N)r2   rC   r0   r"  r*  r  r  rs   r  r¬   r³   rl   rÃ   rì  Úsortedrõ  rî  )r[   rõ  r*  r  rt  ru  s         r\   Útest_existingHeadersÚ-ContentDecoderAgentTests.test_existingHeadersÂ  sé   € ô ×&Ò&Ø�X°G°9Ñ=ó
ˆô ×*Ò*Ø�J‰J˜+¤xÐ0°;ÄÐ2IÐJó
ˆð 	�‰�fÐ7ÀˆÑIà—=‘=ˆà×Ñœ˜X×.Ñ.Ó/°Ô3Ø×$Ñ$×(Ñ(Ó*‰ˆØ×ÑÜ”˜Ÿ™×4Ñ4Ó6Ó7Ó8à# gÐ/CÐ%DÐEØ˜&˜Ð"Ø˜>Ð*Ð+ðõ	
r_   c                ón  • [         R                  " U R                  S[        4S[        4/5      nUR                  SS5      nU R                  R                  R                  5       u  p4[        SSS[        R                  " 5       S5      nUR                  U5        UR                  U R                  U5      $ )	z�
If the response is not encoded despited the request I{Accept-Encoding}
headers, L{client.ContentDecoderAgent} simply forwards the response.
r'  r(  rà  r‡  r¾  r¿  rÀ  N)r0   r"  r*  r  r  rs   r  rl   rÃ   r7   r2   rC   rÂ  rV  rƒ  )r[   r*  rü  rt  ru  r  s         r\   Útest_plainEncodingResponseÚ3ContentDecoderAgentTests.test_plainEncodingResponseÝ  sš   € ô
 ×*Ò*Ø�J‰J˜+¤xÐ0°;ÄÐ2IÐJó
ˆð —=‘= Ð)BÓCˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä˜O¨S°%¼×9MÒ9MÓ9OÐQUÓVˆØ�‰�XÔà×#Ñ# D×$8Ñ$8¸(ÓCÐCr_   c                ó~  • [         R                  " U R                  S[        4S[        4/5      nUR                  SS5      nU R                  R                  R                  5       u  p4[        R                  " S/S/S.5      n[        SS	S
US5      nUR                  U5        UR                  U R                  U5      $ )zb
If an encoding unknown to the L{client.ContentDecoderAgent} is found,
the response is unchanged.
r'  r(  rà  r‡  r~  r.  ©r4  ó   content-encodingr¾  r¿  rÀ  N)r0   r"  r*  r  r  rs   r  rl   rÃ   r2   rC   r7   rÂ  rV  rƒ  )r[   r*  rü  rt  ru  rõ  r  s          r\   Útest_unsupportedEncodingÚ1ContentDecoderAgentTests.test_unsupportedEncodingî  s®   € ô
 ×*Ò*Ø�J‰J˜+¤xÐ0°;ÄÐ2IÐJó
ˆð —=‘= Ð)BÓCˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ø�X°W°IÑ>ó
ˆô ˜O¨S°%¸À$ÓGˆØ�‰�XÔà×#Ñ# D×$8Ñ$8¸(ÓCÐCr_   c                óz  ^ ^• [         R                  " T R                  S[        4S[        4/5      nUR                  SS5      nT R                  R                  R                  5       u  p4[        R                  " S/S/S.5      n[        SS	S
US5      mUR                  T5        UU 4S jnUR                  U5      $ )z�
When L{client.ContentDecoderAgent} encounters a decoder it doesn't know
about, it stops decoding even if another encoding is known afterwards.
r'  r(  rà  r‡  r~  s   decoder1,fizz,decoder2r8  r¾  r¿  rÀ  Nc                ó®   >• TR                  TU 5        TR                  U [        5        TR                  S/U R                  R                  S5      5        g )Ns   decoder1,fizzr9  )r‰  rM  r  r¬   rõ  rö  )rt   r  r[   s    €€r\   ÚcheckÚ<ContentDecoderAgentTests.test_unknownEncoding.<locals>.check	  sI   ø€ Ø×#Ñ# H¨fÔ5Ø×!Ñ! &¬(Ô3Ø×ÑØ!Ð" F§N¡N×$@Ñ$@ÐATÓ$Uõr_   )r0   r"  r*  r  r  rs   r  rl   rÃ   r2   rC   r7   rÂ  rV  )r[   r*  rü  rt  ru  rõ  r>  r  s   `      @r\   Útest_unknownEncodingÚ-ContentDecoderAgentTests.test_unknownEncoding	  s°   ù€ ô
 ×*Ò*Ø�J‰J˜+¤xÐ0°;ÄÐ2IÐJó
ˆð —=‘= Ð)BÓCˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ø�XÐ5NÐ4OÑPó
ˆô ˜O¨S°%¸À$ÓGˆØ�‰�XÔö	ð ×#Ñ# EÓ*Ð*r_   rÜ  N)r`   ra   rb   rc   ry   rÅ  r“   r+  r2  r5  r:  r@  rd   re   r_   r\   r   r   �  s-   † ñò:òAò
ò&
ò6Dò"Dõ(+r_   r   c                  ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚSimpleAgentProtocoli	  zö
A L{Protocol} to be used with an L{client.Agent} to receive data.

@ivar finished: L{Deferred} firing when C{connectionLost} is called.

@ivar made: L{Deferred} firing when C{connectionMade} is called.

@ivar received: C{list} of received data.
c                óN   • [        5       U l        [        5       U l        / U l        g r~   )r   ÚmadeÚfinishedÚreceivedrn   s    r\   ro   ÚSimpleAgentProtocol.__init__)	  s   € Ü“JˆŒ	Ü ›
ˆŒØˆ�r_   c                ó:   • U R                   R                  S 5        g r~   )rE  rÂ  rn   s    r\   ÚconnectionMadeÚ"SimpleAgentProtocol.connectionMade.	  s   € Ø�	‰	×Ñ˜4Õ r_   c                ó:   • U R                   R                  S 5        g r~   )rF  rÂ  )r[   Úreasons     r\   r³  Ú"SimpleAgentProtocol.connectionLost1	  s   € Ø�‰×Ñ˜tÕ$r_   c                ó:   • U R                   R                  U5        g r~   )rG  rr   ©r[   rñ  s     r\   ÚdataReceivedÚ SimpleAgentProtocol.dataReceived4	  s   € Ø�‰×Ñ˜TÕ"r_   )rF  rE  rG  N)
r`   ra   rb   rc   ry   ro   rJ  r³  rQ  rd   re   r_   r\   rC  rC  	  s   † ñòò
!ò%õ#r_   rC  c                  ó2   • \ rS rSrS rS rS rS rS rSr	g)	Ú ContentDecoderAgentWithGzipTestsi8	  c                ó¾   • U R                  5       U l        U R                  U R                  5      n[        R                  " US[        R
                  4/5      U l        g)r  ó   gzipN)r
  r)  r+  r0   r"  ÚGzipDecoderr*  r  s     r\   r“   Ú&ContentDecoderAgentWithGzipTests.setUp9	  sJ   € ð ×)Ñ)Ó+ˆŒØ×-Ñ-¨d¯l©lÓ;ˆÜ×/Ò/°¸Ä&×BTÑBTÐ8UÐ7VÓWˆ�
r_   c                ó.  ^ ^^	• T R                   R                  SS5      nT R                  R                  R	                  5       u  p#[
        R                  " S/S/S.5      n[        5       n[        SSSXE5      m	S	T	l	        UR                  T	5        [        R                  " S
[        R                  S[        R                  -   5      nUR                  S5      UR                  S5      -   UR!                  5       -   mUU	U 4S jnUR#                  U5        U$ )z†
If the response has a C{gzip} I{Content-Encoding} header,
L{GzipDecoder} wraps the response to return uncompressed data to the
user.
rà  r‡  r~  rV  r8  r¾  r¿  rÀ  é   rÐ   é   s   xxxxxxs   yyyyc                óî  >• TR                  U T5        TR                  U R                  S5        TR                  U R                  S5        TR                  U R                  S5        TR                  [        U R                  R                  5       5      SS/4/5        TR                  U R                  [        5        TR                  [        [        U S5        TR                  TS S 5        TR                  TSS  5        TR                  5         [        5       nU R!                  U5        TR                  UR"                  S/5        [$        R&                  " UR(                  UR*                  /5      $ )	Nr¾  r¿  rÀ  r0  r~  Úunknownr²   s
   xxxxxxyyyy)r‰  r¬   rß  ÚcodeÚphraserì  rõ  rî  r­   rD   rM  ÚAttributeErrorÚgetattrÚ_bodyDataReceivedÚ_bodyDataFinishedrC  ÚdeliverBodyrG  r   ÚgatherResultsrE  rF  )rt   r  rñ  r  r[   s     €€€r\   ÚcheckResponseÚQContentDecoderAgentWithGzipTests.test_gzipEncodingResponse.<locals>.checkResponseZ	  s,  ø€ Ø×#Ñ# F¨HÔ5Ø×Ñ˜VŸ^™^¨_Ô=Ø×Ñ˜VŸ[™[¨#Ô.Ø×Ñ˜VŸ]™]¨EÔ2Ø×ÑÜ�V—^‘^×4Ñ4Ó6Ó7¸6ÀFÀ8Ð:LÐ9Môð ×Ñ˜VŸ]™]¬NÔ;Ø×Ñœn¬g°v¸yÔIà×&Ñ& t¨B¨Q xÔ0Ø×&Ñ& t¨A¨B xÔ0Ø×&Ñ&Ô(ä*Ó,ˆHØ×Ñ˜xÔ(à×Ñ˜X×.Ñ.Ð1DÐ0EÔFÜ×&Ò&¨¯©°x×7HÑ7HÐ'IÓJÐJr_   )r*  rs   r  rl   rÃ   r2   rC   r&   r7   r­   rÂ  ÚzlibÚcompressobjÚDEFLATEDÚ	MAX_WBITSÚcompressrð  rV  )
r[   rü  rt  ru  rõ  rb  Ú
compressorrf  rñ  r  s
   `       @@r\   Útest_gzipEncodingResponseÚ:ContentDecoderAgentWithGzipTests.test_gzipEncodingResponseA	  sò   ú€ ð —:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ø�X°W°IÑ>ó
ˆô $Ó%ˆ	Ü˜O¨S°%¸ÓLˆØˆŒØ�‰�XÔä×%Ò% a¬¯©¸¼T¿^¹^Ñ8KÓLˆ
à×Ñ Ó)Ø×!Ñ! (Ó+ñ,à×ÑÓ ñ!ð 	÷	Kð* 	×Ñ˜]Ô+àˆr_   c                óÄ  ^ ^^	• T R                   R                  SS5      nT R                  R                  R	                  5       u  p#[
        R                  " S/S/S.5      n[        5       n[        SSSXE5      m	S	T	l	        UR                  T	5        S
mUU	4S jnUR                  U5        T R                  U[        R                  5        U 4S jnUR                  U5      $ )z…
If the data received by the L{GzipDecoder} isn't valid gzip-compressed
data, the call to C{deliverBody} fails with a C{zlib.error}.
rà  r‡  r~  rV  r8  r¾  r¿  rÀ  rZ  s   not gzipped contentc                óZ   >• TR                  T5        U R                  [        5       5        g r~   )rb  rd  r    )rt   rñ  r  s    €€r\   rf  ÚJContentDecoderAgentWithGzipTests.test_brokenContent.<locals>.checkResponse†	  s!   ø€ Ø×&Ñ& tÔ,à×Ñœx›zÕ*r_   c                óž   >• U R                   S   R                  [        R                  5        TR	                  U R
                  [        5        g )Nr   ©ÚreasonsrÞ   rh  r1   rM  r  r7   ©r1   r[   s    €r\   ÚcheckFailureÚIContentDecoderAgentWithGzipTests.test_brokenContent.<locals>.checkFailureŽ	  ó2   ø€ Ø�M‰M˜!Ñ×!Ñ!¤$§*¡*Ô-Ø×!Ñ! %§.¡.´(Õ;r_   )r*  rs   r  rl   rÃ   r2   rC   r&   r7   r­   rÂ  rV  rS  r0   r8   )
r[   rü  rt  ru  rõ  rb  rf  rw  rñ  r  s
   `       @@r\   Útest_brokenContentÚ3ContentDecoderAgentWithGzipTests.test_brokenContents	  sÇ   ú€ ð
 —:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ø�X°W°IÑ>ó
ˆô $Ó%ˆ	Ü˜O¨S°%¸ÓLˆØˆŒØ�‰�XÔà%ˆö	+ð
 	×Ñ˜]Ô+Ø×Ñ˜8¤V×%:Ñ%:Ô;õ	<ð ×#Ñ# LÓ1Ð1r_   c                óÄ  ^ ^	•  " S S5      n[         R                  nU[         l        T R                  [        [         SU5        T R                  R                  SS5      nT R                  R                  R                  5       u  pE[        R                  " SS/05      n[        5       n[        SSS	Xg5      m	UR                  T	5        U	U 4S
 jnUR                  U5        U$ )z¦
When the connection with the server is lost, the gzip protocol calls
C{flush} on the zlib decompressor object to get uncompressed data which
may have been buffered.
c                  ó&   • \ rS rSrS rS rS rSrg)ÚFContentDecoderAgentWithGzipTests.test_flushData.<locals>.decompressobji›	  c                ó   • g r~   re   ©r[   Úwbitss     r\   ro   ÚOContentDecoderAgentWithGzipTests.test_flushData.<locals>.decompressobj.__init__œ	  r¢   r_   c                ó   • g©Nó   xre   rP  s     r\   Ú
decompressÚQContentDecoderAgentWithGzipTests.test_flushData.<locals>.decompressobj.decompressŸ	  ó   € Ør_   c                ó   • g)Nó   yre   rn   s    r\   rð  ÚLContentDecoderAgentWithGzipTests.test_flushData.<locals>.decompressobj.flush¢	  rˆ  r_   re   N©r`   ra   rb   rc   ro   r†  rð  rd   re   r_   r\   Údecompressobjr~  ›	  s   † òòõr_   r�  rà  r‡  r9  rV  r¾  r¿  rÀ  c                ó  >• TR                  S5        TR                  5         [        5       nU R                  U5        TR	                  UR
                  SS/5        [        R                  " UR                  UR                  /5      $ ©Ns   datar…  rŠ  ©
rb  rc  rC  rd  r¬   rG  r   re  rE  rF  ©rt   r  r  r[   s     €€r\   rf  ÚFContentDecoderAgentWithGzipTests.test_flushData.<locals>.checkResponse²	  óm   ø€ Ø×&Ñ& wÔ/Ø×&Ñ&Ô(ä*Ó,ˆHØ×Ñ˜xÔ(à×Ñ˜X×.Ñ.°°t°Ô=Ü×&Ò&¨¯©°x×7HÑ7HÐ'IÓJÐJr_   )rh  r�  Ú
addCleanupÚsetattrr*  rs   r  rl   rÃ   r2   rC   r&   r7   rÂ  rV  )
r[   r�  ÚoldDecompressObjrü  rt  ru  rõ  rb  rf  r  s
   `        @r\   Útest_flushDataÚ/ContentDecoderAgentWithGzipTests.test_flushData”	  s¾   ù€ ÷	ñ 	ô  ×-Ñ-ÐØ*ŒÔØ�‰œ¤ Ð8HÔIà—:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ð(;¸g¸YÐ'GÓHˆÜ#Ó%ˆ	Ü˜O¨S°%¸ÓLˆØ�‰�XÔö	Kð 	×Ñ˜]Ô+àˆr_   c                ó.  ^ ^
•  " S S5      n[         R                  nU[         l        T R                  [        [         SU5        T R                  R                  SS5      nT R                  R                  R                  5       u  pE[        R                  " SS/05      n[        5       n[        SSS	Xg5      m
UR                  T
5        U
U 4S
 jnUR                  U5        T R                  U[         R"                  5        U 4S jn	UR                  U	5      $ )z}
If the C{flush} call in C{connectionLost} fails, the C{zlib.error}
exception is caught and turned into a L{ResponseFailed}.
c                  ó&   • \ rS rSrS rS rS rSrg)ÚGContentDecoderAgentWithGzipTests.test_flushError.<locals>.decompressobjiÆ	  c                ó   • g r~   re   r€  s     r\   ro   ÚPContentDecoderAgentWithGzipTests.test_flushError.<locals>.decompressobj.__init__Ç	  r¢   r_   c                ó   • gr„  re   rP  s     r\   r†  ÚRContentDecoderAgentWithGzipTests.test_flushError.<locals>.decompressobj.decompressÊ	  rˆ  r_   c                ó,   • [         R                  " 5       er~   )rh  r1   rn   s    r\   rð  ÚMContentDecoderAgentWithGzipTests.test_flushError.<locals>.decompressobj.flushÍ	  s   € Ü—j’j“lÐ"r_   re   NrŒ  re   r_   r\   r�  r›  Æ	  s   † òòõ#r_   r�  rà  r‡  r9  rV  r¾  r¿  rÀ  c                ó  >• TR                  S5        TR                  5         [        5       nU R                  U5        TR	                  UR
                  SS/5        [        R                  " UR                  UR                  /5      $ r�  r�  r‘  s     €€r\   rf  ÚGContentDecoderAgentWithGzipTests.test_flushError.<locals>.checkResponseÝ	  r“  r_   c                óž   >• U R                   S   R                  [        R                  5        TR	                  U R
                  [        5        g )NrÀ   rt  rv  s    €r\   rw  ÚFContentDecoderAgentWithGzipTests.test_flushError.<locals>.checkFailureë	  ry  r_   )rh  r�  r”  r•  r*  rs   r  rl   rÃ   r2   rC   r&   r7   rÂ  rV  rS  r0   r8   )r[   r�  r–  rü  rt  ru  rõ  rb  rf  rw  r  s   `         @r\   Útest_flushErrorÚ0ContentDecoderAgentWithGzipTests.test_flushErrorÀ	  sç   ù€ ÷	#ñ 	#ô  ×-Ñ-ÐØ*ŒÔØ�‰œ¤ Ð8HÔIà—:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ð(;¸g¸YÐ'GÓHˆÜ#Ó%ˆ	Ü˜O¨S°%¸ÓLˆØ�‰�XÔö	Kð 	×Ñ˜]Ô+à×Ñ˜8¤V×%:Ñ%:Ô;õ	<ð ×#Ñ# LÓ1Ð1r_   rÜ  N)
r`   ra   rb   rc   r“   rn  rz  r—  r¦  rd   re   r_   r\   rT  rT  8	  s   † òXò0òd2òB*õX/2r_   rT  c                  ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚProxyAgentTestsiò	  z!
Tests for L{client.ProxyAgent}.
c                ón   • [         R                  " [        U R                  SS5      U R                  5      $ )z1
@return: a new L{twisted.web.client.ProxyAgent}
z	127.0.0.1r\  )r0   Ú
ProxyAgentr   r)  rn   s    r\   rÅ  ÚProxyAgentTests.makeAgent÷	  s-   € ô × Ò Ü˜tŸ|™|¨[¸$Ó?ÀÇÁó
ð 	
r_   c                ó  • U R                  5       U l        [        R                  " [	        U R                  SS5      U R                  5      U l        U R
                  R                  nU R                  X5      U R
                  l        g )NrÚ  é.  )r
  r)  r0   r«  r   r*  Ú_proxyEndpointr!  )r[   ÚoldEndpoints     r\   r“   ÚProxyAgentTests.setUpÿ	  sb   € Ø×)Ñ)Ó+ˆŒÜ×&Ò&Ü˜tŸ|™|¨U°DÓ9¸4¿<¹<ó
ˆŒ
ð —j‘j×/Ñ/ˆØ$(×$5Ñ$5°kÓ$Hˆ�
‰
Õ!r_   c                ó\   • U R                  [        U R                  R                  SS5        g)zW
L{ProxyAgent.request} raises L{TypeError} when the C{method} argument
isn't L{bytes}.
rJ  rK  NrL  rn   s    r\   rO  Ú#ProxyAgentTests.test_nonBytesMethod
  rQ  r_   c                óL  • [         R                  " SS/05      n[        5       nU R                  R	                  SSX5        U R
                  R                  R                  5       SS u  p4nU R                  US5        U R                  US5        U R                  UR                  [        R                  5        U R                  nU R                  [        UR                  5      S	5        UR                  R                  5       u  pxU R                  U[         5        U R                  UR"                  S5        U R                  UR$                  S5        U R                  UR&                  [         R                  " S/S
/S.5      5        U R)                  UR*                  U5        g)zv
L{client.ProxyAgent} issues an HTTP request against the proxy, with the
full URI as path, when C{request} is called.
r4  r~  rà  rž  Nr¿   rÚ  r®  rÀ   rŸ  r  )r2   rC   rF  r*  rs   r)  r  rÃ   r¬   rM  Ú_wrappedFactoryr0   rA   r  r³   rl   r?   r   r  rõ  rƒ  rD  )	r[   rõ  r¡  rv  rw  r  r  rt  ru  s	            r\   Útest_proxyRequestÚ!ProxyAgentTests.test_proxyRequest
  sV  € ô
 ×&Ò&¨°°Ð'9Ó:ˆô ‹xˆØ�
‰
×Ñ˜6Ð#EÀwÔUà"Ÿl™l×5Ñ5×9Ñ9Ó;¸B¸QÐ?Ñˆ�GØ×Ñ˜˜uÔ%Ø×Ñ˜˜tÔ$à×Ñ˜g×5Ñ5´v×7RÑ7RÔSà—=‘=ˆð 	×Ñœ˜X×.Ñ.Ó/°Ô3Ø×$Ñ$×(Ñ(Ó*‰ˆØ×Ñ˜c¤7Ô+Ø×Ñ˜Ÿ™ VÔ,Ø×Ñ˜Ÿ™Ð"DÔEØ×ÑØ�K‰KÜ× Ò ¨6¨(Ð>QÐ=RÑ!SÓTô	
ð 	×Ñ˜S×-Ñ-¨tÕ4r_   c                ód   • U R                  U R                  R                  R                  S5        g)z:
C{ProxyAgent} connections are not persistent by default.
FN)r¬   r*  r  r}  rn   s    r\   r-  Ú"ProxyAgentTests.test_nonPersistent-
  s$   € ð 	×Ñ˜Ÿ™×)Ñ)×4Ñ4°eÕ<r_   c                ó,  ^ ^• [        5       m " UU 4S jS5      nU" 5       n[        R                  " TT R                  US9nT R	                  X#R
                  5        UR                  SS5        T R                  UR
                  R                  S5        g)zº
When a connection is made by the C{ProxyAgent}, it uses its pool's
C{getConnection} method to do so, with the endpoint it was constructed
with and a key of C{("http-proxy", endpoint)}.
c                  ó,   >• \ rS rSrSrSrU U4S jrSrg)ÚAProxyAgentTests.test_connectUsesConnectionPool.<locals>.DummyPooli;
  Fc                óš   >• SU l         TR                  UT5        TR                  UST45        [        R                  " [        5       5      $ )NTz
http-proxy)r<  rƒ  r¬   r   r   rg   r=  s      €€r\   rU  ÚOProxyAgentTests.test_connectUsesConnectionPool.<locals>.DummyPool.getConnection?
  sD   ø€ Ø!%�”Ø×$Ñ$ R¨Ô2ð × Ñ   |°XÐ&>Ô?Ü—}’}Ô%5Ó%7Ó8Ð8r_   re   Nr@  r7  s   €€r\   rA  r¼  ;
  s   ø† ØˆIØˆJ÷9ñ 9r_   rA  r  rà  rC  TN)	r2  r0   r«  r)  rƒ  r  rs   r¬   r<  )r[   rA  rG  r*  r  s   `   @r\   rG  Ú.ProxyAgentTests.test_connectUsesConnectionPool3
  sq   ù€ ô !“?ˆ÷	9õ 	9ñ ‹{ˆÜ×!Ò! (¨D¯L©L¸tÑDˆØ×Ñ˜T§;¡;Ô/à�‰�f˜nÔ-Ø×Ñ˜Ÿ™×.Ñ.°Õ5r_   rÜ  N)r`   ra   rb   rc   ry   rÅ  r“   rO  r¶  r-  rG  rd   re   r_   r\   r©  r©  ò	  s'   † ñò
òIòXò5ò>=õ6r_   r©  )ó   authorizationrý  ó   cookie2ó   proxy-authorizations   www-authenticatec                  ó  • \ rS rSr% SrS\S'   S\S'   S\S'   S	 r    S!           S"S jjrS rS r	S r
S rS r S#     S$S jjrS%S jrS%S jrS%S jrS rS rS rS rS rS rS rS rS rS rS rS rg
)&Ú_RedirectAgentTestsMixiniY
  zR
Test cases mixin for L{RedirectAgentTests} and
L{BrowserLikeRedirectAgentTests}.
rE   r*  r%   r)  rg   r  c                óÌ  • U R                   R                  SS5      nU R                  R                  R	                  5       u  p#[
        R                  " 5       n[        SSSUS5      nUR                  U5        U R                  S[        U R                  R                  5      5        U R                  U5      nU R                  XV5        U R                  UR                  S5        g)zb
L{client.RedirectAgent} behaves like L{client.Agent} if the response
doesn't contain a redirect.
rà  r‡  r¾  r¿  rÀ  Nr   )r*  rs   r  rl   rÃ   r2   rC   r7   rÂ  r¬   r³   rÅ   rƒ  ÚpreviousResponse)r[   rü  rt  ru  rõ  r  rt   s          r\   Útest_noRedirectÚ(_RedirectAgentTestsMixin.test_noRedirectc
  s´   € ð
 —:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ó(ˆÜ˜O¨S°%¸À$ÓGˆØ�‰�XÔà×Ñ˜œC §¡× 6Ñ 6Ó7Ô8Ø×%Ñ% hÓ/ˆØ×Ñ˜XÔ.Ø×Ñ˜V×4Ñ4°dÕ;r_   Nc                ó  • Sn[         b  SOSnUS:X  a  SOSnU R                  R                  SUS-   U-   S	-   US
9  U R                  R                  R                  5       SS u  pšU R                  [        U	5        U R                  XŠ5        U R                  R                  R                  5       u  p¼UnUnUnU(       a&  [         c  [        S5      eUS:X  a  SOSnUS:X  a  SOSnSnU(       a  SnSnU(       a  SOUnUS-   U-   U-   S-   n[        R                  " SU/05      n[        SUSUS5      nUR                  U5        U R                  R                  R                  5       u  nnU R                  SUR                  5        U R                  SUR                   5        U R                  R                  R                  5       SS u  pšU R                  U(       a  ["        O[        U	5        U R                  Xú5        U$ )z¤
When getting a redirect, L{client.RedirectAgent} follows the URL
specified in the L{Location} header field and make a new request.

@param code: HTTP status code.
r^  Nr•  rÚ  r_  r{  rà  rá  s   /foor/  rÐ   z;Cross-scheme redirects can't be tested without TLS support.r_   iû   s   :8443ó   example.netó   /baró   locationr¾  rÀ  )rL   r*  rs   r)  r  rÃ   r¬   r   r  rl   r   r2   rC   r7   rÂ  r   r  r  )r[   r^  ÚcrossSchemeÚcrossDomainÚ	crossPortÚrequestHeadersÚstartDomainÚstartSchemeÚ	startPortrv  rw  rt  ru  ÚtargetSchemeÚtargetDomainÚ
targetPortÚ
portSyntaxÚlocationValuerõ  r  Úreq2Úres2s                         r\   Ú_testRedirectDefaultÚ-_RedirectAgentTestsMixin._testRedirectDefaultu
  så  € ð %ˆÜ"%¡/‘h°wˆØ%¨Ó0‘B°cˆ	Ø�
‰
×ÑØ�K &Ñ(¨;Ñ6¸Ñ@È.ð 	ñ 	
ð —\‘\×,Ñ,×0Ñ0Ó2°2°AÐ6‰
ˆØ×Ñœ¨Ô.Ø×Ñ˜Ô)à—=‘=×)Ñ)×-Ñ-Ó/‰ˆð #ˆØ"ˆØˆ
æÜ‰{ÜØQóð ð (3°gÓ'=™8À7ˆLØ )¨R£™°RˆJàˆ
ÞØˆJØ!ˆJÞ)4‘~¸+ˆØ$ vÑ-°Ñ<¸zÑIÈGÑSˆÜ×&Ò&¨°m°_Ð'EÓFˆÜ˜O¨T°5¸'À4ÓHˆØ�‰�XÔà—]‘]×+Ñ+×/Ñ/Ó1‰
ˆˆdØ×Ñ˜ §¡Ô-Ø×Ñ˜ $§(¡(Ô+à—\‘\×,Ñ,×0Ñ0Ó2°2°AÐ6‰
ˆØ×Ñ®;�¼NÈDÔQØ×Ñ˜Ô*Øˆr_   c                ó&   • U R                  S5        g)z?
L{client.RedirectAgent} follows redirects on status code 301.
é-  N©rÛ  rn   s    r\   Útest_redirect301Ú)_RedirectAgentTestsMixin.test_redirect301³
  ó   € ð 	×!Ñ! #Õ&r_   c                ó$   • U R                  SSS9  g)z9
L{client.RedirectAgent} follows cross-scheme redirects.
rÞ  T©rÍ  Nrß  rn   s    r\   Útest_redirect301SchemeÚ/_RedirectAgentTestsMixin.test_redirect301Scheme¹
  s   € ð 	×!Ñ!ØØð 	"ò 	
r_   c                ó&   • U R                  S5        g)z?
L{client.RedirectAgent} follows redirects on status code 302.
é.  Nrß  rn   s    r\   Útest_redirect302Ú)_RedirectAgentTestsMixin.test_redirect302Â
  râ  r_   c                ó&   • U R                  S5        g)z?
L{client.RedirectAgent} follows redirects on status code 307.
é3  Nrß  rn   s    r\   Útest_redirect307Ú)_RedirectAgentTestsMixin.test_redirect307È
  râ  r_   c                ó&   • U R                  S5        g)z?
L{client.RedirectAgent} follows redirects on status code 308.
i4  Nrß  rn   s    r\   Útest_redirect308Ú)_RedirectAgentTestsMixin.test_redirect308Î
  râ  r_   c           	     óŠ  • S/S/S/S/S/S/S.nSS	/0n[        0 UEUE5      nU R                  S
US9nSS jnU" UR                  5      nU R                  USS/0U" U5      E5        U R                  "  S0 UDS[        0 UEUE5      0D6n	U" U	R                  5      n
U R                  U
SU/0U" [        U5      5      E5        g)z^
L{client.RedirectAgent} scrubs sensitive headers when redirecting
between differing origins.
s   sensitive-authnzs   sensitive-cookie-datas   sensitive-cookie2-datas   sensitive-proxy-auths   sensitive-authns   sensitive-custom)rÀ  rý  rÁ  rÂ  s   wWw-auThentiCates   x-custom-sensitives   x-random-headers   x-random-valuerÞ  )rÐ  c                óv   • U R                  5        VVs0 s H  u  pUR                  5       U_M     snn$ s  snnf r~   )rî  Úlower)rõ  r½  Úvs      r\   ÚnormHeadersÚC_RedirectAgentTestsMixin._sensitiveHeadersTest.<locals>.normHeadersç
  s1   € Ø/6×/GÑ/GÔ/IÔJÒ/I¡V a�A—G‘G“I˜q’LÑ/IÒJÐJùÓJs   ”5rB  r^  rÐ  N)rõ  rC   rw   zDict[bytes, Sequence[bytes]])rÞ  )rC   rÛ  rõ  r˜  )r[   ÚexpectedHostHeaderÚcrossKwargsÚsensitiveHeaderValuesÚotherHeaderValuesÚ
allHeadersÚ
redirectedrö  ÚsameOriginHeadersÚredirectedElsewhereÚotherOriginHeaderss              r\   Ú_sensitiveHeadersTestÚ._RedirectAgentTestsMixin._sensitiveHeadersTestÔ
  s1  € ð  3Ð3Ø0Ð1Ø2Ð3Ø%<Ð$=Ø"4Ð!5Ø$7Ð#8ñ!
Ðð 0Ð2CÐ1DÐEÐÜÐKÐ 5ÐKÐ9JÐKÓLˆ
Ø×.Ñ.¨sÀ:Ð.ÐNˆ
ô	Kñ (¨
×(:Ñ(:Ó;ÐØ×ÑØà˜.Ð)ðá˜jÓ)ðô	
ð #×7Ò7Øñ
àñ
ô #Ð#QÐ&;Ð#QÐ?PÐ#QÓRò
Ðñ
 )Ð)<×)DÑ)DÓEÐØ×ÑØàÐ,Ð-ðáœgÐ&7Ó8Ó9ðõ	
r_   c                ó$   • U R                  SSS9  g)z^
L{client.RedirectAgent} scrubs sensitive headers when redirecting
between differing domains.
TrÊ  )rÎ  rø  N©r  rn   s    r\   Útest_crossDomainHeadersÚ0_RedirectAgentTestsMixin.test_crossDomainHeaders  s   € ð
 	×"Ñ"¨tÈÐ"ÒWr_   c                ó$   • U R                  SSS9  g)z\
L{client.RedirectAgent} scrubs sensitive headers when redirecting
between differing ports.
Ts   example.com:8443)rÏ  rø  Nr  rn   s    r\   Útest_crossPortHeadersÚ._RedirectAgentTestsMixin.test_crossPortHeaders  s   € ð
 	×"Ñ"ØÐ/Bð 	#ò 	
r_   c                ó"   • U R                  SS9  g)z^
L{client.RedirectAgent} scrubs sensitive headers when redirecting
between differing schemes.
Trä  Nr  rn   s    r\   Útest_crossSchemeHeadersÚ0_RedirectAgentTestsMixin.test_crossSchemeHeaders  s   € ð
 	×"Ñ"¨tÐ"Ò4r_   c                ó¶  • U R                   R                  US5        U R                  R                  R	                  5       u  p4[
        R                  " SS/05      n[        SUSUS5      nUR                  U5        U R                  R                  R	                  5       u  pxU R                  SUR                  5        U R                  SUR                  5        g)	z¬
L{client.RedirectAgent} changes the method to I{GET} when getting
a redirect on a non-I{GET} request.

@param code: HTTP status code.

@param method: HTTP request method.
r‡  rÌ  ó   http://example.com/barr¾  rÀ  Nrà  rË  )r*  rs   r  rl   rÃ   r2   rC   r7   rÂ  r¬   r   r  )	r[   r^  r   rt  ru  rõ  r  rÙ  rÚ  s	            r\   Ú_testRedirectToGetÚ+_RedirectAgentTestsMixin._testRedirectToGet  s¬   € ð 	�
‰
×Ñ˜6Ð#<Ô=à—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&¨Ð6OÐ5PÐ'QÓRˆÜ˜O¨T°5¸'À4ÓHˆØ�‰�XÔà—]‘]×+Ñ+×/Ñ/Ó1‰
ˆØ×Ñ˜ §¡Ô-Ø×Ñ˜ $§(¡(Õ+r_   c                ó(   • U R                  SS5        g)zh
L{client.RedirectAgent} changes the method to I{GET} when getting a 303
redirect on a I{POST} request.
i/  r}  N©r  rn   s    r\   Útest_redirect303Ú)_RedirectAgentTestsMixin.test_redirect303-  ó   € ð
 	×Ñ  WÕ-r_   c                óx  • U R                   R                  SS5      nU R                  R                  R	                  5       u  p#[
        R                  " 5       n[        SSSUS5      nUR                  U5        U R                  U[        R                  5      nUR                  R                  S   R                  [        R                   5        U R#                  SUR                  R                  S   R                  R$                  5        U R#                  SUR                  R&                  R(                  5        g)zµ
If no L{Location} header field is found when getting a redirect,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping a
L{error.RedirectWithNoLocation} exception.
rà  r‡  r¾  rÞ  rÀ  Nr   )r*  rs   r  rl   rÃ   r2   rC   r7   rÂ  rÝ   r0   r8   r™  ru  rÞ   r1   ÚRedirectWithNoLocationr¬   r  r  r^  )r[   rü  rt  ru  rõ  r  Úfails          r\   Útest_noLocationFieldÚ-_RedirectAgentTestsMixin.test_noLocationField4  sè   € ð —:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ó(ˆÜ˜O¨S°%¸À$ÓGˆØ�‰�XÔà×#Ñ# H¬f×.CÑ.CÓDˆØ�
‰
×Ñ˜1Ñ×"Ñ"¤5×#?Ñ#?Ô@Ø×ÑÐ2°D·J±J×4FÑ4FÀqÑ4I×4OÑ4O×4SÑ4SÔTØ×Ñ˜˜dŸj™j×1Ñ1×6Ñ6Õ7r_   c                óv  • U R                   R                  US5      nU R                  R                  R	                  5       u  pE[
        R                  " 5       n[        SUSUS5      nUR                  U5        U R                  U[        R                  5      nUR                  R                  S   R                  [        R                   5        U R#                  SUR                  R                  S   R                  R$                  5        U R#                  XR                  R&                  R(                  5        g)zé
When getting a redirect on an unsupported request method,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping
a L{error.PageRedirect} exception.

@param code: HTTP status code.

@param method: HTTP request method.
r‡  r¾  rÀ  Nr   )r*  rs   r  rl   rÃ   r2   rC   r7   rÂ  rÝ   r0   r8   r™  ru  rÞ   r1   ÚPageRedirectr¬   Úlocationr  r^  )	r[   r^  r   rü  rt  ru  rõ  r  r  s	            r\   Ú_testPageRedirectFailureÚ1_RedirectAgentTestsMixin._testPageRedirectFailureG  sê   € ð —:‘:×%Ñ% fÐ.GÓHˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&Ó(ˆÜ˜O¨T°5¸'À4ÓHˆØ�‰�XÔà×#Ñ# H¬f×.CÑ.CÓDˆØ�
‰
×Ñ˜1Ñ×"Ñ"¤5×#5Ñ#5Ô6Ø×ÑØ% t§z¡z×'9Ñ'9¸!Ñ'<×'BÑ'B×'KÑ'Kô	
ð 	×Ñ˜Ÿz™z×2Ñ2×7Ñ7Õ8r_   c                ó(   • U R                  SS5        g)zœ
When getting a 307 redirect on a I{POST} request,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping
a L{error.PageRedirect} exception.
rì  r}  N©r  rn   s    r\   Útest_307OnPostÚ'_RedirectAgentTestsMixin.test_307OnPost`  ó   € ð 	×%Ñ% c¨7Õ3r_   c                ó\  • U R                  U R                  5      n[        R                  " US5      nUR	                  SS5      nU R
                  R                  R                  5       u  pE[        R                  " SS/05      n[        SSSUS	5      nUR                  U5        U R
                  R                  R                  5       u  p‰[        SSSUS	5      n
U	R                  U
5        U R                  U[        R                  5      nUR                  R                  S
   R!                  ["        R$                  5        U R'                  SUR                  R                  S
   R                  R(                  5        U R'                  SUR                  R*                  R,                  5        g	)z©
If the limit of redirects specified to L{client.RedirectAgent} is
reached, the deferred fires with L{ResponseFailed} error wrapping
a L{InfiniteRedirection} exception.
rÀ   rà  r‡  rÌ  r  r¾  rè  rÀ  Nr   )r+  r)  r0   ÚRedirectAgentrs   r  rl   rÃ   r2   rC   r7   rÂ  rÝ   r8   r™  ru  rÞ   r1   ÚInfiniteRedirectionr¬   r  r  r^  )r[   r*  ÚredirectAgentrü  rt  ru  rõ  r  rÙ  rÚ  Ú	response2r  s               r\   Útest_redirectLimitÚ+_RedirectAgentTestsMixin.test_redirectLimith  sQ  € ð ×-Ñ-¨d¯l©lÓ;ˆÜ×,Ò,¨U°AÓ6ˆà ×(Ñ(¨Ð1JÓKˆà—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&¨Ð6OÐ5PÐ'QÓRˆÜ˜O¨S°%¸À$ÓGˆØ�‰�XÔà—]‘]×+Ñ+×/Ñ/Ó1‰
ˆä˜_¨c°5¸'À4ÓHˆ	Ø�‰�iÔ à×#Ñ# H¬f×.CÑ.CÓDˆà�
‰
×Ñ˜1Ñ×"Ñ"¤5×#<Ñ#<Ô=Ø×ÑØ% t§z¡z×'9Ñ'9¸!Ñ'<×'BÑ'B×'KÑ'Kô	
ð 	×Ñ˜˜dŸj™j×1Ñ1×6Ñ6Õ7r_   c                ó´  • U R                   R                  SU5        U R                  R                  R	                  5       u  pE[
        R                  " SU/05      n[        SSSUS5      nUR                  U5        U R                  R                  R	                  5       u  p‰U R                  SUR                  5        U R                  X8R                  5        g)a  
When L{client.RedirectAgent} encounters a relative redirect I{URI}, it
is resolved against the request I{URI} before following the redirect.

@param uri: Request URI.

@param location: I{Location} header redirect URI.

@param finalURI: Expected final URI.
rà  rÌ  r¾  rè  rÀ  N)r*  rs   r  rl   rÃ   r2   rC   r7   rÂ  r¬   r   rÃ  )
r[   r  r  ÚfinalURIrt  ru  rõ  r  rÙ  rÚ  s
             r\   Ú_testRedirectURIÚ)_RedirectAgentTestsMixin._testRedirectURI†  s©   € ð 	�
‰
×Ñ˜6 3Ô'à—=‘=×)Ñ)×-Ñ-Ó/‰ˆä×&Ò&¨°h°ZÐ'@ÓAˆÜ˜O¨S°%¸À$ÓGˆØ�‰�XÔà—]‘]×+Ñ+×/Ñ/Ó1‰
ˆØ×Ñ˜ §¡Ô-Ø×Ñ˜×#3Ñ#3Õ4r_   c                óv   • U R                  SSS5        U R                  SSS5        U R                  SSS5        g)	zg
L{client.RedirectAgent} resolves and follows relative I{URI}s in
redirects, preserving query strings.
ó   http://example.com/foo/bars   bazs   http://example.com/foo/bazs   /bazs   http://example.com/bazó   /baz?as   http://example.com/baz?aN©r.  rn   s    r\   Útest_relativeURIÚ)_RedirectAgentTestsMixin.test_relativeURI�  sJ   € ð
 	×ÑØ)¨6Ð3Pô	
ð 	×ÑØ)¨7Ð4Mô	
ð 	×ÑØ)¨9Ð6Qõ	
r_   c                óP   • U R                  SSS5        U R                  SSS5        g)zë
L{client.RedirectAgent} resolves and follows relative I{URI}s in
redirects, preserving fragments in way that complies with the HTTP 1.1
bis draft.

@see: U{https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.2}
s   http://example.com/foo/bar#fragr2  s   http://example.com/baz?a#fragr1  s   /baz?a#frag2s   http://example.com/baz?a#frag2Nr3  rn   s    r\   Ú!test_relativeURIPreserveFragmentsÚ:_RedirectAgentTestsMixin.test_relativeURIPreserveFragments¬  s4   € ð 	×ÑØ.ØØ,ô	
ð
 	×ÑØ)ØØ-õ	
r_   c                óP   • U R                  SSS5        U R                  SSS5        g)zƒ
L{client.RedirectAgent} resolves and follows scheme relative I{URI}s in
redirects, replacing the hostname and port when required.
r1  s   //foo.com/bazs   http://foo.com/bazs   //foo.com:81/bazs   http://foo.com:81/bazNr3  rn   s    r\   Útest_relativeURISchemeRelativeÚ7_RedirectAgentTestsMixin.test_relativeURISchemeRelative¿  s4   € ð
 	×ÑØ)Ð+;Ð=Rô	
ð 	×ÑØ)Ð+>Ð@Xõ	
r_   c                óf  • U R                  U R                  5      n[        R                  " U5      nUR	                  SS5      nU R
                  R                  R                  5       u  pE[        R                  " SS/05      n[        SSSUS5      nUR                  U5        U R
                  R                  R                  5       u  p‰[        SS	SUS5      n
U	R                  U
5        U R                  U5      nU R                  UR                  U5        U R                  UR                  S5        g)
zy
L{Response.response} references the previous L{Response} from
a redirect, or L{None} if there was no previous response.
rà  r‡  rÌ  r  r¾  rè  rÀ  Nr¿  )r+  r)  r0   r&  rs   r  rl   rÃ   r2   rC   r7   rÂ  rÅ   rƒ  rÆ  )r[   r*  r(  rü  ÚredirectReqÚredirectResrõ  ÚredirectResponsert  ru  r  ÚfinalResponses               r\   Útest_responseHistoryÚ-_RedirectAgentTestsMixin.test_responseHistoryË  s  € ð
 ×-Ñ-¨d¯l©lÓ;ˆÜ×,Ò,¨UÓ3ˆà ×(Ñ(¨Ð1JÓKˆà#'§=¡=×#9Ñ#9×#=Ñ#=Ó#?Ñ ˆä×&Ò&¨Ð6OÐ5PÐ'QÓRˆÜ# O°S¸%ÀÈ$ÓOÐØ×ÑÐ-Ô.à—=‘=×)Ñ)×-Ñ-Ó/‰ˆä˜O¨S°%¸À$ÓGˆØ�‰�XÔà×,Ñ,¨XÓ6ˆØ×Ñ˜]×;Ñ;Ð=MÔNØ×ÑÐ-×>Ñ>ÀÕEr_   re   )FFFN)r^  ÚintrÍ  ÚboolrÎ  rD  rÏ  rD  rÐ  zOptional[Headers]rw   r?   )r^  )rø  r„   rù  rD  rw   rx   rv   )r`   ra   rb   rc   ry   Ú__annotations__rÇ  rÛ  rà  rå  ré  rí  rð  r  r  r  r  r  r  r  r  r"  r*  r.  r4  r7  r:  rA  rd   re   r_   r\   rÄ  rÄ  Y
  sñ   ‡ ñð
 ƒMØÓØÓò<ð* "Ø!ØØ,0ð<àð<ð ð<ð ð	<ð
 ð<ð *ð<ð 
õ<ò|'ò
ò'ò'ò'ð +9ð+
Ø"'ð+
ØIMð+
à	õ+
ôZXô
ô5ò,ò*.ò8ò&9ò24ò8ò<5ò.
ò
ò&

õFr_   rÄ  c                  ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚRedirectAgentTestsiå  z$
Tests for L{client.RedirectAgent}.
c                ó`   • [         R                  " U R                  U R                  5      S/S9$ )z4
@return: a new L{twisted.web.client.RedirectAgent}
s   X-Custom-sensitive©ÚsensitiveHeaderNames)r0   r&  r+  r)  rn   s    r\   rÅ  ÚRedirectAgentTests.makeAgentï  s/   € ô ×#Ò#Ø×)Ñ)¨$¯,©,Ó7Ø"7Ð!8ñ
ð 	
r_   c                óX   • U R                  5       U l        U R                  5       U l        g r~   r  rn   s    r\   r“   ÚRedirectAgentTests.setUpø  ó    € Ø×)Ñ)Ó+ˆŒØ—^‘^Ó%ˆ�
r_   c                ó(   • U R                  SS5        g)zœ
When getting a 301 redirect on a I{POST} request,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping
a L{error.PageRedirect} exception.
rÞ  r}  Nr!  rn   s    r\   Útest_301OnPostÚ!RedirectAgentTests.test_301OnPostü  r$  r_   c                ó(   • U R                  SS5        g)zœ
When getting a 302 redirect on a I{POST} request,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping
a L{error.PageRedirect} exception.
rè  r}  Nr!  rn   s    r\   Útest_302OnPostÚ!RedirectAgentTests.test_302OnPost  r$  r_   rÜ  N)
r`   ra   rb   rc   ry   rÅ  r“   rP  rS  rd   re   r_   r\   rG  rG  å  s   † ñò
ò&ò4õ4r_   rG  c                  ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚBrowserLikeRedirectAgentTestsi  z/
Tests for L{client.BrowserLikeRedirectAgent}.
c                ó`   • [         R                  " U R                  U R                  5      S/S9$ )z?
@return: a new L{twisted.web.client.BrowserLikeRedirectAgent}
s   x-Custom-sensitiverI  )r0   ÚBrowserLikeRedirectAgentr+  r)  rn   s    r\   rÅ  Ú'BrowserLikeRedirectAgentTests.makeAgent  s/   € ô ×.Ò.Ø×)Ñ)¨$¯,©,Ó7Ø"7Ð!8ñ
ð 	
r_   c                óX   • U R                  5       U l        U R                  5       U l        g r~   r  rn   s    r\   r“   Ú#BrowserLikeRedirectAgentTests.setUp   rN  r_   c                ó(   • U R                  SS5        g)ús
L{client.BrowserLikeRedirectAgent} changes the method to I{GET} when
getting a 302 redirect on a I{POST} request.
rÞ  r}  Nr  rn   s    r\   Útest_redirectToGet301Ú3BrowserLikeRedirectAgentTests.test_redirectToGet301$  r  r_   c                ó(   • U R                  SS5        g)r]  rè  r}  Nr  rn   s    r\   Útest_redirectToGet302Ú3BrowserLikeRedirectAgentTests.test_redirectToGet302+  r  r_   rÜ  N)
r`   ra   rb   rc   ry   rÅ  r“   r^  ra  rd   re   r_   r\   rV  rV    s   † ñò
ò&ò.õ.r_   rV  c                  ó"   • \ rS rSrSrSrS rSrg)ÚAbortableStringTransporti3  zC
A version of L{StringTransport} that supports C{abortConnection}.
Fc                ó2   • SU l         U R                  5         g)zŸ
A testable version of the C{ITCPTransport.abortConnection} method.

Since this is a special case of closing the connection,
C{loseConnection} is also called.
TN)ÚabortingÚloseConnectionrn   s    r\   ÚabortConnectionÚ(AbortableStringTransport.abortConnection;  s   € ð ˆŒØ×ÑÕr_   )rf  N)r`   ra   rb   rc   ry   rf  rh  rd   re   r_   r\   rd  rd  3  s   † ñð
 €Hõr_   rd  c                  ó4   • \ rS rSrSrSrSrS\4S jrS r	Sr
g)	ÚDummyResponseiF  al  
Fake L{IResponse} for testing readBody that captures the protocol passed to
deliverBody and uses it to make a connection with a transport.

@ivar protocol: After C{deliverBody} is called, the protocol it was called
    with.

@ivar transport: An instance created by calling C{transportFactory} which
    is used by L{DummyResponse.protocol} to make a connection.
r¿  rÀ  Nc                óB   • Uc
  [        5       nXl        U" 5       U l        g)zÌ
@param headers: The headers for this response.  If L{None}, an empty
    L{Headers} instance will be used.
@type headers: L{Headers}

@param transportFactory: A callable used to construct the transport.
N)rC   rõ  rb  )r[   rõ  ÚtransportFactorys      r\   ro   ÚDummyResponse.__init__U  s   € ð ‰?Ü“iˆGØŒÙ)Ó+ˆ�r_   c                óZ   • Xl         U R                   R                  U R                  5        g)z\
Record the given protocol and use it to make a connection with
L{DummyResponse.transport}.
N©r  r.  rb  rf  s     r\   rd  ÚDummyResponse.deliverBodyb  s   € ð
 !ŒØ�‰×$Ñ$ T§^¡^Õ4r_   )rõ  r  rb  )r`   ra   rb   rc   ry   r^  r_  rd  ro   rd  rd   re   r_   r\   rk  rk  F  s#   † ñ	ð €DØ€Fà#Ð6Nô ,õ5r_   rk  c                  ó   • \ rS rSrSrS rSrg)ÚAlreadyCompletedDummyResponseik  z=
A dummy response that has already had its transport closed.
c                ó|   • Xl         U R                   R                  U R                  5        SU R                   l        g)z1
Make the connection, then remove the transport.
Nrp  rf  s     r\   rd  Ú)AlreadyCompletedDummyResponse.deliverBodyp  s+   € ð !ŒØ�‰×$Ñ$ T§^¡^Ô4Ø"&ˆ�‰Õr_   r  N)r`   ra   rb   rc   ry   rd  rd   re   r_   r\   rs  rs  k  s   † ñõ'r_   rs  c                  ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚReadBodyTestsiy  z
Tests for L{client.readBody}
c                óJ  • [        5       n[        R                  " U5      nUR                  R	                  S5        UR                  R	                  S5        UR                  R                  [        [        5       5      5        U R                  U R                  U5      S5        g)zx
L{client.readBody} returns a L{Deferred} which fires with the complete
body of the L{IResponse} provider passed to it.
ó   firstó   secondó   firstsecondN)
rk  r0   ÚreadBodyr  rQ  r³  r*   r@   r¬   rÅ   )r[   r  rX  s      r\   Útest_successÚReadBodyTests.test_success~  sw   € ô
 !“?ˆÜ�OŠO˜HÓ%ˆØ×Ñ×&Ñ& xÔ0Ø×Ñ×&Ñ& yÔ1Ø×Ñ×(Ñ(¬´³Ó)@ÔAØ×Ñ˜×-Ñ-¨aÓ0°.ÕAr_   c                óî   • [        5       n[        R                  " U5      nUR                  5         U R	                  U[
        R                  5        U R                  UR                  R                  5        g)zo
When cancelling the L{Deferred} returned by L{client.readBody}, the
connection to the server will be aborted.
N)
rk  r0   r|  rã   rÝ   r   r   r–   rb  rf  )r[   r  rü  s      r\   Útest_cancelÚReadBodyTests.test_cancelŠ  sQ   € ô
 !“?ˆÜ—?’? 8Ó,ˆØ�‰ÔØ×Ñ˜X¤u×';Ñ';Ô<Ø�‰˜×*Ñ*×3Ñ3Õ4r_   c                ó  • [        5       n[        R                  " U5      nUR                  R	                  S5        UR                  R	                  S5        UR                  R                  [        [        5       5      5        U R                  U5      nUR                  [        R                  5        U R                  UR                  R                  UR                  R                  UR                  R                  S.SSSS.5        g)zò
If the full body of the L{IResponse} passed to L{client.readBody} is
not definitely received, the L{Deferred} returned by L{client.readBody}
fires with a L{Failure} wrapping L{client.PartialDownloadError} with
the content that was received.
ry  rz  )Ústatusr0  r¡  s   200rÀ  r{  N)rk  r0   r|  r  rQ  r³  r*   r4   rÝ   rÞ   ÚPartialDownloadErrorr¬   r™  rƒ  r0  r  )r[   r  rX  Úfailures       r\   Útest_withPotentialDataLossÚ(ReadBodyTests.test_withPotentialDataLoss•  sÊ   € ô !“?ˆÜ�OŠO˜HÓ%ˆØ×Ñ×&Ñ& xÔ0Ø×Ñ×&Ñ& yÔ1Ø×Ñ×(Ñ(¬Ô1BÓ1DÓ)EÔFØ×&Ñ& qÓ)ˆØ�‰”V×0Ñ0Ô1Ø×Ñà!Ÿ-™-×.Ñ.Ø"Ÿ=™=×0Ñ0ØŸ™×.Ñ.ñð !Ø Ø&ñõ	
r_   c                ól  • [        5       n[        R                  " U5      nUR                  R	                  S5        UR                  R                  [        [        S5      5      5        U R                  U5      nUR                  [        5        U R                  UR                  R                  S5        g)zÄ
If there is an exception other than L{client.PotentialDataLoss} while
L{client.readBody} is collecting the response body, the L{Deferred}
returned by {client.readBody} fires with that exception.
ry  úmystery problem)r‰  N)rk  r0   r|  r  rQ  r³  r*   r   rÝ   rÞ   r¬   r™  r$  )r[   r  rX  rM  s       r\   Útest_otherErrorsÚReadBodyTests.test_otherErrors°  sƒ   € ô !“?ˆÜ�OŠO˜HÓ%ˆØ×Ñ×&Ñ& xÔ0Ø×Ñ×(Ñ(¬´Ð@QÓ1RÓ)SÔTØ×%Ñ% aÓ(ˆØ�‰”NÔ#Ø×Ñ˜Ÿ™×*Ñ*Ð,@ÕAr_   c                óâ   ^• [        [        S9mSTR                  l        U R	                  [
        S[        U4S j5      nUR                  5         U R                  U[        R                  5        g)z´
Calling L{client.readBody} with a transport that does not implement
L{twisted.internet.interfaces.ITCPTransport} produces a deprecation
warning, but no exception when cancelling.
)rm  NzLUsing readBody with a transport that does not have an abortConnection methodc                 ó0   >• [         R                  " T 5      $ r~   )r0   r|  )r  s   €r\   r‹   Ú8ReadBodyTests.test_deprecatedTransport.<locals>.<lambda>Ë  s   ø€ ”F—O’O HÔ-r_   )rk  r&   rb  rh  ÚassertWarnsr2  Ú__file__rã   rÝ   r   r   )r[   rX  r  s     @r\   Útest_deprecatedTransportÚ&ReadBodyTests.test_deprecatedTransport¾  s\   ø€ ô !´/ÑBˆØ-1ˆ×ÑÔ*Ø×ÑÜð%äÜ-ó
ˆð 	
�‰Œ
Ø×Ñ˜Q¤× 4Ñ 4Õ5r_   c                óš   • [        5       n[        R                  " U5        U R                  5       nU R	                  [        U5      S5        g)z�
Calling L{client.readBody} with a response that has already had its
transport closed (eg. for a very small request) will not trigger a
deprecation warning.
r   N)rs  r0   r|  r1  r¬   r³   )r[   r  r3  s      r\   Ú!test_deprecatedTransportNoWarningÚ/ReadBodyTests.test_deprecatedTransportNoWarningÐ  s:   € ô 1Ó2ˆÜ�Š˜Ô!à×%Ñ%Ó'ˆØ×Ñœ˜X›¨Õ*r_   re   N)r`   ra   rb   rc   ry   r}  r€  r†  rŠ  r‘  r”  rd   re   r_   r\   rw  rw  y  s'   † ñò
Bò	5ò
ò6Bò6õ$
+r_   rw  c                  ó&   • \ rS rSrS rS rS rSrg)ÚHostnameCachingHTTPSPolicyTestsiÝ  c                óÂ  • [        5       n[        US9n[        U5      nUR                  SS5      nU R	                  UR
                  5        SUl        U R                  S[        UR                  5      5        UR                  S5      nU R                  UR                  UR                  5       5        UR                  SS5        U R                  UR
                  5        g)z„
Verify that the connection creator is added to the
policy's cache, and that it is reused on subsequent calls
to creatorForNetLoc.

r8  r4  i5  FrÀ   N)rT   r;   r=   r"  r–   rY   r˜  r³   Ú_cacher  rÙ  rZ   r:  r€  )r[   r9  ÚwrappedPolicyr;  r<  r=  s         r\   Útest_cacheIsUsedÚ0HostnameCachingHTTPSPolicyTests.test_cacheIsUsedß  s¶   € ô +Ó,ˆ	Ü1¸IÑFˆÜ+¨MÓ:ˆØ×)Ñ)¨&°$Ó7ˆØ�‰˜	×(Ñ(Ô)Ø ˆ	ÔØ×Ñ˜!œS §¡Ó/Ô0Ø×3Ñ3°DÓ9ˆ
Ø�‰�i×'Ñ'¨×)?Ñ)?Ó)AÔBà×Ñ ¨Ô-Ø×Ñ˜×)Ñ)Õ*r_   c                ó�  • [        5       n[        US9n[        U5      n[        SS5       H2  nS[	        U5      -   nUR                  UR                  S5      S5        M4     SnUR                  UR                  S5      S5        U R                  XcR                  5        U R                  S[        UR                  5      5        S	nUR                  UR                  S5      S5        S
nU R                  XƒR                  5        U R                  S[        UR                  5      5        U R                  XsR                  5        U R                  XcR                  5        [        S5       H$  n	UR                  UR                  S5      S5        M&     Sn
UR                  U
R                  S5      S5        U R                  SUR                  5        U R                  S[        UR                  5      5        U R                  X£R                  5        U R                  XsR                  5        U R                  XcR                  5        g)z\
Verify that when the cache is full, and a new entry is added,
the oldest entry is removed.
r8  r   é   rv  rA  éã!  Úhost0é5  ÚnewÚhost1Únew1i   Úhost2N©rT   r;   r=   rÂ   Ústrr"  rf  rd  r™  r˜  r³   rN  )r[   r9  rš  r;  rË   r  r   Úhostnr£  rØ  Ú
hostNPlus1s              r\   Útest_cacheRemovesOldestÚ7HostnameCachingHTTPSPolicyTests.test_cacheRemovesOldestó  sµ  € ô
 +Ó,ˆ	Ü1¸IÑFˆÜ+¨MÓ:ˆÜ�q˜"–ˆAØ¤ A£‘ˆHØ×#Ñ# H§O¡O°GÓ$<¸dÖCñ ð
 ˆØ×Ñ §¡¨WÓ 5°sÔ;Ø�‰�eŸ]™]Ô+Ø×Ñ˜"œc &§-¡-Ó0Ô1àˆØ×Ñ §¡¨WÓ 5°sÔ;àˆØ×Ñ˜§¡Ô.Ø×Ñ˜"œc &§-¡-Ó0Ô1à�‰�eŸ]™]Ô+Ø�‰�eŸ]™]Ô+ô �r–ˆAØ×#Ñ# E§L¡L°Ó$9¸4Ö@ñ ð ˆ
à×Ñ 
× 1Ñ 1°'Ó :¸CÔ@à×Ñ˜ &§-¡-Ô0Ø×Ñ˜"œc &§-¡-Ó0Ô1à�‰�j§-¡-Ô0Ø�‰�eŸ]™]Ô+Ø�‰�eŸ]™]Õ+r_   c                óB  • [        5       n[        US9n[        USS9n[        SS5       H2  nS[	        U5      -   nUR                  UR                  S5      S5        M4     SnU R                  XcR                  5        U R                  S[        UR                  5      5        S	nUR                  UR                  S5      S
5        U R                  XcR                  5        U R                  S[        UR                  5      5        U R                  XsR                  5        g)zp
Verify that changing the cache size results in a policy that
respects the new cache size and not the default.

r8  r²   )Ú	cacheSizer   rv  rA  rŸ  r   r¢  r¡  Nr¦  )r[   r9  rš  r;  rË   r  Úfirstr¨  s           r\   Útest_changeCacheSizeÚ4HostnameCachingHTTPSPolicyTests.test_changeCacheSize  sá   € ô +Ó,ˆ	Ü1¸IÑFˆÜ+¨MÀQÑGˆÜ�q˜!–ˆAØ¤ A£‘ˆHØ×#Ñ# H§O¡O°GÓ$<¸dÖCñ ð ˆØ�‰�eŸ]™]Ô+Ø×Ñ˜!œS §¡Ó/Ô0àˆØ×Ñ §¡¨WÓ 5°sÔ;Ø×Ñ˜§¡Ô.Ø×Ñ˜!œS §¡Ó/Ô0à�‰�eŸ]™]Õ+r_   re   N)r`   ra   rb   rc   r›  rª  r¯  rd   re   r_   r\   r—  r—  Ý  s   † ò+ò(),õV,r_   r—  c                  ó   • \ rS rSrSrS rSrg)ÚRequestMethodInjectionTestsi7  z8
Test L{client.Request} against HTTP method injections.
c                óX   • [         R                  " US[        R                  " 5       SS9  g)rà  rá  N©r   r  rõ  rD  ©r0   r?   r2   rC   )r[   r   s     r\   rã  Ú=RequestMethodInjectionTests.attemptRequestWithMaliciousMethod?  s%   € ô 	�ŠØØ)Ü ×(Ò(Ó*Øó		
r_   re   Nrå  re   r_   r\   r²  r²  7  ó   † ñõ
r_   r²  c                  ó   • \ rS rSrSrS rSrg)Ú"RequestWriteToMethodInjectionTestsiM  ú@
Test L{client.Request.writeTo} against HTTP method injections.
c                ó¢   • [         R                  " SS/05      n[        R                  " SSUSS9nXl        UR                  [        5       5        g)rà  rë  ó   twisted.invalidrà  rá  Nr´  )r2   rC   r0   r?   r   ÚwriteTor&   )r[   r   rõ  rt  s       r\   rã  ÚDRequestWriteToMethodInjectionTests.attemptRequestWithMaliciousMethodU  sM   € ô ×&Ò&¨Ð2DÐ1EÐ'FÓGˆÜ�nŠnØØ)ØØñ	
ˆð Œ
Ø�‰”OÓ%Õ&r_   re   Nrå  re   r_   r\   r¹  r¹  M  ó   † ñõ'r_   r¹  c                  ó   • \ rS rSrSrS rSrg)ÚRequestURIInjectionTestsif  z5
Test L{client.Request} against HTTP URI injections.
c                óX   • [         R                  " SU[        R                  " 5       SS9  g)zX
Attempt a request with the provided URI.

@param method: see L{URIInjectionTestsMixin}
rà  Nr´  rµ  r  s     r\   rê  Ú7RequestURIInjectionTests.attemptRequestWithMaliciousURIn  s%   € ô 	�ŠØØÜ ×(Ò(Ó*Øó		
r_   re   Nrì  re   r_   r\   rÁ  rÁ  f  r·  r_   rÁ  c                  ó   • \ rS rSrSrS rSrg)ÚRequestWriteToURIInjectionTestsi|  rº  c                ó¢   • [         R                  " SS/05      n[        R                  " SSUSS9nXl        UR                  [        5       5        g)z[
Attempt a request with the provided method.

@param method: see L{URIInjectionTestsMixin}
rë  r¼  rà  rá  Nr´  )r2   rC   r0   r?   r  r½  r&   )r[   r  rõ  rt  s       r\   rê  Ú>RequestWriteToURIInjectionTests.attemptRequestWithMaliciousURI„  sM   € ô ×&Ò&¨Ð2DÐ1EÐ'FÓGˆÜ�nŠnØØ)ØØñ	
ˆð ŒØ�‰”OÓ%Õ&r_   re   Nrì  re   r_   r\   rÅ  rÅ  |  r¿  r_   rÅ  )©ry   Ú
__future__r   rh  Úhttp.cookiejarr   Úior   Útypingr   r   r   r	   r
   r   Úunittestr   r   Úzope.interface.declarationsr   Úzope.interface.verifyr   Úincrementalr   Útwisted.internetr   r   Útwisted.internet.addressr   r   Útwisted.internet.deferr   r   r   rô  r   r   Útwisted.internet.errorr   r   r   Útwisted.internet.interfacesr   Útwisted.internet.protocolr   r    Útwisted.internet.taskr!   Ú$twisted.internet.test.test_endpointsr"   Útwisted.internet.testingr#   r$   r%   r&   Útwisted.loggerr'   Útwisted.python.componentsr(   Útwisted.python.deprecater)   Útwisted.python.failurer*   Útwisted.test.iosimr+   r,   Útwisted.test.test_sslverifyr-   Útwisted.trial.unittestr.   r/   Útwisted.webr0   r1   r2   Útwisted.web._newclientr3   r4   r5   r6   r7   r8   r9   r\  r:   r;   r<   r=   r>   r?   r@   rA   Útwisted.web.errorrB   Útwisted.web.http_headersrC   rP  rD   rE   rF   rG   rH   rI   Ú!twisted.web.test.injectionhelpersrJ   rK   ÚtestMixinClassrF  ÚruntimeTestCaserL   Ú_sslrì  Útwisted.internet._sslverifyrM   rN   Útwisted.internet.sslrO   Útwisted.protocolsrP   Útwisted.protocols.tlsrQ   rR   rT   ÚImportErrorrg   r{   r‡   r   r  r  r  r  r  rû   r2  r8  r=  rC  rÃ  rÈ  r	  r  rÞ  rè  rî  rY  r{  rÅ  rÐ  rò  r  r  r   rC  rT  r©  ÚSENSITIVE_HEADERSrÄ  rG  rV  rd  rk  rs  rw  r—  r²  r¹  rÁ  rÅ  re   r_   r\   Ú<module>rî     sê  ðñõ #ã Ý $Ý ß G× Gß %å 3Ý .å ç (ß =ß DÑ Dß K÷ñ õ
 Hß 7Ý 'Ý N÷ó õ .Ý 7Ý @Ý *ß 4Ý Iß @ß 3Ñ 3÷÷ ñ ÷	÷ 	ó 	õ 1Ý ,÷÷ ÷ö Ø€NØ�Oà€NØ€Oð#Ý,ð
 €CØ€JßOÝ8Ý%ßOáÐ"Ó#÷#ð #ó $ð#ô�xô ÷2%ñ %ô]&˜Hô ]&ð@ €ØÐ Ø€Ø€Ø€Ø€
÷P!ñ P!÷f!ñ !÷Gñ Gô �7ô  ôjV˜hÐ(Bô jV÷Z		@ñ 	@÷u
ñ u
ñp Ð"Ó#÷0ð 0ó $ð0ô$Y)ØÐ(¨/Ð;RôY)ôx4ØØØô4ô(4ØØØô4ñ( ˆJŒÐ@ÓAôX
�hÐ :Ð<Só X
ó BðX
ôv?U 8ô ?UôDy, 8Ð-Gô y,÷x!ñ !ô2;
�XÐ/ô ;
ô|h2ØÐÐ :¸Oôh2ôVÑ  Ó+ô ôˆxô ô~+˜xÐ)CÀ_ô ~+ôB#˜(ô #ô4w2 xÐ1Kô w2ôt[6�hÐ :¸Oô [6ò|Ð ôIF˜~ô IFôX%4ØØØØô	%4ôP#.ØØØØô	#.ôL˜ô ÷&"5ñ "5ôJ' Mô 'ôa+�Hô a+ñH ˆJŒÐ@ÓAôV, hó V,ó BðV,ôr
ØØô
ô,'ØØô'ô2
ØØô
ô,'ØØõ'øðh ó Ø
€CØƒJðús   Ä(M Í
M,Í+M,