+
    Dfj+                    "   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHtHtHt ^ R
IHt ^ RIt^ RIHt ^ RIHt ^ RIH t H!t! ^ RI"H#t# ^ RI$H%t%H&t&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t-H.t. ^ RI/H0t0 ^ RI1H2t2 ^ RI3H4t5 ^ RI6H7t7 ^ RI8Ht ^ RI9H:t: ^ RI;H<t<H=t=H>t> ^ RI?H@t@HAtAHBtB ^ RICHDtDHEtEHFtFHGtG ^RIHHItI  ! R R]0! ]<P                  4      4      tKR tL ! R  R!]<P                  4      tN]L! ]N4      tO ! R" R#]Pt                  4      tP ! R$ R%]<P                  4      tQ]L! ]Q4      tR]! ]>P                  4       ! R& R']Q4      4       tT]L! ]T4      tU ! R( R)]Q4      tV]L! ]V4      tW ! R* R+]<P                  4      tYR, tZ ! R- R.4      t[ ! R/ R0]Pt                  ][4      t\ ! R1 R2]\4      t] ! R3 R4]\4      t^ ! R5 R6]\4      t_ ! R7 R8]Pt                  ][4      t` ! R9 R:]Pt                  4      ta ! R; R<]Pt                  4      tb ! R= R>]Pt                  4      tc ! R? R@]Pt                  4      tdRA te ! RB RC]Pt                  4      tf ! RD RE]:4      tg ! RF RG]Pt                  4      th ! RH RI]Pt                  ][4      ti ! RJ RK]Pt                  4      tj ! RL RM]Pt                  4      tk ! RN RO]<P                  4      tl ! RP RQ]Pt                  4      tm ! RR RS]Pt                  ][4      tn ! RT RU]Pt                  4      to ! RV RW]Pt                  ][4      tpRX tq ! RY RZ]Pt                  4      tr ! R[ R\]Pt                  4      ts ! R] R^]P                  4      tu ! R_ R`]P                  4      tv ! Ra Rb]P                  4      twR# )cz
Test HTTP support.
N)partial)BytesIOTextIOWrapper)cycle)SequenceUnion)skipIfclear_cache)urlparse
urlunsplit)directlyProvides
providedByprovider)verifyObject)Version)address)ConnectionDoneConnectionLost)Clock)EventLoggingObserverNonStreamingProducerStringTransport)globalLogPublisher)loopback)	iterbytesnetworkString)proxyForInterface)Failure)logfile)DummyProducer)unittest)TestCase)httphttp_headersiweb)PotentialDataLoss	_DataLoss_IdentityTransferDecoder)DummyChannelbytesLinearWhitespaceComponentssanitizedBytestextLinearWhitespaceComponents)assertIsFilesystemTemporaryc                       ] tR t^5tRtRtR# )._IDeprecatedHTTPChannelToRequestInterfaceProxyz}
Proxy L{_IDeprecatedHTTPChannelToRequestInterface}.  Used to
assert that the interface matches what L{HTTPChannel} expects.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r0       </usr/lib/python3/dist-packages/twisted/web/test/test_http.pyr/   r/   5   s    
r7   r/   c                >   a  V 3R lp\        V\        S 4      4       V# )a  
Return a callable that proxies instances of C{clsToWrap} via
    L{_IDeprecatedHTTPChannelToRequestInterface}.

@param clsToWrap: The class whose instances will be proxied.
@type cls: L{_IDeprecatedHTTPChannelToRequestInterface}
    implementer.

@return: A factory that returns
    L{_IDeprecatedHTTPChannelToRequestInterface} proxies.
@rtype: L{callable} whose interface matches C{clsToWrap}'s constructor.
c                  *   < S! V / VB p\        V4      # N)r/   )argskwargsinstance	clsToWraps   *, r8   _makeRequestProxy3_makeRequestProxyFactory.<locals>._makeRequestProxyN   s    d-f-=hGGr7   )r   r   )r?   r@   s   f r8   _makeRequestProxyFactoryrB   @   s!    H
 &
9(=>r7   c                   *   a  ] tR t^Wt o RtR tRtV tR# )DummyPullProducerHandlerz
An HTTP request handler that registers a dummy pull producer to serve the
body.

The owner must call C{finish} to complete the response.
c                    \        V 4      V n        V P                  ^4       V P                  V P                  R4       R# )   FN)r   _actualProducersetResponseCoderegisterProducerselfs   &r8   process DummyPullProducerHandler.process_   s3    3D9S!d22E:r7   )rG   Nr1   r2   r3   r4   r5   rL   r6   __classdictcell____classdict__s   @r8   rD   rD   W   s     ; ;r7   rD   c                   0   a  ] tR t^ht o RtR tR tRtV tR# )DateTimeTestszTest date parsing functions.c                    \        R 4       FW  p\        P                  ! ^ R4      p\        P                  ! V4      p\        P
                  ! V4      pV P                  W$4       KY  	  R# )i'  i 5wN)rangerandomrandintr#   datetimeToStringstringToDatetimeassertEqual)rK   itimetimestrtime2s   &    r8   testRoundtripDateTimeTests.testRoundtripk   sN    uA>>!Z0D++D1G))'2ET)	 r7   c                   . ROp\         P                  ! R4      pV F)  pV P                  \        P                  ! V4      V4       K+  	  V P                  \        P                  ! R4      \         P                  ! R4      4       R# )   Sun, 06 Nov 1994 08:49:37 GMTs    Thursday, 29-Sep-16 17:15:29 GMTN)rb   s   06 Nov 1994 08:49:37 GMTs   Sunday, 06-Nov-94 08:49:37 GMTs   06-Nov-94 08:49:37 GMTs    Sunday, 06-Nov-1994 08:49:37 GMTs   06-Nov-1994 08:49:37 GMTs   Sun Nov  6 08:49:37 1994s   Nov  6 08:49:37 1994)	i           1   %   rd   rd       )	i  	            rj      i  rh   )calendartimegmrZ   r#   rY   )rK   dateStringsdateInt
dateStrings   &   r8   testStringToDatetime"DateTimeTests.testStringToDatetimer   si    	
 //"CD%JT22:>H &!!"EFOO@A	
r7   r0   N)	r1   r2   r3   r4   r5   r_   rs   r6   rO   rP   s   @r8   rS   rS   h   s     &*
 
r7   rS   c                   &   a  ] tR t^t o R tRtV tR# )DummyHTTPHandlerc                \   V P                   P                  ^ ^ 4       V P                   P                  4       pV P                  R4      pVf   \	        V4      P                  4       pRV,           R,           V,           R,           pV P                  ^4       V P                  RV P                  4       V P                  RV P                  4       V P                  RV P                  4       V P                  RR	\        V4      3,          4       V P                  V4       V P                  4        R# )
rh      content-lengthNs   '''
   
s   Requests   Commands   Version   Content-Lengths   %d)contentseekread	getHeaderstrencoderH   	setHeaderurimethodclientprotolenwritefinish)rK   datalengthrequests   &   r8   rL   DummyHTTPHandler.process   s    !Q||  " 12>['')FV#e+d2X=S!z488,z4;;/z4#3#34(%3w</*AB

7r7   r0   Nr1   r2   r3   r4   rL   r6   rO   rP   s   @r8   rv   rv      s      r7   rv   c                   *   a  ] tR t^t o RtR tRtV tR# )DummyNewHTTPHandlerz
This is exactly like the DummyHTTPHandler but it takes only one argument
in its constructor, with no default arguments. This exists to test an
alternative code path in L{HTTPChannel}.
c                0    \         P                  W4       R # r;   )rv   __init__)rK   channels   &&r8   r   DummyNewHTTPHandler.__init__   s    !!$0r7   r0   N)r1   r2   r3   r4   r5   r   r6   rO   rP   s   @r8   r   r      s     1 1r7   r   c                   0   a  ] tR t^t o RtR tR tRtV tR# )DelayedHTTPHandlerz<
Like L{DummyHTTPHandler}, but doesn't respond immediately.
c                    R # r;   r0   rJ   s   &r8   rL   DelayedHTTPHandler.process   s    r7   c                0    \         P                  V 4       R # r;   )rv   rL   rJ   s   &r8   delayedProcess!DelayedHTTPHandler.delayedProcess   s      &r7   r0   N)	r1   r2   r3   r4   r5   rL   r   r6   rO   rP   s   @r8   r   r      s     ' 'r7   r   c                   &   a  ] tR t^t o R tRtV tR# )LoopbackHTTPClientc                    V P                  R R4       V P                  R^
4       V P                  4        V P                  P	                  R4       R# )   GET   /foo/barrz   
   0123456789N)sendCommand
sendHeader
endHeaders	transportr   rJ   s   &r8   connectionMade!LoopbackHTTPClient.connectionMade   s=    -)2.]+r7   r0   N)r1   r2   r3   r4   r   r6   rO   rP   s   @r8   r   r      s     , ,r7   r   c                <    VP                   V P                  n         V # )a|  
Parametrizes the L{TimeoutMixin} so that it works with whatever reactor is
being used by the test.

@param protocol: A L{_GenericHTTPChannel} or something implementing a
    similar interface.
@type protocol: L{_GenericHTTPChannel}

@param reactor: An L{IReactorTime} implementation.
@type reactor: L{IReactorTime}

@return: The C{channel}, with its C{callLater} method patched.
)	callLater_channel)protocolreactors   &&r8   parametrizeTimeoutMixinr      s    $ #*"3"3HOr7   c                   *   a  ] tR t^t o RtR tRtV tR# )ResponseTestMixinz
A mixin that provides a simple means of comparing an actual response string
to an expected response string by performing the minimal parsing.
c                   V F  pVRR VR,          rTV^ ,          pVR,          pVP                  R^4      w  rxVP                  4       pVP                  ^ 4      p	V P                  Wi4       V P                  \	        V4      \	        V4      4       VR\        V4       p
V\        V4      R pV P                  W4       K  	  R# )a  
Assert that the C{responses} matches the C{expected} responses.

@type responses: C{bytes}
@param responses: The bytes sent in response to one or more requests.

@type expected: C{list} of C{tuple} of C{bytes}
@param expected: The expected values for the responses.  Each tuple
    element of the list represents one response.  Each byte string
    element of the tuple is a full header line without delimiter, except
    for the last element which gives the full response body.
N:   NN   

)split
splitlinespoprZ   setr   )rK   	responsesexpectedresponseexpectedHeadersexpectedContentexpectedStatusheadersreststatusr{   s   &&&        r8   assertResponseEquals&ResponseTestMixin.assertResponseEquals   s     !H/7}hrl_,Q/N-b1O%OOK;MG((*G[[^F^4S\3+?@1S12GS134IW6 !r7   r0   N)r1   r2   r3   r4   r5   r   r6   rO   rP   s   @r8   r   r      s     
7 7r7   r   c                   l   a  ] tR t^t o RtR.tR tR tR tR t	R t
R tR tR	 tR
 tV 3R ltRtV tR# )HTTP1_0Testss7   GET / HTTP/1.0

GET / HTTP/1.1
Accept: text/html

c                `   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       \        V P                  4       F  pVP                  V4       K  	  VP                  \        R4      4       VP                  4       pV P                  W@P                  4       R# )zJ
Send requests over a channel and check responses match what is expected.
zall oneNr   r#   HTTPChannelDummyHTTPHandlerProxyrequestFactorymakeConnectionr   requestsdataReceivedconnectionLostIOErrorvaluer   expected_responserK   babyter   s   &    r8   test_bufferHTTP1_0Tests.test_buffer  s     0	dmm,DNN4  -	+,	!!%)?)?@r7   c                
   \        4       p\        4       p\        P                  ! 4       p^dVn        VP
                  Vn        VP                  V4       VP                  R4       VP                  ^c4       V P                  VP                  4       VP                  R4       VP                  ^c4       V P                  VP                  4       VP                  R4       V P                  \        VP                  4      ^4       R# )zY
L{HTTPChannel} resets its timeout whenever data from a request body is
delivered to it.
&   POST / HTTP/1.0
Content-Length: 2

   xN)r   r   r#   r   timeOutr   r   r   advanceassertFalsedisconnectingrZ   r   r   )rK   clockr   r   s   &   r8   test_requestBodyTimeout$HTTP1_0Tests.test_requestBodyTimeout  s    
 #%	##%"__	*MNb001d#b001d#X../3r7   c                   \        4       p\        4       p\        P                  ! 4       pVP	                  R4      p\        WA4      pVP                  V4       VP                  R4       VP                  ^;4       V P                  VP                  4       VP                  ^4       V P                  VP                  4       R# )z1
L{HTTPChannel}'s default timeout is 60 seconds.
Nr   )r   r   r#   HTTPFactorybuildProtocolr   r   r   r   r   r   
assertTruerK   r   r   factoryr   s   &    r8   test_requestBodyDefaultTimeout+HTTP1_0Tests.test_requestBodyDefaultTimeout1  s     #%	""$((.*8;	*MNb001a	//0r7   c                   \         P                  ! V \        4      p\        4       p\	        4       p\
        P                  ! 4       pVP                  R4      p\        WR4      pVP                  V4       VP                  R4       V P                  VP                  4       V P                  VP                  4       VP                  ^<4       V P                  VP                  4       V P                  VP                  4       V P!                  ^\#        V4      4       V^ ,          pV P%                  RVR,          4       VP                  ^4       V P                  VP                  4       V P                  VP                  4       VP                  ^4       V P                  VP                  4       V P                  VP                  4       V P!                  ^\#        V4      4       V^,          pV P!                  RVR,          4       R# )e
If a timed out transport doesn't close after 15 seconds, the
L{HTTPChannel} will forcibly close it.
Nr   zTiming out client: {peer}
log_formatz"Forcibly timing out client: {peer})r   createWithCleanupr   r   r   r#   r   r   r   r   r   r   r   disconnectedr   r   assertEqualsr   assertIn)rK   logObserverr   r   r   r   events   &      r8   test_transportForciblyClosed)HTTP1_0Tests.test_transportForciblyClosedA  s   
 +<<TCUV#%	""$((.*8;	*MN001//0 	b	//0//0!S-.A153FG 	b	//0//0a	//0	../!S-.A>l@STr7   c                   \        4       p\        4       p\        P                  ! 4       pVP	                  R4      p\        WA4      pVP                  V4       VP                  R4       V P                  VP                  4       V P                  VP                  4       VP                  ^<4       V P                  VP                  4       V P                  VP                  4       VP                  ^4       VP                  R4       VP                  ^4       V P                  VP                  4       V P                  VP                  4       R# )zm
If a timed out transport ends up calling C{connectionLost}, it prevents
the force-closure of the transport.
Nr   )r   r   r#   r   r   r   r   r   r   r   r   r   r   r   r   s   &    r8   +test_transportNotAbortedAfterConnectionLost8HTTP1_0Tests.test_transportNotAbortedAfterConnectionLostd  s   
 #%	""$((.*8;	*MN001//0 	b	//0//0 	b% 	a	//0//0r7   c                ~   \        4       p\        4       p\        P                  ! 4       pVP	                  R4      pRVP
                  n        \        WA4      pVP                  V4       VP                  R4       V P                  VP                  4       V P                  VP                  4       VP                  ^<4       V P                  VP                  4       V P                  VP                  4       VP                  R4       V P                  VP                  4       V P                  VP                  4       R# )zP
If the L{HTTPChannel} has its c{abortTimeout} set to L{None}, it never
aborts.
Nr   l        )r   r   r#   r   r   r   abortTimeoutr   r   r   r   r   r   r   r   r   s   &    r8   ,test_transportNotAbortedWithZeroAbortTimeout9HTTP1_0Tests.test_transportNotAbortedWithZeroAbortTimeout  s    
 #%	""$((.)-&*8;	*MN001//0 	b	//0//0 	e	//0//0r7   c                   \        4       p\        4       p\        P                  ! 4       pVP	                  R4      p\        WA4      pVP                  V4       VP                  R4       V P                  VP                  4       V P                  VP                  4       VP                  ^<4       VP                  ^4       V P                  VP                  4       V P                  VP                  4       VP                  \        4       R# )r   Nr   )r   r   r#   r   r   r   r   r   r   r   r   r   r   r   r   r   s   &    r8   "test_connectionLostAfterForceClose/HTTP1_0Tests.test_connectionLostAfterForceClose  s    
 #%	""$((.*8;	*MN001//0 	bb	//0	../
 	/r7   c                `   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       \        V P                  4       F  pVP                  V4       K  	  VP                  \        R4      4       VP                  4       pV P                  W@P                  4       R# )zN
Test that a L{http.Request} subclass with no queued kwarg works as
expected.
all doneNr   r   s   &    r8   test_noPipeliningApi!HTTP1_0Tests.test_noPipeliningApi  s    
 0	dmm,DNN4  -	,-	!!%)?)?@r7   c                   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       \        V P                  4       F  pVP                  V4       K  	  VP                  4       pV P                  VR4       V P                  ^\        VP                  4      4       VP                  '       dU   V P                  ^\        VP                  4      4       VP                  ^ ,          P                  pVP                  4        Kf  VP                  4       pV P                  W@P                  4       R# )zG
Test that pipelined requests get buffered, not processed in parallel.
r7   N)r   r#   r   DelayedHTTPHandlerProxyr   r   r   r   r   r   rZ   r   originalr   r   r   )rK   r   r   r   r   r   s   &     r8   test_noPipeliningHTTP1_0Tests.test_noPipelining  s     2	dmm,DNN4  -	 	$C

O, jjjQAJJ0jjm,,G""$	!!%)?)?@r7   c                \   < V ^8  d   Qh/ S[ S[S[S[,          ,          S[3,          ;R&   # )   r   )r   r   bytes)formatrQ   s   "r8   __annotate__HTTP1_0Tests.__annotate__   s'      Xhuo6=> 	 r7   r0   N)   HTTP/1.0 200 OK
   Request: /   Command: GET   Version: HTTP/1.0   Content-Length: 13   '''
None
'''
)r1   r2   r3   r4   r   r   r   r   r   r   r   r   r   r   r  __annotate_func__r6   rO   rP   s   @r8   r   r      sW     	 	
	BA4(1 !UF1:1404A AW  r7   r   c                   "    ] tR tRtRt. ROtRtR# )HTTP1_1Testsi  s   GET / HTTP/1.1
Accept: text/html

POST / HTTP/1.1
Content-Length: 10

0123456789POST / HTTP/1.1
Content-Length: 10

0123456789HEAD / HTTP/1.1

r0   N))   HTTP/1.1 200 OKr  r     Version: HTTP/1.1r  r  r  r     Command: POSTr  s   Content-Length: 21   '''
10
0123456789'''
r  )r  r  s   Command: HEADr  r  r7   r1   r2   r3   r4   r   r   r6   r0   r7   r8   r  r    s    
	 !r7   r  c                        ] tR tRtRtR.tRtR# )HTTP1_1_close_Testsi  J   GET / HTTP/1.1
Accept: text/html
Connection: close

GET / HTTP/1.0

r0   N)r  s   Connection: closer  r  r  r  r  r  r0   r7   r8   r  r    s    	 	

r7   r  c                   4   a  ] tR tRt o RtRtR tR tRtV t	R# )HTTP0_9Testsi*  s   GET /
   HTTP/1.1 400 Bad Request

c                (    V P                  W4       R # r;   )rZ   )rK   r   expectedResponses   &&&r8   r   !HTTP0_9Tests.assertResponseEquals/  s    4r7   c                .    \         P                  ! R 4      h)zHTTP/0.9 not supported)r!   SkipTestrJ   s   &r8   r  HTTP0_9Tests.test_noPipelining2  s     899r7   r0   N)
r1   r2   r3   r4   r   r   r   r  r6   rO   rP   s   @r8   r  r  *  s     H;5: :r7   r  c                   T   a  ] tR tRt o RtRtRR.tR tR tR t	R t
R tR	 tR
tV tR# )PipeliningBodyTestsi6  z`
Pipelined requests get buffered and executed in the order received,
not processed in parallel.
st   POST / HTTP/1.1
Content-Length: 10

0123456789POST / HTTP/1.1
Transfer-Encoding: chunked

a
0123456789
0

c                   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       \        V P                  4       F  pVP                  V4       K  	  V P                  VP                  4       R4       V P                  ^\        VP                  4      4       VP                  '       dU   V P                  ^\        VP                  4      4       VP                  ^ ,          P                  pVP                  4        Kf  V P                  VP                  4       V P                  4       R# )z
Imitate a slow connection that delivers one byte at a time.
The request handler (L{DelayedHTTPHandler}) is puppeted to
step through the handling of each request.
r7   N)r   r#   r   r  r   r   r   r   r   rZ   r   r   r  r   r   expectedResponses)rK   r   r   r   r   s   &    r8   test_stepwiseTinyTube)PipeliningBodyTests.test_stepwiseTinyTube^  s     2	dmm,DNN4  - 	C(C

O, jjjQAJJ0jjm,,G""$!!!'')T-C-CDr7   c                \   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  V P                  4       V P                  VP                  4       R4       V P                  ^\        VP                  4      4       VP                  '       dU   V P                  ^\        VP                  4      4       VP                  ^ ,          P                  pVP                  4        Kf  V P                  VP                  4       V P                  4       R# )z
Imitate a fast connection where several pipelined
requests arrive in a single read. The request handler
(L{DelayedHTTPHandler}) is puppeted to step through the
handling of each request.
r7   N)r   r#   r   r  r   r   r   r   rZ   r   r   r  r   r   r)  )rK   r   r   r   s   &   r8   test_stepwiseDumpTruck*PipeliningBodyTests.test_stepwiseDumpTruckx  s     2		t}}% 	C(C

O, jjjQAJJ0jjm,,G""$!!!'')T-C-CDr7   c                t   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       \        V P                  4       F9  pVP                  V4       V P                  \        VP                  4      ^4       K;  	  V P                  VP                  4       V P                  4       R# )z
Imitate a slow connection that delivers one byte at a time.

(L{DummyHTTPHandler}) immediately responds, but no more
than one
N)r   r#   r   r   r   r   r   r   r   assertLessEqualr   r   r   r)  )rK   r   r   r   s   &   r8   test_immediateTinyTube*PipeliningBodyTests.test_immediateTinyTube  s     0	 dmm,DNN4   QZZ!4 -
 	!!!'')T-C-CDr7   c                   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  V P                  4       V P                  VP                  4       V P                  4       R# )a  
Imitate a fast connection where several pipelined
requests arrive in a single read. The request handler
(L{DummyHTTPHandler}) immediately responds.

This doesn't check the at-most-one pending request
invariant but exercises otherwise uncovered code paths.
See GHSA-c8m8-j448-xjx7.
N)r   r#   r   r   r   r   r   r   r   r   r)  )rK   r   r   s   &  r8   test_immediateDumpTruck+PipeliningBodyTests.test_immediateDumpTruck  s^     0	 	
t}}%!!!'')T-C-CDr7   c                |   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  \        V P                  4      ,          ^
,          pVP                  V P                  V,          4       V P                  VP                  4       V P                  V,          4       R# )ao  
Imitate a fast connection where a so many pipelined
requests arrive in a single read that backpressure is indicated.
The request handler (L{DummyHTTPHandler}) immediately responds.

This doesn't check the at-most-one pending request
invariant but exercises otherwise uncovered code paths.
See GHSA-c8m8-j448-xjx7.

@see: L{http.HTTPChannel._optimisticEagerReadSize}
N)r   r#   r   r   r   r   _optimisticEagerReadSizer   r   r   r   r   r)  )rK   r   r   overLimitCounts   &   r8   test_immediateABiggerTruck.PipeliningBodyTests.test_immediateABiggerTruck  s     0	33s4==7IIBN	t}}~56!!!'')T-C-Cn-TUr7   c           
        \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  \        V P                  4      ,          p\        ^V^,           4       FV  pVP                  V P                  4       V P                  VP                  RRP                  VP                  VR7      4       KX  	  VP                  V P                  4       V P                  VP                  R4       R# )z
When pipelined requests are received, we will optimistically continue
receiving data up to a specified limit, then pause the transport.

@see: L{http.HTTPChannel._optimisticEagerReadSize}
	producingz(state was {state!r} after {x} iterations)statexpausedN)r   r#   r   r  r   r   r7  r   r   rU   r   rZ   producerStater  r   )rK   r   r   
underLimitr>  s   &    r8   test_pipeliningReadLimit,PipeliningBodyTests.test_pipeliningReadLimit  s     2	//3t}}3EE
q*q.)ANN4==):AA//Q B  * 	
t}}%!//84r7   r0   Nr  )r  r  r  r  s   Content-Length: 23s   '''
None
0123456789'''
)r1   r2   r3   r4   r5   r   r)  r*  r-  r1  r4  r9  rB  r6   rO   rP   s   @r8   r'  r'  6  sN     	  	
	
&E4E4E(E(V,5 5r7   r'  c                   X   a  ] tR tRt o Rt ! R R]P                  4      tRtR t	Rt
V tR# )	ShutdownTestsi  zE
Tests that connections can be shut down by L{http.Request} objects.
c                   *   a  ] tR tRt o RtR tRtV tR# )!ShutdownTests.ShutdownHTTPHandleri  z<
A HTTP handler that just immediately calls loseConnection.
c                &    V P                  4        R # r;   )loseConnectionrJ   s   &r8   rL   )ShutdownTests.ShutdownHTTPHandler.process  s    !r7   r0   NrN   rP   s   @r8   ShutdownHTTPHandlerrG    s     		" 	"r7   rK  s1   POST / HTTP/1.1
Content-Length: 10

0123456789c                J   \        4       p\        P                  ! 4       p\        V P                  4      Vn        VP                  V4       VP                  V P                  4       V P                  VP                  4       VP                  4       pV P                  VR4       R# )zQ
Calling L{http.Request.loseConnection} causes the transport to be
disconnected.
r7   N)r   r#   r   rB   rK  r   r   r   r   r   r   r   rZ   )rK   r   r   r   s   &   r8   test_losingConnection#ShutdownTests.test_losingConnection  sz    
 3D4L4LM		t||$ 	( 	$r7   r0   N)r1   r2   r3   r4   r5   r#   RequestrK  r   rM  r6   rO   rP   s   @r8   rE  rE    s,     "dll " UG% %r7   rE  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )SecurityTestsi  zQ
Tests that L{http.Request.isSecure} correctly takes the transport into
account.
c                    \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       \        P
                  ! V4      pV P                  VP                  4       4       R# )zj
Calling L{http.Request.isSecure} when the channel is backed with a
secure transport will return L{True}.
N)r)   SSLr#   r   r   rO  r   isSecurerK   r   r   reqs   &   r8   test_isSecureSecurityTests.test_isSecure  sM    
 	ll1o'r7   c                    \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       \        P
                  ! V4      pV P                  VP                  4       4       R# )zo
Calling L{http.Request.isSecure} when the channel is not backed with a
secure transport will return L{False}.
N)r)   TCPr#   r   r   rO  r   rT  rU  s   &   r8   test_notSecureSecurityTests.test_notSecure  sO    
 	ll1o(r7   c                ^   \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       \        P
                  ! V4      pVP                  P                  V4       VP                  ^4       VP                  4        V P                  VP                  4       4       R# )z\
After a request is finished, calling L{http.Request.isSecure} will
always return L{False}.
N)r)   rS  r#   r   r   rO  r   appendrH   r   r   rT  rU  s   &   r8   test_notSecureAfterFinish'SecurityTests.test_notSecureAfterFinish'  sx    
 	ll1o	

#C 

(r7   r0   N)
r1   r2   r3   r4   r5   rW  r[  r_  r6   rO   rP   s   @r8   rQ  rQ    s     
	(	)) )r7   rQ  c                   t  a  ] tR tRt o RtRtR t]! ]P                  '       * R4      R 4       t
R tR tR	 t]! ]P                  '       * R4      R
 4       t]! ]P                  R4      R 4       tR tR tR t]! ]P                  '       * R4      R 4       t]! ]P                  '       * R4      R 4       tRtV tR# )GenericHTTPChannelTestsi7  zz
Tests for L{http._genericHTTPChannelProtocol}, a L{HTTPChannel}-alike which
can handle different HTTP protocol channels.
r  c                   \         P                  ! R4      p\        Vn        VP	                  V4       \        V P                  4       F  pVP                  V4       K  	  VP                  \        R4      4       VP                  # )zc
Run a request using the specific instance of a transport. Returns the
negotiated protocol string.
r7   r   )r#   "_genericHTTPChannelProtocolFactoryr   r   r   r   r   r   r   r   _negotiatedProtocol)rK   tr   r   s   &&  r8   '_negotiatedProtocolForTransportInstance?GenericHTTPChannelTests._negotiatedProtocolForTransportInstanceF  sh    
 33C80	dmm,DNN4  -	,-$$$r7   zHTTP/2 support not presentc                   \        4       p\        P                  ! R4      p\        Vn        ^dVn        VP                  Vn        \        4       pRVn        VP                  V4       \        P                  ! VP                  4       \        P                  ! \        P                  ! R\        P                  ! R4      4      4      4       VP                  4       ^ ,          pVP!                  R4       V P#                  VP$                  R4       V P'                  VP(                  4       \        P                  ! VP                  4       \        P                  ! \        P                  ! R\        P                  ! R4      4      4      4       R# )zO
When the transport is switched to H2, the HTTPChannel timeouts are
cancelled.
r7      h2	cancelledFN)r   r#   rd  r   r   r   r   r   negotiatedProtocolr   hamcrestassert_thatgetDelayedCallscontainshas_propertyequal_tor   rZ   re  r   rk  )rK   r   r   r   
h11Timeouts   &    r8   test_h2CancelsH11Timeout0GenericHTTPChannelTests.test_h2CancelsH11TimeoutT  s2    33C80 	oo$	
 	!!#%%%%e,	
 **,Q/
 	
s..6 	
,,-!!#%%%%e,	
r7   c                `    \        4       pV P                  V4      pV P                  VR4       R# )zr
If the transport has no support for protocol negotiation (no
negotiatedProtocol attribute), HTTP/1.1 is assumed.
   http/1.1N)r   rg  rZ   rK   r   rl  s   &  r8   test_protocolUnspecified0GenericHTTPChannelTests.test_protocolUnspecified  s.    
 !II!L+[9r7   c                n    \        4       pRVn        V P                  V4      pV P                  VR4       R# )zv
If the transport has no support for protocol negotiation (returns None
for negotiatedProtocol), HTTP/1.1 is assumed.
Nrw  r   rl  rg  rZ   rx  s   &  r8   test_protocolNone)GenericHTTPChannelTests.test_protocolNone  s6    
 #!II!L+[9r7   c                n    \        4       pRVn        V P                  V4      pV P                  VR4       R# )zQ
If the transport reports that HTTP/1.1 is negotiated, that's what's
negotiated.
rw  Nr|  rx  s   &  r8   test_http11#GenericHTTPChannelTests.test_http11  s6    
 *!II!L+[9r7   c                n    \        4       pRVn        V P                  V4      pV P                  VR4       R# )ze
If the transport reports that HTTP/2 is negotiated and HTTP/2 is
present, that's what's negotiated.
rj  Nr|  rx  s   &  r8   test_http2_present*GenericHTTPChannelTests.test_http2_present  s6     $!II!L+U3r7   zHTTP/2 support presentc                j    \        4       pRVn        V P                  \        V P                  V4       R# )zh
If the transport reports that HTTP/2 is negotiated and HTTP/2 is not
present, an error is encountered.
rj  N)r   rl  assertRaises
ValueErrorrg  rK   r   s   & r8   test_http2_absent)GenericHTTPChannelTests.test_http2_absent  s1     $88	
r7   c                j    \        4       pRVn        V P                  \        V P                  V4       R# )zh
If the transport reports that a protocol other than HTTP/1.1 or HTTP/2
is negotiated, an error occurs.
s   smtpN)r   rl  r  AssertionErrorrg  r  s   & r8   test_unknownProtocol,GenericHTTPChannelTests.test_unknownProtocol  s1    
 &88	
r7   c                    \         P                  ! R4      pRVP                  n        V P	                  VP                  R4       R# )z;
The C{factory} attribute is taken from the inner channel.
r7      FooN)r#   rd  r   r   rZ   )rK   r   s   & r8   test_factory$GenericHTTPChannelTests.test_factory  s4     33C8#

F+r7   c                   \        4       p\        P                  ! VR7      pVP                  R4      pV P	                  VP
                  VP
                  4       V P	                  VP                  P
                  VP
                  4       R# )z
If C{callLater} is patched onto the L{http._GenericHTTPChannelProtocol}
then we need to propagate it through to the backing channel.
r   N)r   r#   r   r   rZ   r   r   )rK   r   r   r   s   &   r8   *test_GenericHTTPChannelPropagatesCallLaterBGenericHTTPChannelTests.test_GenericHTTPChannelPropagatesCallLater  se    
 ""51((.++U__=**44eooFr7   c                >   \        4       p\        P                  ! VR7      pVP                  R4      pV P	                  VP
                  VP
                  4       V P	                  VP                  P
                  VP
                  4       \        4       pRVn        \        Vn
        VP                  V4       VP                  R4       V P	                  VP
                  VP
                  4       V P	                  VP                  P
                  VP
                  4       R# )z
If C{callLater} is patched onto the L{http._GenericHTTPChannelProtocol}
then we need to propagate it across onto a new backing channel after
upgrade.
r  Nrj     P)r   r#   r   r   rZ   r   r   r   rl  rv   r   r   r   rK   r   r   r   r   s   &    r8   'test_genericHTTPChannelCallLaterUpgrade?GenericHTTPChannelTests.test_genericHTTPChannelCallLaterUpgrade  s     ""51((.++U__=**44eooF#%	',	$"2	* 	d#++U__=**44eooFr7   c                   \        4       pRVn        \        P                  ! R4      p\        Vn        VP                  V4       VP                  pV P                  VP                  V4       VP                  R4       V P                  VP                  V4       V P                  VP                  VP                  4       R# )zs
The L{_GenericHTTPChannelProtocol} will unregister its proxy channel
from the transport if upgrade is negotiated.
rj  r7   r  N)r   rl  r#   rd  r   r   r   r   assertIsproducerr   assertIsNot)rK   r   genericProtocoloriginalChannels   &   r8   test_unregistersProducer0GenericHTTPChannelTests.test_unregistersProducer  s     $%	',	$AA#F)>&&&y1)22 	i((/: 	$$T* 	++_= 	i((/*B*BCr7   r0   N)r1   r2   r3   r4   r5   r   rg  r   r#   
H2_ENABLEDrt  ry  r}  r  r  r  r  r  r  r  r  r6   rO   rP   s   @r8   rb  rb  7  s     	 % !=>/
 ?/
b::: !=>4 ?4 DOO56
 7

,
G !=>G ?G0 !=>D ?Dr7   rb  c                   h   a  ] tR tRt o RRRRRRRR	/t^ t^ t^ t^ tR
 t	R t
R tR tR tR tRtV tR# )HTTPLoopbackTestsi  s   requestr   s   commandr   s   version   HTTP/1.0rx   s   21c                \    ^V n         V P                  VR4       V P                  VR4       R# )r   r     200N)	gotStatusrZ   rK   versionr   messages   &&&&r8   _handleStatusHTTPLoopbackTests._handleStatus   s)    +.(r7   c                8    ^V n         V P                  VR4       R# )r   r  N)gotResponserZ   )rK   r   s   &&r8   _handleResponse!HTTPLoopbackTests._handleResponse%  s    :;r7   c                    V P                   ^,           V n         V P                  V P                  VP                  4       ,          V4       R# r   N)
numHeadersrZ   r   lower)rK   keyr   s   &&&r8   _handleHeaderHTTPLoopbackTests._handleHeader)  s3    //A---ciik:EBr7   c                L    ^V n         V P                  V P                  ^4       R# r  )gotEndHeadersrZ   r  rJ   s   &r8   _handleEndHeaders#HTTPLoopbackTests._handleEndHeaders-  s    !,r7   c                D   \         P                  ! 4       p\        Vn        \	        4       pV P
                  Vn        V P                  Vn        V P                  Vn
        V P                  Vn        \        P                  ! W4      pVP                  V P                   4       V# r;   )r#   r   r   r   r   r  handleResponser  handleHeaderr  handleEndHeadersr  handleStatusr   loopbackAsyncaddCallback_cbTestLoopback)rK   serverclientds   &   r8   testLoopbackHTTPLoopbackTests.testLoopback1  s    !!# 5#% $ 4 4"00"&"8"8"00""62	d**+r7   c                    V P                   '       d%   V P                  '       d   V P                  '       g<   \        R P	                  V P                   V P                  V P                  .4      4      hV =V =V = V =R# )zdidn't get all callbacks {}N)r  r  r  RuntimeErrorr  r  )rK   ignoreds   &&r8   r  !HTTPLoopbackTests._cbTestLoopback=  sn    4#3#3#38J8J8J-44^^T%5%5t7I7IJ 
 NOr7   )r  r  r  r  N)r1   r2   r3   r4   r   r  r  r  r  r  r  r  r  r  r  r6   rO   rP   s   @r8   r  r    sZ     KFK5	O JIKM)
<C-

 
r7   r  c                     \         P                  ! \        4       R4      pV P                  4        F*  w  r#VP                  P                  \        V4      V4       K,  	  V# )zJ
Make a request with the given request headers for the persistence tests.
F)r#   rO  r)   itemsrequestHeaderssetRawHeadersr   )r   r   
headerNamevs   ,   r8   	_prequestr  J  sH     ll<>51G 
,,]:-FJ )Nr7   c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
PersistenceTestsiT  z(
Tests for persistent HTTP connections.
c                X    \         P                  ! 4       V n        \        4       V n        R # r;   )r#   r   r   r  r   rJ   s   &r8   setUpPersistenceTests.setUpY  s    '') {r7   c                    V P                   P                  V P                  R4      pV P                  V4       V P	                  . \        V P                  P                  P                  4       4      4       R# )zT
After being used for an I{HTTP/0.9} request, the L{HTTPChannel} is not
persistent.
s   HTTP/0.9Nr   checkPersistencer   r   rZ   listresponseHeadersgetAllRawHeadersrK   persists   & r8   test_http09PersistenceTests.test_http09]  T    
 ,,//kJ!T$,,">">"O"O"QRSr7   c                    V P                   P                  V P                  R4      pV P                  V4       V P	                  . \        V P                  P                  P                  4       4      4       R# )zT
After being used for an I{HTTP/1.0} request, the L{HTTPChannel} is not
persistent.
r  Nr  r  s   & r8   test_http10PersistenceTests.test_http10f  r  r7   c                    V P                   P                  V P                  R4      pV P                  V4       V P	                  . \        V P                  P                  P                  4       4      4       R# )zP
After being used for an I{HTTP/1.1} request, the L{HTTPChannel} is
persistent.
   HTTP/1.1N)r   r  r   r   rZ   r  r  r  r  s   & r8   r  PersistenceTests.test_http11o  sR    
 ,,//kJ T$,,">">"O"O"QRSr7   c                    \        R.R7      pV P                  P                  VR4      pV P                  V4       V P	                  RR.3.\        VP                  P                  4       4      4       R# )zw
After being used for an I{HTTP/1.1} request with a I{Connection: Close}
header, the L{HTTPChannel} is not persistent.
s   close)
connectionr  s
   ConnectionN)r  r   r  r   rZ   r  r  r  )rK   r   r  s   &  r8   test_http11Close!PersistenceTests.test_http11Closex  sf    
 z2,,//E!hZ()((99;<	
r7   )r   r   N)r1   r2   r3   r4   r5   r  r  r  r  r  r6   rO   rP   s   @r8   r  r  T  s+     #TTT
 
r7   r  c                   `   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )IdentityTransferEncodingTestsi  z(
Tests for L{_IdentityTransferDecoder}.
c                    . V n         . V n        ^
V n        \        V P                  V P                   P                  V P                  P                  4      V n        R# )zh
Create an L{_IdentityTransferDecoder} with callbacks hooked up so that
calls to them can be inspected.
N)r   r   contentLengthr(   r^  decoderrJ   s   &r8   r  #IdentityTransferEncodingTests.setUp  sG    
 	/		 0 0$++2D2D
r7   c                    V P                   P                  RV P                  ,          4       V P                  V P                  RV P                  ,          .4       V P                  V P
                  R.4       R# )a  
If L{_IdentityTransferDecoder.dataReceived} is called with a byte string
with length equal to the content length passed to
L{_IdentityTransferDecoder}'s initializer, the data callback is invoked
with that string and the finish callback is invoked with a zero-length
string.
r   r7   Nr  r   r  rZ   r   r   rJ   s   &r8   test_exactAmountReceived6IdentityTransferEncodingTests.test_exactAmountReceived  sY     	!!$););";<TD,>,>%>$?@se,r7   c                   V P                   P                  R4       V P                  V P                  R.4       V P                  V P                  . 4       V P                   P                  RV P
                  ^,
          ,          4       V P                  V P                  RRV P
                  ^,
          ,          .4       V P                  V P                  R.4       R# )a  
If L{_IdentityTransferDecoder.dataReceived} is called multiple times
with byte strings which, when concatenated, are as long as the content
length provided, the data callback is invoked with each string and the
finish callback is invoked only after the second call.
r      yr7   N)r  r   rZ   r   r   r  rJ   s   &r8   test_shortStrings/IdentityTransferEncodingTests.test_shortStrings  s     	!!$'TF+b)!!$$*<*<q*@"ABT443E3E3I+J$KLse,r7   c                   V P                   P                  RV P                  ,          R,           4       V P                  V P                  RV P                  ,          .4       V P                  V P
                  R.4       R# )a  
If L{_IdentityTransferDecoder.dataReceived} is called with a byte string
with length greater than the provided content length, only the prefix
of that string up to the content length is passed to the data callback
and the remainder is passed to the finish callback.
r   r  Nr  rJ   s   &r8   test_longString-IdentityTransferEncodingTests.test_longString  s^     	!!$););";d"BCTD,>,>%>$?@tf-r7   c                V  aa . oVV3R lp\        ^V P                  P                  V4      oSP                  R4       V P	                  S. 4       SP                  R4       S^ ,          P                  \        4       V P	                  \        S^ ,          P                  4      R4       R# )z
If data is passed to L{_IdentityTransferDecoder.dataReceived} after the
finish callback has been invoked, C{RuntimeError} is raised.
c                    <  SP                  R 4       R#   \         d    SP                  \        4       4        R# i ; i)   fooN)r   BaseExceptionr^  r   )r  r  failuress   &r8   r   JIdentityTransferEncodingTests.test_rejectDataAfterFinished.<locals>.finish  s3    +$$V,  +	*+s    $>>r  z;_IdentityTransferDecoder cannot decode data after finishingNs   xxxx)	r(   r   r^  r   rZ   trapr  r   r   )rK   r   r  r  s   & @@r8   test_rejectDataAfterFinished:IdentityTransferEncodingTests.test_rejectDataAfterFinished  s    
 	+ +1dii.>.>GX&2&T"&!!"I	
r7   c                   . p. p\        RVP                  VP                  4      pVP                  R4       V P                  VR.4       VP                  R4       V P                  VRR.4       V P                  V. 4       R# )z
If L{_IdentityTransferDecoder} is constructed with L{None} for the
content length, it passes all data delivered to it through to the data
callback.
Nr   r  )r(   r^  r   rZ   )rK   r   r   r  s   &   r8   test_unknownContentLength7IdentityTransferEncodingTests.test_unknownContentLength  sv     *4fmmLT"v&T"d|,$r7   c                v    V P                  VP                  R4       V P                  VP                  R4       R# )zu
Check the decoder's data and finish callbacks and make sure they are
None in order to help avoid references cycles.
N)assertIdenticaldataCallbackfinishCallback)rK   r  s   &&r8   _verifyCallbacksUnreferenced:IdentityTransferEncodingTests._verifyCallbacksUnreferenced  s0    
 	W1148W33T:r7   c                    V P                   P                  RV P                  ^,
          ,          4       V P                  \        V P                   P
                  4       V P                  V P                   4       R# )z
L{_IdentityTransferDecoder.noMoreData} raises L{_DataLoss} if it is
called and the content length is known but not enough bytes have been
delivered.
r   N)r  r   r  r  r'   
noMoreDatar  rJ   s   &r8   test_earlyConnectionLose6IdentityTransferEncodingTests.test_earlyConnectionLose  sR     	!!$$*<*<q*@"AB)T\\%<%<=))$,,7r7   c                    . p. p\        RVP                  VP                  4      pV P                  \        VP                  4       V P                  V. 4       V P                  VR.4       V P                  V4       R# )z
L{_IdentityTransferDecoder.noMoreData} calls the finish callback and
raises L{PotentialDataLoss} if it is called and the content length is
unknown.
Nr7   )r(   r^  r  r&   r  rZ   r  )rK   bodyfinishedr  s   &   r8   'test_unknownContentLengthConnectionLoseEIdentityTransferEncodingTests.test_unknownContentLengthConnectionLose  sk     *4hooN+W-?-?@r"C5)))'2r7   c                    V P                   P                  RV P                  ,          4       V P                   P                  4        V P	                  V P                   4       R# )z
L{_IdentityTransferDecoder.noMoreData} does not raise any exception if
it is called when the content length is known and that many bytes have
been delivered.
r   N)r  r   r  r  r  rJ   s   &r8   test_finishedConnectionLose9IdentityTransferEncodingTests.test_finishedConnectionLose  sC     	!!$););";<!))$,,7r7   )r  r   r  r   N)r1   r2   r3   r4   r5   r  r  r  r   r	  r  r  r  r  r  r6   rO   rP   s   @r8   r  r    sA     


--	.
.%;838 8r7   r  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )ChunkedTransferEncodingTestsi  z
Tests for L{_ChunkedTransferDecoder}, which turns a byte stream encoded
using HTTP I{chunked} C{Transfer-Encoding} back into the original byte
stream.
c                    . p\         P                  ! VP                  R4      pVP                  R4       VP                  R4       V P	                  V. RO4       R# )zw
L{_ChunkedTransferDecoder.dataReceived} decodes chunked-encoded data
and passes the result to the specified callback.
N   3
abc
5
12345
s   a
0123456789
   abc   12345r   r#   _ChunkedTransferDecoderr^  r   rZ   rK   Lps   &  r8   test_decoding*ChunkedTransferEncodingTests.test_decoding  sJ    
 ((48	45	-.=>r7   c                0   . p. p\         P                  ! VP                  VP                  4      p\        R4       F  pVP	                  V4       K  	  V P                  V. RO4       V P                  VR.4       V P                  VP                  . 4       R# )zc
L{_ChunkedTransferDecoder.dataReceived} decodes chunks broken up and
delivered in multiple calls.
   3
abc
5
12345
0

r7   N   a   b   c   1   2   3   4   5r#   r(  r^  r   r   rZ   _trailerHeadersrK   r*  r  r+  ss   &    r8   
test_short'ChunkedTransferEncodingTests.test_short  s~    
 ((8??CABANN1 CLMC5)**B/r7   c                   . p. p\         P                  ! VP                  VP                  4      pVP                  R4       VP                  R4       VP                  R4       V P	                  VRR.4       V P	                  VR.4       R# )z`
L{_ChunkedTransferDecoder.dataReceived} delivers partial chunk data as
soon as it is received.
s	   a;
12345s   67890s   
0;

...r&  s   ...Nr'  )rK   r   r  r+  s   &   r8   	test_long&ChunkedTransferEncodingTests.test_long-  st    
 ((hooF	~&	x 	+,(34F8,r7   c                <   . p. p\         P                  ! VP                  VP                  4      pVP                  R4       \	        R4       F%  pVP                  V4       VP                  R4       K'  	  V P                  V. RO4       V P                  VR.4       R# )zZ
L{_ChunkedTransferDecoder.dataReceived} is robust against receiving
a zero-length input.
r7   r/  Nr0  )r#   r(  r^  r   r   rZ   )rK   chunksr  r+  r<  s   &    r8   
test_empty'ChunkedTransferEncodingTests.test_empty;  s    
 ((H	sABANN1NN3 C 	!QRC5)r7   c                    . p\         P                  ! VP                  R4      pVP                  R4       V P	                  VR.4       R# )zg
L{_ChunkedTransferDecoder.dataReceived} doesn't treat CR LF pairs
embedded in chunk bodies specially.
Ns   2


   
r'  r)  s   &  r8   test_newlines*ChunkedTransferEncodingTests.test_newlinesJ  s>    
 ((48	'(WI&r7   c                    . p\         P                  ! VP                  R4      pVP                  R4       V P	                  VR.4       R# )zL
L{_ChunkedTransferDecoder.dataReceived} disregards chunk-extension
fields.
Ns   3; x-foo=bar
abc
r%  r'  r)  s   &  r8   test_extensions,ChunkedTransferEncodingTests.test_extensionsT  s>    
 ((48	12VH%r7   c                    RpRpRpW,           V,            Fa  pR\        V34      ,           R,           p\        P                  ! R R 4      pV P                  \        P                  VP
                  V4       Kc  	  R# )	z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk extension fields contain
invalid characters.

This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq.
s    
   \   s   3;    
abc
c                     R # r;   r0   r   s   &r8   <lambda>GChunkedTransferEncodingTests.test_extensionsMalformed.<locals>.<lambda>o      $r7   c                     R # r;   r0   rR  s   &r8   rS  rT  p  rU  r7   N)r  r#   r(  r  _MalformedChunkedDataErrorr   )rK   invalidControlinvalidDelimiter
invalidDelr   r   r+  s   &      r8   test_extensionsMalformed5ChunkedTransferEncodingTests.test_extensionsMalformed^  sy    P 	 !
2Z??AE1$K'.8D,,A d==q~~tT @r7   c                    \         P                  ! RR4      pV P                  \         P                  VP                  RR\         P
                  ,          ,           R,           4       R# )a   
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk size line exceeds 4 KiB.
This applies even when the data has already been received and buffered
so that behavior is consistent regardless of how bytes are framed.
Ns   3;   .rP  r#   r(  r  rW  r   maxChunkSizeLineLengthrK   r+  s   & r8   test_oversizedChunkSizeLine8ChunkedTransferEncodingTests.test_oversizedChunkSizeLinet  sL     ((t4++NND46666G	
r7   c                    \         P                  ! RR4      pV P                  \         P                  VP                  R\         P
                  ^,           ,          4       R# )z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the amount of data buffered while
looking for the end of the chunk size line exceeds 4 KiB so
that buffering does not continue without bound.
Nr^  r_  ra  s   & r8   "test_oversizedChunkSizeLinePartial?ChunkedTransferEncodingTests.test_oversizedChunkSizeLinePartial  sG     ((t4++NND//!34	
r7   c                    \         P                  ! R R 4      pV P                  \         P                  VP                  R4       R# )z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk size can't be decoded as
a base-16 integer.
c                     R # r;   r0   rR  s   &r8   rS  FChunkedTransferEncodingTests.test_malformedChunkSize.<locals>.<lambda>      dr7   c                     R # r;   r0   rR  s   &r8   rS  ri    rj  r7   s   bloop
abc
Nr#   r(  r  rW  r   ra  s   & r8   test_malformedChunkSize4ChunkedTransferEncodingTests.test_malformedChunkSize  s<     ((
 	++Q^^=P	
r7   c                    \         P                  ! R R 4      pV P                  \         P                  VP                  R4       R# )zo
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk size is negative.
c                     R # r;   r0   rR  s   &r8   rS  NChunkedTransferEncodingTests.test_malformedChunkSizeNegative.<locals>.<lambda>  rj  r7   c                     R # r;   r0   rR  s   &r8   rS  rq    rj  r7   s	   -3
abc
Nrl  ra  s   & r8   test_malformedChunkSizeNegative<ChunkedTransferEncodingTests.test_malformedChunkSizeNegative  s<    
 ((
 	++Q^^=M	
r7   c                    \         P                  ! R R 4      pV P                  \         P                  VP                  R4       R# )z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk size is prefixed with
"0x", as if it were a Python integer literal.

This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq.
c                     R # r;   r0   rR  s   &r8   rS  IChunkedTransferEncodingTests.test_malformedChunkSizeHex.<locals>.<lambda>  rj  r7   c                     R # r;   r0   rR  s   &r8   rS  rw    rj  r7   s
   0x3
abc
Nrl  ra  s   & r8   test_malformedChunkSizeHex7ChunkedTransferEncodingTests.test_malformedChunkSizeHex  s<     ((
 	++Q^^=N	
r7   c                    \         P                  ! R R 4      pV P                  \         P                  VP                  R4       R# )z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the chunk is followed by characters
other than C{\r\n}.
c                     R # r;   r0   rR  s   &r8   rS  EChunkedTransferEncodingTests.test_malformedChunkEnd.<locals>.<lambda>  rj  r7   c                     R # r;   r0   rR  s   &r8   rS  r}    rj  r7   s
   3
abc!!!!Nrl  ra  s   & r8   test_malformedChunkEnd3ChunkedTransferEncodingTests.test_malformedChunkEnd  s;     ((
 	++Q^^_	
r7   c                    . p\         P                  ! RVP                  4      pVP                  R4       V P	                  VR.4       R# )z
L{_ChunkedTransferDecoder.dataReceived} interprets a zero-length
chunk as the end of the chunked data stream and calls the completion
callback.
N   0

r7   r'  rK   r  r+  s   &  r8   test_finish(ChunkedTransferEncodingTests.test_finish  s=     ((x?	|$C5)r7   c                    . p\         P                  ! RVP                  4      pVP                  R4       V P	                  VR.4       R# )z
L{_ChunkedTransferDecoder.dataReceived} passes any bytes which come
after the terminating zero-length chunk to the completion callback.
Ns
   0

hello   hellor'  r  s   &  r8   
test_extra'ChunkedTransferEncodingTests.test_extra  s>    
 ((x?	()H:.r7   c                    \         P                  ! RR 4      pVP                  R4       V P                  \        VP                  R4       R# )zr
L{_ChunkedTransferDecoder.dataReceived} raises C{RuntimeError} if it
is called after it has seen the last chunk.
Nc                     R # r;   r0   r  s   &r8   rS  AChunkedTransferEncodingTests.test_afterFinished.<locals>.<lambda>  s    Tr7   r  r  )r#   r(  r   r  r  ra  s   & r8   test_afterFinished/ChunkedTransferEncodingTests.test_afterFinished  s9    
 ((/AB	|$,Ar7   c                    \         P                  ! RR 4      pVP                  R4       V P                  \        VP
                  4      pV P                  \        V4      R4       R# )z
L{_ChunkedTransferDecoder.noMoreData} raises L{_DataLoss} if it is
called and the end of the last trailer has not yet been received.
Nc                     R # r;   r0   r  s   &r8   rS  GChunkedTransferEncodingTests.test_earlyConnectionLose.<locals>.<lambda>      $r7   s   0
zYChunked decoder in 'TRAILER' state, still expecting more data to get to 'FINISHED' state.)r#   r(  r   r  r'   r  rZ   r   )rK   parserexcs   &  r8   r  5ChunkedTransferEncodingTests.test_earlyConnectionLose  sW    
 --d4FGJ'	6+<+<=H*	
r7   c                x    \         P                  ! RR 4      pVP                  R4       VP                  4        R# )z
L{_ChunkedTransferDecoder.noMoreData} does not raise any exception if
it is called after the terminal zero length chunk is received.
Nc                     R # r;   r0   r  s   &r8   rS  JChunkedTransferEncodingTests.test_finishedConnectionLose.<locals>.<lambda>  r  r7   r  )r#   r(  r   r  )rK   r  s   & r8   r  8ChunkedTransferEncodingTests.test_finishedConnectionLose  s1    
 --d4FGL)r7   c                   aaa . o. oVVV3R lp\         P                  ! RV4      oSP                  R4       V P                  S. 4       V P                  SR.4       R# )zn
L{_ChunkedTransferDecoder.noMoreData} can be called from the finished
callback without raising an exception.
c                    <  SP                  4        SP                  R 4       R#   \         d    SP                  \        4       4        R# i ; iTN)r  r^  r  r   )extraerrorsr  	successess   &r8   r  OChunkedTransferEncodingTests.test_reentrantFinishedNoMoreData.<locals>.finished  sC    '!!#   & ! )gi()s   & $AANr  T)r#   r(  r   rZ   )rK   r  r  r  r  s   & @@@r8    test_reentrantFinishedNoMoreData=ChunkedTransferEncodingTests.test_reentrantFinishedNoMoreData  sX    
 		' --dH=L)$TF+r7   c                2   . p. p\         P                  ! VP                  VP                  4      pVP                  R4       VP                  R4       V P	                  V. RO4       V P	                  VR.4       V P	                  VP
                  RR.4       R# )z
L{_ChunkedTransferDecoder.dataReceived} decodes chunked-encoded data
and ignores trailer headers which come after the terminating zero-length
chunk.
r#  s\   a
0123456789
0
Server-Timing: total;dur=123.4
Expires: Wed, 21 Oct 2015 07:28:00 GMT

r7      Server-Timing: total;dur=123.4s&   Expires: Wed, 21 Oct 2015 07:28:00 GMTNr$  )r#   r(  r^  r   rZ   r:  )rK   r*  r  r+  s   &   r8   test_trailerHeaders0ChunkedTransferEncodingTests.test_trailerHeaders  s     ((8??C	45	w	
 	=>C5)19	
r7   c                2   . p. p\         P                  ! VP                  VP                  4      p\        R4       F  pVP	                  V4       K  	  V P                  V. RO4       V P                  VR.4       V P                  VP                  R.4       R# )z
L{_ChunkedTransferDecoder.dataReceived} decodes chunks of input with
tailer header broken up and delivered in multiple calls.
s7   3
abc
5
12345
0
Server-Timing: total;dur=123.4

r7   r  Nr0  r9  r;  s   &    r8   test_shortTrailerHeader4ChunkedTransferEncodingTests.test_shortTrailerHeader*  s    
 ((8??CT
A NN1
 	LMC5)**-N,OPr7   c                    \         P                  ! R R 4      p^
Vn        V P                  \         P                  VP
                  R4       R# )zz
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the trailing headers data is too long.
c                     R # r;   r0   rR  s   &r8   rS  HChunkedTransferEncodingTests.test_tooLongTrailerHeader.<locals>.<lambda>@  rj  r7   c                     R # r;   r0   rR  s   &r8   rS  r  A  rj  r7   s4   3
abc
0
Total-Trailer: header;greater-then=10

N)r#   r(  _maxTrailerHeadersSizer  rW  r   ra  s   & r8   test_tooLongTrailerHeader6ChunkedTransferEncodingTests.test_tooLongTrailerHeader:  sE    
 ((
 $& ++NNM	
r7   c                    \         P                  ! R R 4      p^
Vn        VP                  R4       VP                  R4       V P	                  \         P
                  VP                  R4       R# )z
L{_ChunkedTransferDecoder.dataReceived} raises
L{_MalformedChunkedDataError} when the trailing headers data is too long
and doesn't have final CRLF characters.
c                     R # r;   r0   rR  s   &r8   rS  KChunkedTransferEncodingTests.test_unfinishedTrailerHeader.<locals>.<lambda>Q  rj  r7   c                     R # r;   r0   rR  s   &r8   rS  r  R  rj  r7   s   3
abc
0
01234567      AN)r#   r(  r  r   r  rW  ra  s   & r8   test_unfinishedTrailerHeader9ChunkedTransferEncodingTests.test_unfinishedTrailerHeaderJ  s`     ((
 $&  	
34	u++NN	
r7   r0   N)r1   r2   r3   r4   r5   r,  r=  r@  rD  rH  rK  r[  rb  re  rm  rs  ry  r  r  r  r  r  r  r  r  r  r  r  r6   rO   rP   s   @r8   r!  r!    s     	?0-*'&U,




 
	*/B
,*
.Q 
 
 
r7   r!  c                   J   a  ] tR tRt o . R	OtR tR tR tR
R ltR t	Rt
V tR# )ChunkingTestsia  c                   V P                    FP  pR P                  \        P                  ! V4      4      pV P	                  VR 3\        P
                  ! V4      4       KR  	  V P                  \        \        P
                  R4       V P                  \        \        P
                  R4       V P                  \        \        P
                  R4       R# )r7   s   -5
malformed!
s   0xa
malformed!
s   0XA
malformed!
N)stringsjoinr#   toChunkrZ   	fromChunkr  r  )rK   r<  chunkeds   &  r8   
testChunksChunkingTests.testChunksd  s    Ahht||A/GaXt~~g'>?  	*dnn6MN*dnn6NO*dnn6NOr7   c           
        R P                  V P                   Uu. uF(  pR P                  \        P                  ! V4      4      NK*  	  up4      p. pR p\	        V4       F5  pWE,           p \        P
                  ! V4      w  rdVP                  V4       K7  	  V P                  W0P                  4       R# u upi   \         d     Ki  i ; i)r7   N)	r  r  r#   r  r   r  r^  r  rZ   )rK   rf  r  resultbuffercr   s   &      r8   testConcatenatedChunks$ChunkingTests.testConcatenatedChunksl  s    ((t||L|!CHHT\\!_5|LM7#AZF#~~f5d#	 $ 	. M  s   .B4*)B99CCc                   \        4       p\        P                  ! 4       pVP                  V4       \        P                  ! VR4      pVP                  ^4       RVn        VP                  P                  RR.4       VP                  R4       VP                  R4       V P                  VP                  4       R.4       R# )	zF
Test that the L{HTTPChannel} correctly chunks responses when needed.
Fr     test   lemur   Hello   World!Nr     Test: lemur   Transfer-Encoding: chunkeds   5
Hello
6
World!
)r   r#   r   r   rO  rH   r   r  r  r   r   r   )rK   transr   rV  s   &   r8   test_chunkedResponses#ChunkingTests.test_chunkedResponsesy  s      !""$u%ll7E*C %))'H:>		(		)!!KKM
	
r7   Nc                   \         P                  ! 4       pV'       d   \        V4      Vn        VP	                  RR4      pVP                  R^4      w  rV\        4       pVP                  V4       VP                  VR,           4       \        \        V4      V,          ^,           4       Fl  pVP                  P                  '       d    MOVP                  RP                  \         P                  ! WhV,          V^,           V,           4      4      4       Kn  	  VP                  RP                  \         P                  ! R4      4      4       VP                  \!        R4      4       V# )z
Execute a web request based on plain text content, chunking
the request payload.

This is a stripped-down, chunking version of ParsingTests.runRequest.
ry   rG  r   r7   r   )r#   r   rB   r   replacer   r   r   r   rU   r   r   r   r  r  r   r   )	rK   httpRequestr   	chunkSizer   headerr  r   poss	   &&&&     r8   runChunkedRequestChunkingTests.runChunkedRequest  s    ""$%=n%MG"!))%9"((a8#%	y)Vk12Ti/!34C  ...  d?cAg=R&STU 5 	SXXdll3&789wz23r7   c                D  a . o ! V3R lR\         P                  4      pRpV P                  W!^R7      pV P                  VP                  P                  4       R4       V P                  \        S4      ^4       V P                  S^ ,          P                  RR./4       R# )	z
Test that chunked uploads are actually processed into args.

This is essentially a copy of ParsingTests.test_multipartFormData,
just with chunking put in.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )7ChunkingTests.test_multipartFormData.<locals>.MyRequesti  c                l   < SP                  V 4       V P                  R 4       V P                  4        R# s   doneNr^  r   r   rK   	processeds   &r8   rL   ?ChunkingTests.test_multipartFormData.<locals>.MyRequest.process  &      &

7#r7   r0   Nr   rQ   r  s   @r8   	MyRequestr          r7   r  s   POST / HTTP/1.0
Content-Type: multipart/form-data; boundary=AaB03x
Transfer-Encoding: chunked

--AaB03x
Content-Type: text/plain
Content-Disposition: form-data; name="text"
Content-Transfer-Encoding: quoted-printable

abasdfg
--AaB03x--
)r     HTTP/1.0 200 OK

done   text   abasdfgN)r#   rO  r  rZ   r   r   r   r<   rK   r  rV  r   r  s   &   @r8   test_multipartFormData$ChunkingTests.test_multipartFormData  s     		 	 ((1(E**0024RSY+1**Wzl,CDr7   r0   )s   abcvr7   s   fdfsd423s	   Ffasfas
s   523523
fsdfs   4234)Nr   )r1   r2   r3   r4   r  r  r  r  r  r  r6   rO   rP   s   @r8   r  r  a  s,     UGP/
8@E Er7   r  c                   <  a  ] tR tRt o RtR tR3R ltR tR tR t	R	 t
R
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R  t!R! t"R" t#R# t$R$ t%R% t&R& t'R' t(R( t)R) t*R* t+R+ t,R, t-R- t.R. t/R/ t0R0 t1R1 t2R2t3V t4R# )4ParsingTestsi  z/
Tests for protocol parsing in L{HTTPChannel}.
c                    R V n         R# )FN
didRequestrJ   s   &r8   r  ParsingTests.setUp  s	    r7   Nc                    V'       g   \         P                  ! 4       pV'       d   \        V4      Vn        VP	                  RR4      p\        4       pVP                  V4       \        V4       F2  pVP                  P                  '       d    MVP                  V4       K4  	  VP                  \        R4      4       V'       d   V P                  V P                  4       V# V P                  V P                  4       V# )a  
        Execute a web request based on plain text content.

        @param httpRequest: Content for the request which is processed. Each
            L{"
"} will be replaced with L{"
"}.
        @type httpRequest: C{bytes}

        @param requestFactory: 2-argument callable returning a Request.
        @type requestFactory: C{callable}

        @param success: Value to compare against I{self.didRequest}.
        @type success: C{bool}

        @param channel: Channel instance over which the request is processed.
        @type channel: L{HTTPChannel}

        @return: Returns the channel used for processing the request.
        @rtype: L{HTTPChannel}
        ry   rG  r   )r#   r   rB   r   r  r   r   r   r   r   r   r   r   r   r  r   )rK   r  r   successr   r   r   s   &&&&&  r8   
runRequestParsingTests.runRequest  s    ( &&(G%=n%MG"!))%9#%	y)k*D  ...  & + 	wz23OODOO,  T__-r7   c                N  a RP                  V4      p. o ! V3R lR\        P                  4      pV P                  W#RR7      pV P	                  VP
                  P                  4       R4       V P                  VP
                  P                  4       V P	                  S. 4       R# )a  
Execute a HTTP request and assert that it is rejected with a 400 Bad
Response and disconnection.

@param requestLines: Plain text lines of the request. These lines will
    be joined with newlines to form the HTTP request that is processed.
@type requestLines: C{list} of C{bytes}
ry   c                   .   <a  ] tR tRt o V3R ltRtV tR# )5ParsingTests.assertRequestRejected.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r^  r   r  s   &r8   rL   =ParsingTests.assertRequestRejected.<locals>.MyRequest.process        &r7   r0   Nr   r  s   @r8   r  r          r7   r  Fr  r  N)	r  r#   rO  r  rZ   r   r   r   r   )rK   requestLinesr  r  r   r  s   &&   @r8   assertRequestRejected"ParsingTests.assertRequestRejected
  s     jj.		 	
 //+%/H##%/	
 	))778B'r7   c                .  a . o ! V3R lR\         P                  4      pRpV P                  W!^ 4      pV P                  VP                  P                  4       R4       V P                  VP                  P                  4       V P                  S. 4       R# )zw
When client sends invalid HTTP method containing
non-ascii characters HTTP 400 'Bad Request' status will be returned.
c                   .   <a  ] tR tRt o V3R ltRtV tR# ):ParsingTests.test_invalidMethodNonAscii.<locals>.MyRequesti*  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   BParsingTests.test_invalidMethodNonAscii.<locals>.MyRequest.process+  r   r7   r0   Nr   r  s   @r8   r  r  *  r  r7   r  s   GE© / HTTP/1.1

r  N)r#   rO  r  rZ   r   r   r   r   )rK   r  badRequestLiner   r  s   &   @r8   test_invalidMethodNonAscii'ParsingTests.test_invalidMethodNonAscii#  sy    
 		 	
 ://.Q?**0024WX))778B'r7   c                D    R F  pV P                  VRRRR.4       K  	  R# )z
The three components of the request line must not be
separated by anything other than a single SP character,
or a 400 status results.
   Content-Length: 0   Host: foo.exampler7   N)s   GET  / HTTP/1.0s   GET /  HTTP/1.0s   GET	/ HTTP/1.0s   GET /HTTP/1.1s   GET / HTTP/1.1 s    GET / HTTP/1.1r  )rK   requestLines   & r8   "test_invalidRequestLineExtraSpaces/ParsingTests.test_invalidRequestLineExtraSpaces5  s.    
K &&24H#sS
r7   c                ,    V P                  . RO4       R# )zJ
A request with an empty method field is rejected with a
400 status code.
N)s    /foo HTTP/1.1r  r  r7   r7   r  rJ   s   &r8   test_invalidMethodEmpty$ParsingTests.test_invalidMethodEmptyG      
 	""	
r7   c                ,    V P                  . RO4       R# )z[
A request with a method that contains a NUL character
is rejected with a 400 status code.
N)s   GET  /foo HTTP/1.1r  r  r7   r7   r  rJ   s   &r8   test_invalidMethodNUL"ParsingTests.test_invalidMethodNULV  r  r7   c                ,    V P                  . RO4       R# )zS
A request with an invalid HTTP version number is rejected
with a 400 status code.
N)s   HEAD /foo HTTP/1.2r  r  r7   r7   r  rJ   s   &r8   test_invalidVersion ParsingTests.test_invalidVersione  r  r7   c                ,    V P                  . RO4       R# )R
A request with an empty request-target (URI) is rejected with
a 400 status code.
N)s   POST  HTTP/1.1r  r  r7   r7   r  rJ   s   &r8   test_invalidRequestTargetEmpty+ParsingTests.test_invalidRequestTargetEmptyt  r  r7   c                ,    V P                  . RO4       R# )r   N)s   POST /foo  HTTP/1.1r  r  r7   r7   r  rJ   s   &r8   test_invalidRequestTargetNUL)ParsingTests.test_invalidRequestTargetNUL  r  r7   c                ,    V P                  . RO4       R# )zd
A request with a request-target (URI) that contains whitespace
is rejected with a 400 status code.
N)s   POST /foo	/bar HTTP/1.1r  r  r7   r7   r  rJ   s   &r8   #test_invalidRequestTargetWhitespace0ParsingTests.test_invalidRequestTargetWhitespace  r  r7   c                D  a . o ! V3R lR\         P                  4      pR Fz  w  r#\        P                  ! RP	                  W#34      4      pRV,           R,           pV P                  WQ^ 4       SP                  4       pV P                  W#3VP                  4       K|  	  R# )z
L{HTTPChannel} provides username and password information supplied in
an I{Authorization} header to the L{Request} which makes it available
via its C{getUser} and C{getPassword} methods.
c                   .   <a  ] tR tRt o V3R ltRtV tR# ),ParsingTests.test_basicAuth.<locals>.Requesti  c                t   < V P                  4       V P                  4       3V n        SP                  V 4       R # r;   getUsergetPasswordcredentialsr^  rK   r   s   &r8   rL   4ParsingTests.test_basicAuth.<locals>.Request.process  +    $(LLND4D4D4F#G %r7   r0  Nr   rQ   r   s   @r8   rO  r+         & &r7   rO     :$   GET / HTTP/1.0
Authorization: Basic    

N))r     bar)r  s   there:z)	r#   rO  base64	b64encoder  r  r   rZ   r0  )rK   rO  ur+  r<  frV  r   s   &      @r8   test_basicAuthParsingTests.test_basicAuth  s     	&dll 	&
 ?DA  A6!23A81<wFAOOA*,,.CaVS__5 ?r7   c                J  a . o ! V3R lR\         P                  4      p. R
OpV P                  RP                  V4      V^ 4       Sw  pV P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R4      RR.4       R	# )zW
Headers received by L{HTTPChannel} in a request are made available to
the L{Request}.
c                   .   <a  ] tR tRt o V3R ltRtV tR# ),ParsingTests.test_headers.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   4ParsingTests.test_headers.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  rC    r  r7   r  ry   r  r:  s   bAzs   Quux   quuxN)   GET / HTTP/1.0   Foo: bars	   baz: Quuxs	   baz: quuxr7   r7   r#   rO  r  r  rZ   r  getRawHeadersrK   r  r  r   r  s   &   @r8   test_headersParsingTests.test_headers  s    
 		 	

 	

<0)Q?	//==fExP""0087G:L	
r7   c                  a . o ! V3R lR\         P                  4      p. ROpV P                  RP                  V4      V^ 4       Sw  pV P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R	4      R
.4       R# )a  
Line folded headers are handled by L{HTTPChannel} by replacing each
fold with a single space by the time they are made available to the
L{Request}. Any leading whitespace in the folded lines of the header
value is replaced with a single space, per:

    A server that receives an obs-fold in a request message ... MUST
    ... replace each received obs-fold with one or more SP octets prior
    to interpreting the field value or forwarding the message
    downstream.

See RFC 7230 section 3.2.4.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )5ParsingTests.test_headersMultiline.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   =ParsingTests.test_headersMultiline.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  rP    r  r7   r  ry   s   nospaces   spaces   space space   spacess   spaces spaces spacess   tabs   t a bN)rG  s	   nospace: s	    nospace	s   space:spaces    spaces   spaces: spacess     spacess	      spacess   tab: ts   	as   	br7   r7   rI  rK  s   &   @r8   test_headersMultiline"ParsingTests.test_headersMultiline  s     		 	

  	

<0)Q?	 	""00<L	
 	""00:	
 	""00;$%	
 	""008J	
r7   c                P  a . o ! V3R lR\         P                  4      p. ROpV P                  RP                  V4      V^ 4       Sw  pV P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R4      R.4       V P	                  VP
                  P                  R4      R	.4       V P	                  VP
                  P                  R
4      R.4       V P	                  VP
                  P                  R4      R.4       R# )z
Leading and trailing space and tab characters are stripped from
headers. Other forms of whitespace are preserved.

See RFC 7230 section 3.2.3 and 3.2.4.
c                   .   <a  ] tR tRt o V3R ltRtV tR# ):ParsingTests.test_headerStripWhitespace.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   BParsingTests.test_headerStripWhitespace.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  rX    r  r7   r  ry   rS  s   spaces were strippeds   tabss   tabs were strippeds   spaces-and-tabss   spaces and tabs were strippeds   line-tabs    vertical tab was preserveds	   form-feeds    form feed was preserved N)rG  s!   spaces:   spaces were stripped   s   tabs: 		tabs were stripped		s5   spaces-and-tabs: 	 	 spaces and tabs were stripped	 	s*   line-tab:    vertical tab was preserved	s(   form-feed:  form feed was preserved   r7   r7   rI  rK  s   &   @r8   test_headerStripWhitespace'ParsingTests.test_headerStripWhitespace  s    		 	
	
 	

<0)Q?	 	""00;$%	
 	""009"#	
 	""001CD-.	
 	""00=/0	
 	""00>-.	
r7   c                    R.p\        \        P                  P                  ^,           4       F   pVP	                  \        V R24      4       K"  	  VP                  RR.4       V P                  V4       R# )zm
C{HTTPChannel} enforces a limit of C{HTTPChannel.maxHeaders} on the
number of headers received per request.
rG  z: foor7   N)rU   r#   r   
maxHeadersr^  r   extendr  )rK   r  r[   s   &  r8   test_tooManyHeaders ParsingTests.test_tooManyHeaders=  se    
 **t''22Q67A5k :; 8S#J'""<0r7   c                ,    V P                  . RO4       R# )z
If a I{Content-Length} header with a non-integer value is received,
a 400 (Bad Request) response is sent to the client and the connection
is closed.
N)rG  s   Content-Length: xr7   r7   r  rJ   s   &r8   test_invalidContentLengthHeader,ParsingTests.test_invalidContentLengthHeaderI       	""	
r7   c                ,    V P                  . RO4       R# )zx
If a header without colon is received a 400 (Bad Request) response
is sent to the client and the connection is closed.
N)rG  s   HeaderName r7   r7   r  rJ   s   &r8   test_invalidHeaderNoColon&ParsingTests.test_invalidHeaderNoColonX  s    
 	""	
r7   c                ,    V P                  . RO4       R# )z
C{HTTPChannel} rejects a request with an empty header name (i.e.
nothing before the colon).  It produces a 400 (Bad Request) response
and closes the connection.
N)rG  s   : foor7   r7   r  rJ   s   &r8   test_invalidHeaderOnlyColon(ParsingTests.test_invalidHeaderOnlyColonf  re  r7   c                ,    V P                  . RO4       R# )z
C{HTTPChannel} rejects a request containing a header with whitespace
between the header name and colon as requried by RFC 7230 section
3.2.4. A 400 (Bad Request) response is generated and the connection
closed.
N)rG  s   HeaderName : foor7   r7   r  rJ   s   &r8   'test_invalidHeaderWhitespaceBeforeColon4ParsingTests.test_invalidHeaderWhitespaceBeforeColonu  s     	""	
r7   c                D    R F  pV P                  RRVRR.4       K  	  R# )zc
A request with a header name that contains invalid characters
is rejected with a 400 status code.
   GET / HTTP/1.1r  r7   N)s   foo bar: bazs   foobar: bazs   FooBar: bazs   Foo Bar: bazs   foo‽bar: bazr  rK   r  s   & r8   test_invalidHeaderNameChars(ParsingTests.test_invalidHeaderNameChars  s-    

F &&"$8&#sK
r7   c                D    R F  pV P                  RRVRR.4       K  	  R# )z\
A request with a header value that contains a NUL byte
is rejected with a 400 status code.
rp  r  r7   N)s   x-foo:  s	   x-foo: a s   x-foo:  bazs   x-foo:     x0  r  rq  s   & r8   test_invalidHeaderValueNUL'ParsingTests.test_invalidHeaderValueNUL  s-    

F &&"$8&#sK
r7   c                  a . o ! V3R lR\         P                  4      pV P                  \         P                  R^4       . R
OpV P	                  RP                  V4      V^ 4      pSw  rEV P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  VP                  P                  4       R4       R	# )z
C{HTTPChannel} enforces the limit of C{HTTPChannel.maxHeaders} per
request so that headers received in an earlier request do not count
towards the limit when processing a later request.
c                   .   <a  ] tR tRt o V3R ltRtV tR# ):ParsingTests.test_headerLimitPerRequest.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   BParsingTests.test_headerLimitPerRequest.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  ry    r  r7   r  r^  ry   r  r:     bazh   HTTP/1.1 200 OK
Transfer-Encoding: chunked

0

HTTP/1.1 200 OK
Transfer-Encoding: chunked

0

N)rp  rH  r7   r7   rp  s   Bar: bazr7   r7   )
r#   rO  patchr   r  r  rZ   r~   r   r   )rK   r  r  r   firstsecondr  s   &     @r8   test_headerLimitPerRequest'ParsingTests.test_headerLimitPerRequest  s     		 	
 	

4##\15	
 //%**\":IqI#0&9))&16:##%		
r7   c                "  a . o ! V3R lR\         P                  4      p\         P                  ! 4       p^
Vn        RpV P	                  VVVRR7      pV P                  S. 4       V P                  VP                  P                  4       R4       R# )z
Enforces a limit of C{HTTPChannel.totalHeadersSize}
on the size of headers received per request starting from initial
command line.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )@ParsingTests.test_headersTooBigInitialCommand.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   HParsingTests.test_headersTooBigInitialCommand.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  r    r  r7   r  s"   GET /path/longer/than/10 HTTP/1.1
Fr  r   r   r  r  Nr#   rO  r   totalHeadersSizer  rZ   r   r   rK   r  r   r  r  s   &   @r8    test_headersTooBigInitialCommand-ParsingTests.test_headersTooBigInitialCommand  s     		 	
 ""$#% <//#$	 " 
 	B'**0024WXr7   c                "  a . o ! V3R lR\         P                  4      p\         P                  ! 4       p^(Vn        RpV P	                  VVVRR7      pV P                  S. 4       V P                  VP                  P                  4       R4       R# )z
Enforces a limit of C{HTTPChannel.totalHeadersSize}
on the size of headers received per request counting first line
and total headers.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )>ParsingTests.test_headersTooBigOtherHeaders.<locals>.MyRequesti  c                J   < SP                  V 4       V P                  4        R # r;   r  r  s   &r8   rL   FParsingTests.test_headersTooBigOtherHeaders.<locals>.MyRequest.process  r   r7   r0   Nr   r  s   @r8   r  r    r  r7   r  s5   GET /less/than/40 HTTP/1.1
Some-Header: less-than-40
Fr  r  Nr  r  s   &   @r8   test_headersTooBigOtherHeaders+ParsingTests.test_headersTooBigOtherHeaders  s     		 	
 ""$#% T//#$	 " 
 	B'**0024WXr7   c                     ! R R\         P                  4      p\         P                  ! 4       p^<Vn        Wn        RpV P                  W2RR7      pV P                  VP                  P                  4       R4       R# )zh
Enforces total size of headers per individual request and counter
is reset at the end of each request.
c                   &   a  ] tR tRt o R tRtV tR# )@ParsingTests.test_headersTooBigPerRequest.<locals>.SimpleRequesti	  c                &    V P                  4        R # r;   )r   rJ   s   &r8   rL   HParsingTests.test_headersTooBigPerRequest.<locals>.SimpleRequest.process	  s    r7   r0   Nr   rP   s   @r8   SimpleRequestr  	  s      r7   r  sZ   GET / HTTP/1.1
Some-Header: total-less-than-60

GET / HTTP/1.1
Some-Header: less-than-60

F)r  r   r  r}  N)	r#   rO  r   r  r   r  rZ   r   r   )rK   r  r   r  s   &   r8   test_headersTooBigPerRequest)ParsingTests.test_headersTooBigPerRequest	  s{    	DLL 	 ""$#% !. 	 //#e " 
 	##%		
r7   c           	        aa Rp/ oV o ! VV3R lR\         P                  4      pV P                  W4       V P                  SRRRRRR	/4       R
# )z#
Test cookies parsing and reading.
sK   GET / HTTP/1.0
Cookie: rabbit="eat carrot"; ninja=secret; spam="hey 1=1!"

c                   0   <a  ] tR tRt o VV3R ltRtV tR# )+ParsingTests.testCookies.<locals>.MyRequesti9	  c                p   < R F  pV P                  V4      SV&   K  	  RSn        V P                  4        R# )   rabbitTN)r     ninja   spam)	getCookier  r   )rK   namecookiestestcases   & r8   rL   3ParsingTests.testCookies.<locals>.MyRequest.process:	  s0    :D$(NN4$8GDM ;&*#r7   r0   Nr   )rQ   r  r  s   @r8   r  r  9	  s      r7   r  r  s   "eat carrot"r  s   secretr  s
   "hey 1=1!"Nr#   rO  r  rZ   )rK   r  r  r  r  s   &  @@r8   testCookiesParsingTests.testCookies-	  sZ    
 	 	 	 	/9g}U	
r7   c                   aaa R p. o. oV o ! VVV3R lR\         P                  4      pV P                  W4       V P                  SR.4       V P                  SR.R.RR..4       R# )	sJ   GET /?key=value&multiple=two+words&multiple=more%20words&empty= HTTP/1.0

c                   2   <a  ] tR tRt o VVV3R ltRtV tR# )'ParsingTests.testGET.<locals>.MyRequestiP	  c                   < SP                  V P                  4       SP                  V P                  R ,          V P                  R,          V P                  R,          .4       RSn        V P                  4        R# s   keys   emptys   multipleTN)r^  r   r_  r<   r  r   )rK   r<   r   r  s   &r8   rL   /ParsingTests.testGET.<locals>.MyRequest.processQ	  sW    dkk*YYv&		((;TYY{=ST '+#r7   r0   Nr   )rQ   r<   r   r  s   @r8   r  r  P	  s      r7   r  r      valuer7   	   two words
   more wordsNr  )rK   r  r  r<   r   r  s   &  @@@r8   testGETParsingTests.testGETG	  sp     	 	 	 	/&*
SEL-3PQRr7   c                   aaaa Rp. o. o. oV o ! VVVV3R lR\         P                  4      pV P                  W4       V P                  SR.4       V P                  SR.4       V P                  SR.R..4       R# )	z
While only a single '?' is allowed in an URL, several other servers
allow several and pass all after the first through as part of the
query arguments.  Test that we emulate this behavior.
s"   GET /foo?bar=?&baz=quux HTTP/1.0

c                   4   <a  ] tR tRt o VVVV3R ltRtV tR# )6ParsingTests.test_extraQuestionMark.<locals>.MyRequestij	  c                  < SP                  V P                  4       SP                  V P                  4       SP                  V P                  R ,          V P                  R,          .4       RSn        V P                  4        R# )r:  r|  TN)r^  r   pathr_  r<   r  r   )rK   r<   r   r  r  s   &r8   rL   >ParsingTests.test_extraQuestionMark.<locals>.MyRequest.processk	  sW    dkk*DII&TYYv.		&0ABC&*#r7   r0   Nr   )rQ   r<   r   r  r  s   @r8   r  r  j	  s      r7   r  r   s   /foo   ?rF  Nr  )rK   r  r  r<   r   r  r  s   &  @@@@r8   test_extraQuestionMark#ParsingTests.test_extraQuestionMark]	  s~     >	 	 	 	/&*y)	23r7   c                L  aaaa Rp\        R\        V4      V3,          4      p. o. o. oV o ! VVVV3R lR\        P                  4      pV P	                  W#4       V P                  SR.4       V P                  SR.R.RR	..4       V P                  S\        V4      .4       R
# )a-  
The request body of a I{POST} request with a I{Content-Type} header
of I{application/x-www-form-urlencoded} is parsed according to that
content type and made available in the C{args} attribute of the
request object.  The original bytes of the request may still be read
from the C{content} attribute.
z9key=value&multiple=two+words&multiple=more%20words&empty=zVPOST / HTTP/1.0
Content-Length: %d
Content-Type: application/x-www-form-urlencoded

%sc                   4   <a  ] tR tRt o VVVV3R ltRtV tR# )4ParsingTests.test_formPOSTRequest.<locals>.MyRequesti	  c                L  < SP                  V P                  4       SP                  V P                  R ,          V P                  R,          V P                  R,          .4       SP                  V P                  P                  4       4       RSn        V P                  4        R# r  )r^  r   r_  r<   r{   r}   r  r   )rK   r<   r{   r   r  s   &r8   rL   <ParsingTests.test_formPOSTRequest.<locals>.MyRequest.process	  sp    dkk*YYv&		((;TYY{=ST t||0023&*#r7   r0   Nr   )rQ   r<   r{   r   r  s   @r8   r  r  	  s      r7   r  s   POSTr  r7   r  r  N)r   r   r#   rO  r  rZ   )rK   queryr  r  r<   r{   r   r  s   &   @@@@r8   test_formPOSTRequest!ParsingTests.test_formPOSTRequestw	  s     L# 5z5!"
 	 	 	 	/'+
SEL-3PQR 	=#7"89r7   c                    RpV P                  V\        P                  RR7      pV P                  VP                  P                  4       R4       R# )zH
When the multipart processing fails the client gets a 400 Bad Request.
s  POST / HTTP/1.0
Content-Type: multipart/form-data; boundary=☃
Content-Length: 103

--☃
Content-Type: text/plain
Content-Length: 999999999999999999999999999999999999999999999999999999999999999
Content-Transfer-Encoding: quoted-printable

abasdfg
--☃--
Fr  r  N)r  r#   rO  rZ   r   r   )rK   rV  r   s   &  r8   test_multipartProcessingFailure,ParsingTests.test_multipartProcessingFailure	  sC     //#t||U/C**0024WXr7   c                  a . o ! V3R lR\         P                  4      pRpV P                  W!RR7      pV P                  VP                  P                  4       R4       V P                  S^ ,          P                  / 4       R# )zC
When the multipart does not contain a header is should be skipped
c                   .   <a  ] tR tRt o V3R ltRtV tR# )JParsingTests.test_multipartEmptyHeaderProcessingFailure.<locals>.MyRequesti	  c                l   < SP                  V 4       V P                  R 4       V P                  4        R# r  r  r  s   &r8   rL   RParsingTests.test_multipartEmptyHeaderProcessingFailure.<locals>.MyRequest.process	  r  r7   r0   Nr   r  s   @r8   r  r  	  r  r7   r  sr   POST / HTTP/1.0
Content-Type: multipart/form-data; boundary=AaBb1313
Content-Length: 14

--AaBb1313

--AaBb1313--
Fr  r  N)r#   rO  r  rZ   r   r   r<   r  s   &   @r8   *test_multipartEmptyHeaderProcessingFailure7ParsingTests.test_multipartEmptyHeaderProcessingFailure	  so     		 	 //#%/@**0024RS1**B/r7   c                R  a . o ! V3R lR\         P                  4      pRpV P                  W!RR7      pV P                  VP                  P                  4       R4       V P                  \        S4      ^4       V P                  S^ ,          P                  RR./4       V P                  V\        VRR	7      RR7      pV P                  VP                  P                  4       R4       V P                  \        S4      ^4       V P                  S^,          P                  / 4       R
# )z
If the request has a Content-Type of C{multipart/form-data}, and the
form data is parseable, the form arguments will be added to the
request's args.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )6ParsingTests.test_multipartFormData.<locals>.MyRequesti	  c                l   < SP                  V 4       V P                  R 4       V P                  4        R# r  r  r  s   &r8   rL   >ParsingTests.test_multipartFormData.<locals>.MyRequest.process	  r  r7   r0   Nr   r  s   @r8   r  r  	  r  r7   r  s   POST / HTTP/1.0
Content-Type: multipart/form-data; boundary=AaB03x
Content-Length: 149

--AaB03x
Content-Type: text/plain
Content-Disposition: form-data; name="text"
Content-Transfer-Encoding: quoted-printable

abasdfg
--AaB03x--
Fr  r  r  r  parsePOSTFormSubmissionN)	r#   rO  r  rZ   r   r   r   r<   r   r  s   &   @r8   r  #ParsingTests.test_multipartFormData	  s     		 	 //#%/@**0024RSY+1**Wzl,CD //EBE " 
 	**0024RSY+1**B/r7   c           	       a . o ! V3R lR\         P                  4      pRpR\        \        VP	                  RR4      4      4      ,           R,           pV P                  VP                  R4      V,           VR	R
7      pV P                  VP                  P                  4       R4       V P                  \        S4      ^4       V P                  S^ ,          P                  RRR./4       V P                  VP                  R4      V,           \        VR	R7      R	R
7      pV P                  VP                  P                  4       R4       V P                  \        S4      ^4       V P                  S^,          P                  / 4       R# )z
If the request has a Content-Type of C{multipart/form-data}, the
C{Request} is told to parse the body, if the form data is parseable
and contains files, each of the file portions will be added to the
request's args in the same order.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )7ParsingTests.test_multipartFilesData.<locals>.MyRequesti
  c                l   < SP                  V 4       V P                  R 4       V P                  4        R# r  r  r  s   &r8   rL   ?ParsingTests.test_multipartFilesData.<locals>.MyRequest.process
  r  r7   r0   Nr   r  s   @r8   r  r  
  r  r7   r  ss  -----------------------------738837029596785559389649595
Content-Disposition: form-data; name="uploadedfiles"; filename="testC"
Content-Type: application/octet-stream

abasdfg
-----------------------------738837029596785559389649595
Content-Disposition: form-data; name="uploadedfiles"; filename="testB"

qwerty
-----------------------------738837029596785559389649595--
zPOST / HTTP/1.0
Content-Type: multipart/form-data; boundary=---------------------------738837029596785559389649595
Content-Length: ry   rG  z


asciiFr  r  s   uploadedfilesr  s   qwertyr  N)r#   rO  r   r   r  r  r   rZ   r   r   r<   r   )rK   r  r  rV  r   r  s   &    @r8   test_multipartFilesData$ParsingTests.test_multipartFilesData	  sU    		 	
 #dll5'234	5
 	 //#**W"5"<iQV/W**0024RSY+1**-=
I?V,WX //JJw$&Iu= " 

 	**0024RSY+1**B/r7   c                  aaaaa Rp. o. o. o. oV o ! VVVVV3R lR\         P                  4      pV P                  W4       V P                  S^ ,          P                  4       \        V S^ ,          4       V P                  S^,          R4       V P                  SR.4       V P                  SR.4       V P                  SR.4       R# )z
If a request uses the I{chunked} transfer encoding, the request body is
decoded accordingly before it is made available on the request.
sh   GET / HTTP/1.0
Content-Type: text/plain
Transfer-Encoding: chunked

6
Hello,
14
 spam,eggs spam spam
0

c                   6   <a  ] tR tRt o VVVVV3R ltRtV tR# )4ParsingTests.test_chunkedEncoding.<locals>.MyRequestiE
  c                  < SP                  V P                  4       SP                  V P                  P                  4       4       \        4       V n        SP                  V P                  4       SP                  V P
                  4       SP                  V P                  P                  4       R Sn        V P                  4        R# r  )
r^  r{   r}   r   r   r  r   _transferDecoderr  r   )rK   r{   r  r   r  r  s   &r8   rL   <ParsingTests.test_chunkedEncoding.<locals>.MyRequest.processF
  s~    t||,t||0023  'ydkk*DII&t||<<=&*#r7   )r{   Nr   )rQ   r{   r  r   r  r  s   @r8   r  r  E
  s     
 
r7   r  s   Hello, spam,eggs spam spamr      /N)r#   rO  r  
addCleanupcloser-   rZ   )rK   r  r  r{   r  r   r  r  s   &  @@@@@r8   test_chunkedEncoding!ParsingTests.test_chunkedEncoding.
  s    
 	 	 	 	/ 	
(()#D'!*5%BC&*v&4&)r7   c                0  a Rp. o ! V3R lR\         P                  4      pV P                  WRR7      pV P                  SR4       V P	                  VP
                  P                  4       R4       V P                  VP
                  P                  4       R# )	z
If a request uses the I{chunked} transfer encoding, but provides an
invalid chunk length value, the request fails with a 400 error.
s   GET / HTTP/1.1
Content-Type: text/plain
Transfer-Encoding: chunked

MALFORMED_LINE_THIS_SHOULD_BE_'6'
Hello,
14
 spam,eggs spam spam
0

c                   .   <a  ] tR tRt o V3R ltRtV tR# )=ParsingTests.test_malformedChunkedEncoding.<locals>.MyRequestir
  c                *   < SP                  R 4       R# r  r^  )rK   r  s   &r8   rL   EParsingTests.test_malformedChunkedEncoding.<locals>.MyRequest.processs
  s    !!$'r7   r0   Nr   )rQ   r  s   @r8   r  r  r
  s     ( (r7   r  Fr  zRequest.process calledr  N)	r#   rO  r  r   rZ   r   r   r   r   )rK   r  r  r   r  s   &   @r8   test_malformedChunkedEncoding*ParsingTests.test_malformedChunkedEncoding^
  s~     
	( 	(
 //+%/H%=>**0024WX))778r7   c                ^  a	 \         P                  ! V \        4      p. o	 ! V	3R lR\        P                  4      pRpRp\
        P                  ! RP                  W434      4      pRV,           R,           pV P                  \
        RR	 4       V P                  Wb^ 4       S	P                  4       pV P                  RVP                  4       V P                  ^\        V4      4       V^ ,          pVR
,          pV P                  VP                   \"        4       V P%                  \"        4       R# )z}
A L{Request} that throws an exception processing basic authorization
logs an error and uses an empty username and password.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )5ParsingTests.test_basicAuthException.<locals>.Requesti
  c                t   < V P                  4       V P                  4       3V n        SP                  V 4       R # r;   r-  r1  s   &r8   rL   =ParsingTests.test_basicAuthException.<locals>.Request.process
  r3  r7   r4  Nr   r5  s   @r8   rO  r  
  r6  r7   rO  r  r:  r7  r8  r9  	b64decodec                     . # r;   r0   )r>  s   &r8   rS  6ParsingTests.test_basicAuthException.<locals>.<lambda>
  s    "r7   log_failureN)r7   r7   )r   r   r   r#   rO  r;  r<  r  r~  r  r   rZ   r0  r   r   assertIsInstancer   AttributeErrorflushLoggedErrors)
rK   r   rO  r=  r+  r<  r>  rV  r   r   s
   &        @r8   test_basicAuthException$ParsingTests.test_basicAuthException|
  s    
 +<<TCUV	&dll 	&
 TYYv./4q87B

6;5A&llnS__5!S-.A- agg~6~.r7   c                ,    V P                  . RO4       R# )z{
A request which includes multiple C{content-length} headers
fails with a 400 response without calling L{Request.process}.
N)   GET /a HTTP/1.1   Content-Length: 56r     Host: host.invalidr7   r7   r  rJ   s   &r8   test_duplicateContentLengths)ParsingTests.test_duplicateContentLengths
  s    
 	""		
r7   c           	     B    V P                  RRRRRRR,          .4       R# )zu
A request with a non-integer C{Content-Length} header fails with a 400
response without calling L{Request.process}.
r  s(   Content-Length: MORE THAN NINE THOUSAND!r  r7   r   i)#  Nr  rJ   s   &r8   test_contentLengthMalformed(ParsingTests.test_contentLengthMalformed
  s-    
 	""";%t		
r7   c                ,    V P                  . RO4       R# )z
A request with a C{Content-Length} header that begins with a L{+} fails
with a 400 response without calling L{Request.process}.

This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq.
N)r  s   Content-Length: +100r  r7   r7   sd   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr  rJ   s   &r8   test_contentLengthTooPositive*ParsingTests.test_contentLengthTooPositive
       	""		
r7   c                ,    V P                  . RO4       R# )z
A request with a C{Content-Length} header that is negative fails with
a 400 response without calling L{Request.process}.

This is a potential request smuggling vector: see GHSA-c2jg-hw38-jrqq.
N)r  s   Content-Length: -100r  r7   r7   s   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr  rJ   s   &r8   test_contentLengthNegative'ParsingTests.test_contentLengthNegative
  r  r7   c                ,    V P                  . RO4       R# )z
Two pipelined requests, the first of which includes multiple
C{content-length} headers, trigger a 400 response without
calling L{Request.process}.
N)
r  r  r  r  r7   r7   r  r  r7   r7   r  rJ   s   &r8   1test_duplicateContentLengthsWithPipelinedRequests>ParsingTests.test_duplicateContentLengthsWithPipelinedRequests
       	""	
r7   c                ,    V P                  . RO4       R# )z
A request that includes both C{content-length} and
C{transfer-encoding} headers fails with a 400 response without
calling L{Request.process}.
N)r  r  r  r  r7   r7   r  rJ   s   &r8   %test_contentLengthAndTransferEncoding2ParsingTests.test_contentLengthAndTransferEncoding
  s     	""		
r7   c                ,    V P                  . RO4       R# )z
Two pipelined requests, the first of which includes both
C{content-length} and C{transfer-encoding} headers, triggers a
400 response without calling L{Request.process}.
N)
r  r  r  r  r7   r7   r  r  r7   r7   r  rJ   s   &r8   :test_contentLengthAndTransferEncodingWithPipelinedRequestsGParsingTests.test_contentLengthAndTransferEncodingWithPipelinedRequests  r  r7   c                ,    V P                  . RO4       R# )z
A request whose C{transfer-encoding} header includes a value
other than C{chunked} or C{identity} fails with a 400 response
without calling L{Request.process}.
N)r  s   Transfer-Encoding: unknownr  r7   r7   r  rJ   s   &r8   test_unknownTransferEncoding)ParsingTests.test_unknownTransferEncoding  s     	""	
r7   c                   a . o ! V3R lR\         P                  4      pRpV P                  W!R4      pV P                  SR.4       V P                  VP                  P                  4       R4       R# )zj
A request with a valid C{content-length} and a
C{transfer-encoding} whose value is C{identity} succeeds.
c                   2   <a  ] tR tRt o RtV3R ltRtV tR# )EParsingTests.test_transferEncodingIdentity.<locals>.SuccessfulRequesti-  Fc                   < SP                  V P                  P                  4       4       V P                  R R4       V P	                  4        R# )rx      0N)r^  r{   r}   r   r   )rK   r  s   &r8   rL   MParsingTests.test_transferEncodingIdentity.<locals>.SuccessfulRequest.process0  s4    DLL--/00$7r7   r0   N)r1   r2   r3   r4   r  rL   r6   rO   )rQ   r  s   @r8   SuccessfulRequestr"  -  s     I r7   r&  sT   GET / HTTP/1.1
Host: host.invalid
Content-Length: 2
Transfer-Encoding: identity

ok
Fs   oks&   HTTP/1.1 200 OK
Content-Length: 0

N)r#   rO  r  rZ   r   r   )rK   r&  r   r   r  s   &   @r8   test_transferEncodingIdentity*ParsingTests.test_transferEncodingIdentity&  sh    
 	 	 //'eDw'##%;	
r7   r  )NTN)5r1   r2   r3   r4   r5   r  r  r  r  r  r  r  r  r!  r$  r'  r?  rL  rT  r[  r`  rc  rg  rj  rm  rr  ru  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r  r  r'  r6   rO   rP   s   @r8   r  r    s     )V(2($$





6(
88
t0
d
1



  )
VY6Y6&
P
4S,44':RY,06&0P30j.*`9</6
 
 
$
$
*
"
*
 
 
r7   r  c                   ,   a  ] tR tRt o R tR tRtV tR# )QueryArgumentsTestsiE  c                *  a  R pV 3R lp\        4        V! 4        F  pV! VR4       V! VR4       K  	  \        4        V! 4        F  pV! VR4       V! VR4       K  	  V! 4        F)  p\        4        V! VR4       \        4        V! VR4       K+  	  R# )z
For a given URL, L{http.urlparse} should behave the same as L{urlparse},
except it should always return C{bytes}, never text.
c               3      "   R FW  p R FN  pR FE  pR F<  pVf   K	  VR,           \        \        V4      4      ,           p\        WVRR34      x  K>  	  KG  	  KP  	  KY  	  R# 5i)   httpNr7   r7  )r-  s   https)   example.com)Nd   )r7   s   path)r   r   r   )schemehostportr  s       r8   urls/QueryArgumentsTests.test_urlparse.<locals>.urlsL  s^     --D +$2D#/'+d{]3t95M'M&0&c31O&P P %3 !, . .s   A"AA"c                  < T pV'       d   V P                  R4      p\        V4      p\        VP                  \        4      '       d   VP                  P                  R4      VP                  P                  R4      VP                  P                  R4      VP                  P                  R4      VP                  P                  R4      VP                  P                  R4      3pMDVP                  VP                  VP                  VP                  VP                  VP                  3p\        P                  ! V 4      w  rVrxrSP                  WVWxW3V4       SP                  V\        4       SP                  V\        4       SP                  V\        4       SP                  V\        4       SP                  V	\        4       SP                  V
\        4       R# )z^
Verify that C{url} is parsed into the same objects by both
L{http.urlparse} and L{urlparse}.
r  zutf-8N)decoder   
isinstancer0  r   r   netlocr  paramsr  fragmentr#   rZ   r  r  )urlr6  urlToStandardImplementationstandardResultr   r0  r8  r  r9  r  r:  rK   s   &&         r8   assertSameParsing<QueryArgumentsTests.test_urlparse.<locals>.assertSameParsingU  s   
 +.'.1jj.A+
 &&ABN.//55 #))009"))009"''..w7"))009"((//8"++227; #))"))"''"))"(("++ =AMM#<N9FD%fdELhW!!&%0!!&%0!!$.!!&%0!!%/!!(E2r7   TFNr	   )rK   r3  r>  r;  s   f   r8   test_urlparse!QueryArgumentsTests.test_urlparseF  s    	Q)	3X 	6Cc4(c5) 
 	6Cc5)c4( 
 6CMc4(Mc5)	 r7   c                P    V P                  \        \        P                  R4       R# )z5
L{http.urlparse} should reject unicode input early.
zhttp://example.org/pathN)r  	TypeErrorr#   r   rJ   s   &r8   test_urlparseRejectsUnicode/QueryArgumentsTests.test_urlparseRejectsUnicode  s     	)T]]4MNr7   r0   N)r1   r2   r3   r4   r@  rD  r6   rO   rP   s   @r8   r*  r*  E  s     K*ZO Or7   r*  c                   &   a  ] tR tRt o R tRtV tR# )ClientDriveri  c                *    Wn         W n        W0n        R # r;   )r  r   r  r  s   &&&&r8   r  ClientDriver.handleStatus  s    r7   )r  r   r  N)r1   r2   r3   r4   r  r6   rO   rP   s   @r8   rG  rG    s      r7   rG  c                   2   a  ] tR tRt o R tR tR tRtV tR# )ClientStatusParsingTestsi  c                    \        4       pVP                  R 4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP
                  R4       R# )s   HTTP/1.0 201 foor     201r  NrG  lineReceivedrZ   r  r   r  rK   r  s   & r8   testBaseline%ClientStatusParsingTests.testBaseline  sR    N	*+K06*F+r7   c                    \        4       pVP                  R 4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP
                  R4       R# )   HTTP/1.0 201r  rM  r7   NrN  rP  s   & r8   testNoMessage&ClientStatusParsingTests.testNoMessage  sQ    N	'K06*C(r7   c                    \        4       pVP                  R 4       V P                  VP                  R4       V P                  VP                  R4       V P                  VP
                  R4       R# )s   HTTP/1.0 201 r  rM  r7   NrN  rP  s   & r8   testNoMessage_trailingSpace4ClientStatusParsingTests.testNoMessage_trailingSpace  sR    N	'(K06*C(r7   r0   N)	r1   r2   r3   r4   rQ  rU  rX  r6   rO   rP   s   @r8   rK  rK    s     ,)) )r7   rK  c                     a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R& t(R' t)R( t*R) t+R* t,R+ t-R, t.R- t/R. t0R/ t1R0 t2R1 t3R2 t4R3 t5R4 t6R5 t7R6 t8R7 t9R8 t:R9 t;R: t<R; t=R< t>R= t?R> t@R? tAV 3R@ lRA ltBV 3RB lRC ltCRD tDRE tERF tFRG tGRH tHRI tIRJ tJRK tKRL tLRM tMRN tNRO tORP tPRQtQV tRRR# )SRequestTestsi  z
Tests for L{http.Request}
c                   \         P                  ! \        4       R4      p\        W24      P	                  RR.4       V P                  \        W14      R,          R4       \        W1RR/4       V P                  \        \        W24      P                  4       4      RR.3.4       \        W2\        P                  ! 4       4       V P                  \        W14      / 4       R# )a  
Verify that each of two different attributes which are associated with
the same state properly reflect changes made through the other.

This is used to test that the C{headers}/C{responseHeaders} and
C{received_headers}/C{requestHeaders} pairs interact properly.
Fr  r  r  r:  r  N)r#   rO  r)   getattrr  rZ   setattrr  r  r$   Headers)rK   oldNamenewNamerV  s   &&& r8   _compatHeadersTestRequestTests._compatHeadersTest  s     ll<>51++GhZ@.w7Bvv./&779:fvh=O<P	
 	l2245.3r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       V P                  VP                  R4      R4       R# )zJ
L{http.Request.getHeader} returns the value of the named request
header.
Fr  r  Nr#   rO  r)   r  r  rZ   r~   rK   rV  s   & r8   test_getHeaderRequestTests.test_getHeader  sG    
 ll<>51((8*=w/:r7   c                   a a \         P                  ! \        4       R4      oVV 3R lpV! RR4       V! RR4       V! RR4       V! RR4       V! RR4       V! R	R
4       V! RR4       V! RR4       V! RR4       R# )zo
L{http.Request.getRequestHostname} returns the hostname portion of the
request, based on the C{Host:} header.
Fc                    < SP                   P                  R V .4       SP                  SP                  4       V4       R# )   hostN)r  r  rZ   getRequestHostname)r  expectedHostrV  rK   s   &&r8   check3RequestTests.test_getRequestHostname.<locals>.check  s4    ,,Wvh?S335|Dr7   r.  s   example.com:8443s   192.168.1.1s   192.168.1.1:19289s   [2607:f0d0:1002:51::4]s   2607:f0d0:1002:51::4s)   [2607:f0d0:1002:0051:0000:0000:0000:0004]s'   2607:f0d0:1002:0051:0000:0000:0000:0004s   [::1]s   ::1s
   [::1]:8080s   [2607:f0d0:1002:51::4]:9443N)r#   rO  r)   )rK   rn  rV  s   f @r8   test_getRequestHostname$RequestTests.test_getRequestHostname  s    
 ll<>51	E 	nn-!>2nn-"N3')@A86	
 	hmV$,.EFr7   c                    \         P                  ! \        4       R4      pVP                  P	                  RRR.4       V P                  VP                  R4      R4       R# )zo
When there are multiple values for a single request header,
L{http.Request.getHeader} returns the last value.
Fr  r     pandaNre  rf  s   & r8   test_getHeaderReceivedMultiples,RequestTests.test_getHeaderReceivedMultiples  sJ    
 ll<>51((8X2FGw/:r7   c                    \         P                  ! \        4       R4      pV P                  VP	                  R4      R4       R# )zn
L{http.Request.getHeader} returns L{None} when asked for the value of a
request header which is not present.
Fr  N)r#   rO  r)   rZ   r~   rf  s   & r8   test_getHeaderNotFound#RequestTests.test_getHeaderNotFound  s/    
 ll<>51w/6r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       V P                  VP                  4       RR/4       R# )zq
L{http.Request.getAllheaders} returns a C{dict} mapping all request
header names to their corresponding values.
Fr  r  Nr#   rO  r)   r  r  rZ   getAllHeadersrf  s   & r8   test_getAllHeadersRequestTests.test_getAllHeaders  sL    
 ll<>51((8*=**,w.ABr7   c                    \         P                  ! \        4       R4      pV P                  VP	                  4       / 4       R# )zY
L{http.Request.getAllHeaders} returns an empty C{dict} if there are no
request headers.
FN)r#   rO  r)   rZ   r{  rf  s   & r8   test_getAllHeadersNoHeaders(RequestTests.test_getAllHeadersNoHeaders
  s/    
 ll<>51**,b1r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RRR.4       V P                  VP                  4       RR/4       R# )zx
When there are multiple values for a single request header,
L{http.Request.getAllHeaders} returns only the last value.
Fr  r  rs  Nrz  rf  s   & r8   !test_getAllHeadersMultipleHeaders.RequestTests.test_getAllHeadersMultipleHeaders  sO    
 ll<>51((8X2FG**,w.ABr7   c                   \        4       p\        P                  ! VR4      pVP                  ^4       VP	                  R4       V P                  VP                  P                  P                  4       P                  4       ^ ,          R4       R# )zf
L{http.Request.setResponseCode} takes a status code and causes it to be
used as the response status.
Fr7   s    (no clientproto yet) 201 CreatedN
r)   r#   rO  rH   r   rZ   r   writtengetvaluer   rK   r   rV  s   &  r8   test_setResponseCode!RequestTests.test_setResponseCode  sk    
 .ll7E*C 		#%%..0;;=a@/	
r7   c                    \        4       p\        P                  ! VR4      pVP                  ^R4       VP	                  R4       V P                  VP                  P                  P                  4       P                  4       ^ ,          R4       R# )zv
L{http.Request.setResponseCode} takes a status code and a message and
causes them to be used as the response status.
Fs   happily acceptedr7   s)   (no clientproto yet) 202 happily acceptedNr  r  s   &  r8   test_setResponseCodeAndMessage+RequestTests.test_setResponseCodeAndMessage)  sn    
 .ll7E*C!45		#%%..0;;=a@8	
r7   c                f    \         P                  ! \        4       R4      pVP                  ^4       R# )zx
L{http.Request.setResponseCode} accepts C{int} for the code parameter
and raises L{TypeError} if passed anything else.
FN)r#   rO  r)   rH   rf  s   & r8   #test_setResponseCodeAcceptsIntegers0RequestTests.test_setResponseCodeAcceptsIntegers7  s$    
 ll<>51Ar7   c                :   \        4       p\        P                  ! VR4      pVP                  \        P                  4       VP                  R4       V P                  VP                  P                  P                  4       P                  4       ^ ,          R4       R# )z
L{http.Request.setResponseCode} supports RFC 2324 section 2.3.2
418 response code and will automatically set the associated message.
Fr7   s%   (no clientproto yet) 418 I'm a teapotN)r)   r#   rO  rH   IM_A_TEAPOTr   rZ   r   r  r  r   r  s   &  r8   test_setResponseCode418$RequestTests.test_setResponseCode418?  sq    
 .ll7E*D,,-		#%%..0;;=a@4	
r7   c                    \         P                  ! \        4       R4      pVP                  ^*4       V P	                  VP
                  ^*4       R# )z
When no previous value was set and no 'if-modified-since' value was
requested, L{http.Request.setLastModified} takes a timestamp in seconds
since the epoch and sets the request's lastModified attribute.
FNr#   rO  r)   setLastModifiedrZ   lastModifiedrf  s   & r8   test_setLastModifiedNeverSet)RequestTests.test_setLastModifiedNeverSetO  s:     ll<>51B))2.r7   c                    \         P                  ! \        4       R4      pVP                  ^ 4       VP                  ^4       V P	                  VP
                  ^4       R# )z
If the supplied timestamp is later than the lastModified attribute's
value, L{http.Request.setLastModified} updates the lastModifed
attribute.
FNr  rf  s   & r8   test_setLastModifiedUpdate'RequestTests.test_setLastModifiedUpdate[  sH     ll<>51AA))1-r7   c                    \         P                  ! \        4       R4      pVP                  ^4       VP                  ^ 4       V P	                  VP
                  ^4       R# )z
If the supplied timestamp occurs earlier than the current lastModified
attribute, L{http.Request.setLastModified} ignores it.
FNr  rf  s   & r8   test_setLastModifiedIgnore'RequestTests.test_setLastModifiedIgnoreh  sH    
 ll<>51AA))1-r7   c                    \         P                  ! \        4       R4      pVP                  P	                  \        R4      R.4       VP                  ^*4      pV P                  V\         P                  4       R# )z
If the resource is older than the if-modified-since date in the request
header, L{http.Request.setLastModified} returns L{http.CACHED}.
Fif-modified-sinces   02 Jan 1970 00:00:00 GMTN	r#   rO  r)   r  r  r   r  rZ   CACHEDrK   rV  r  s   &  r8   test_setLastModifiedCached'RequestTests.test_setLastModifiedCachedt  s_    
 ll<>51((-.1L0M	
 $$R(-r7   c                    \         P                  ! \        4       R4      pVP                  P	                  \        R4      R.4       VP                  R4      pV P                  VR4       R# )z~
If the resource is newer than the if-modified-since date in the request
header, L{http.Request.setLastModified} returns None
Fr  s   01 Jan 1970 00:00:00 GMT@B Nr#   rO  r)   r  r  r   r  rZ   r  s   &  r8   test_setLastModifiedNotCached*RequestTests.test_setLastModifiedNotCached  s[    
 ll<>51((-.1L0M	
 $$W-&r7   c                    \         P                  ! \        4       R4      pVP                  P	                  \        R4      R.4       VP                  R4       VP                  ^ 4      pV P                  VR4       R# )z
When L{http.Request.setLastModified} is called multiple times, the
highest supplied value is honored. If that value is higher than the
if-modified-since date in the request header, the method returns None.
Fr  s   01 Jan 1970 00:00:01 GMTr  Nr  r  s   &  r8   "test_setLastModifiedTwiceNotCached/RequestTests.test_setLastModifiedTwiceNotCached  si     ll<>51((-.1L0M	
 	G$$$Q'&r7   c                   \         P                  ! \        4       R4      pVP                  P	                  \        R4      R.4       VP                  ^4       VP                  ^ 4      pV P                  V\         P                  4       R# )z
When L{http.Request.setLastModified} is called multiple times, the
highest supplied value is honored. If that value is lower than the
if-modified-since date in the request header, the method returns
L{http.CACHED}.
Fr  s   01 Jan 1999 00:00:01 GMTNr  r  s   &  r8   test_setLastModifiedTwiceCached,RequestTests.test_setLastModifiedTwiceCached  sm     ll<>51((-.1L0M	
 	A$$Q'-r7   c                    \         P                  ! \        4       R4      pVP                  R^P4       V P	                  VP
                  P                  R4      R.4       R# )|
L{http.Request.setHost} sets the value of the host request header.
The port should not be added because it is the default.
Fr.  rk  Nr#   rO  r)   setHostrZ   r  rJ  rf  s   & r8   test_setHostRequestTests.test_setHost  sH    
 ll<>51NB'++99'B^DTUr7   c                    \        4       p\         P                  ! 4       Vn        \        P                  ! VR4      pVP                  RR4       V P                  VP                  P                  R4      R.4       R# )r  Fr.  i  rk  N	r)   rS  r   r#   rO  r  rZ   r  rJ  rK   r  rV  s   &  r8   test_setHostSSLRequestTests.test_setHostSSL  s]    
 N"&&(ll1e$NC(++99'B^DTUr7   c                    \         P                  ! \        4       R4      pVP                  R^Q4       V P	                  VP
                  P                  R4      R.4       R# z|
L{http.Request.setHost} sets the value of the host request header.
The port should be added because it is not the default.
Fr.  rk  s   example.com:81Nr  rf  s   & r8   test_setHostNonDefaultPort'RequestTests.test_setHostNonDefaultPort  sI    
 ll<>51NB'++99'BEVDWXr7   c                    \        4       p\         P                  ! 4       Vn        \        P                  ! VR4      pVP                  R^Q4       V P                  VP                  P                  R4      R.4       R# r  r  r  s   &  r8   test_setHostSSLNonDefaultPort*RequestTests.test_setHostSSLNonDefaultPort  s^    
 N"&&(ll1e$NB'++99'BEVDWXr7   c                    \         P                  ! \        4       R4      pVP                  RR4       V P	                  VP
                  P                  R4      R.4       R# )zH
L{http.Request.setHeader} sets the value of the given response header.
Fr  r  N)r#   rO  r)   r   rZ   r  rJ  rf  s   & r8   test_setHeaderRequestTests.test_setHeader  sG     ll<>51gx(,,::7ChZPr7   c                   \        4       p\        P                  ! VR4      pVP                  ! V/ VB  V P	                  VP
                  ^ ,          V4       VP                  R4       VP                  P                  P                  4       P                  R4      pV Uu. uF  qwP                  R4      '       g   K  VNK  	  ppV P	                  \        V4      ^4       V P	                  V^ ,          RV,           4       R# u upi )z
Call L{http.Request.addCookie} with C{*args} and C{**kwargs}, and check
that the cookie value is equal to C{expectedCookieValue}.
Fr7   rG  s
   Set-Cookies   Set-Cookie: N)r)   r#   rO  	addCookierZ   r  r   r   r  r  r   
startswithr   )	rK   expectedCookieValuer<   r=   r   rV  writtenLinesr>  addCookieLiness	   &&*,     r8   _checkCookieRequestTests._checkCookie  s    
 .ll7E*t&v&Q)<= 			#((0099;AA'J &2Q\\\-5P!!\Q^,a0*O>Q,QR Rs   D<Dc                0    RpV P                  VRR4       R# )z
L{http.Request.addCookie} adds a new cookie to be sent with the
response, and can be called with just a key and a value. L{unicode}
arguments are encoded using UTF-8.
   foo=barfoobarNr  rK   r  s   & r8   )test_addCookieWithMinimumArgumentsUnicode6RequestTests.test_addCookieWithMinimumArgumentsUnicode  s     )-ue<r7   c                @    RpV P                  VRRRRRRRR	R	R
7
       R# )zy
L{http.Request.addCookie} adds a new cookie to be sent with the
response. L{unicode} arguments are encoded using UTF-8.
}   foo=bar; Expires=Fri, 31 Dec 9999 23:59:59 GMT; Domain=.example.com; Path=/; Max-Age=31536000; Comment=test; Secure; HttpOnlyr  r  zFri, 31 Dec 9999 23:59:59 GMTz.example.com/31536000testTexpiresdomainr  max_agecommentsecurehttpOnlyNr  r  s   & r8   %test_addCookieWithAllArgumentsUnicode2RequestTests.test_addCookieWithAllArgumentsUnicode  s?    . 	 	3! 	 	
r7   c                0    RpV P                  VRR4       R# )z
L{http.Request.addCookie} adds a new cookie to be sent with the
response, and can be called with just a key and a value. L{bytes}
arguments are not decoded.
r  r  r:  Nr  r  s   & r8   'test_addCookieWithMinimumArgumentsBytes4RequestTests.test_addCookieWithMinimumArgumentsBytes  s     )-vv>r7   c                @    RpV P                  VRRRRRRRR	R	R
7
       R# )zo
L{http.Request.addCookie} adds a new cookie to be sent with the
response. L{bytes} arguments are not decoded.
r  r  r:  s   Fri, 31 Dec 9999 23:59:59 GMTs   .example.comr  s   31536000r  Tr  Nr  r  s   & r8   #test_addCookieWithAllArgumentsBytes0RequestTests.test_addCookieWithAllArgumentsBytes   s?    . 	 	4" 	 	
r7   c           	     L   R p. ROp\        \        \        \        ,           \	        \
        .4      4      4      pRR.RR..pV F\  w  rEV P                  V! WU4      WD4       V F9  w  rgRP                  V! WU4      V! Wu4      .4      pV P                  ! WV3/ Wd/B  K;  	  K^  	  R# )zY
L{http.Request.addCookie} replaces linear whitespace and
semicolons with single spaces.
c                 &    R P                  W.4      # )   =)r  )r  r   s   &&r8   cookieValue<RequestTests.test_addCookieSanitization.<locals>.cookieValue>  s    99c\**r7   zFoo; bars   Foo  bars   Foo; bars   ; N))r  s   Expires)r  s   Domain)r  s   Path)r  s   Max-Age)r  s   Comment)r  zipr,   r*   r   r+   r  r  )	rK   r  	argumentsinputsAndOutputs
inputValueoutputValueargument	parameterr   s	   &        r8   test_addCookieSanitization'RequestTests.test_addCookieSanitization8  s    	+
	  .1PP~&'
 %+&

 (8#JK5z (1# ::#K=#I; !!*9A8N (1	 (8r7   c                    V P                  RRRRR7       V P                  RRRRR7       V P                  RRRRR7       R	# )
z
L{http.Request.setCookie} supports a C{sameSite} argument.
It will set the cookie with samesite=lax and samesite=strict values.
s   foo=bar; SameSite=laxr  r:  laxsameSiteLaxs   foo=bar; SameSite=strictstrictNr  rJ   s   &r8   test_addCookieSameSite#RequestTests.test_addCookieSameSited  sP    
 	2FFUS2FFUS'( 	 	
r7   c                    V P                  RRRRRR7       V P                  RRRRRR7       V P                  RRRRRR7       R	# )
a  
L{http.Request.setCookie} supports the C{sameSite} argument together with secure.
It will set the cookie with samesite=none and secure attributes to be sure that
all values of samesite are supported. secure attribute is a necessary condition
if the samesite is none
s   foo=bar; Secure; SameSite=noner  r:  NoneTr  r  nones   noneNr  rJ   s   &r8    test_addCookieSameSiteNoneSecure-RequestTests.test_addCookieSameSiteNoneSecureo  sn     	- 	 	
 	- 	 	
 	- 	 	
r7   c           
        V P                  \        V P                  RRRRR7      pV P                  RVP                  ^ ,          4       V P                  \        V P                  RRRRRR	7      pV P                  R
VP                  ^ ,          4       V P                  \        V P                  RRRRR7      pV P                  R
VP                  ^ ,          4       R# )z
Raises an exception when setting the cookie with not supported samesite value and without a necessary
secure attribute for the samesite=none cookie.
r7   r  r:  zanything-elser  z,Invalid value for sameSite: b'anything-else'r  Fr  zCInvalid value for sameSite: b'none'. Missing the "secure" attributeN)r  r  r  rZ   r<   )rK   errors   & r8   test_addCookieWrongValues&RequestTests.test_addCookieWrongValues  s    
 !!))3 " 
 	GTUW!! " 
 	SJJqM	

 !!))3 " 
 	SJJqM	
r7   c                6   \        4       p\        P                  ! VR4      p\        4       pW1n        VP                  ^4       RVn        VP                  P                  RR.4       VP                  R4       V P                  VP                  4       R.4       R# )zw
For an HTTP 1.0 request, L{http.Request.write} sends an HTTP 1.0
Response-Line and whatever response headers are set.
Fr  r  r  r  N)r  r  r  r)   r#   rO  r   r   rH   r   r  r  r   r   r   rK   r   rV  r  s   &   r8   test_firstWriteRequestTests.test_firstWrite  s    
 .ll7E*!!C %))'H:>		(!!KKMJK	
r7   c                X   \        4       p\        P                  ! VR4      p\        4       pW1n        VP                  ^4       RVn        VP                  P                  RR.4       VP                  R4       VP                  R4       V P                  VP                  4       R.4       R# )	z
For an HTTP 1.1 request, L{http.Request.write} sends an HTTP 1.1
Response-Line, whatever response headers are set, and uses chunked
encoding for the response body.
Fr  r  r  r  r  Nr  r  r  s   &   r8   test_firstWriteHTTP11Chunked)RequestTests.test_firstWriteHTTP11Chunked  s     .ll7E*!!C %))'H:>		(		)!!KKM
	
r7   c                D   \        4       p\        P                  ! VR4      p\        4       pW1n        VP                  ^4       RVn        ^ Vn        VP                  P                  RR.4       VP                  R4       V P                  VP                  4       R.4       R# )z
For an HTTP 1.0 request for a resource with a known last modified time,
L{http.Request.write} sends an HTTP Response-Line, whatever response
headers are set, and a last-modified header with that time.
Fr  r  r  r  N)r  r  ,   Last-Modified: Thu, 01 Jan 1970 00:00:00 GMTr  )r)   r#   rO  r   r   rH   r   r  r  r  r   r   r   r  s   &   r8   test_firstWriteLastModified(RequestTests.test_firstWriteLastModified  s     .ll7E*!!C %))'H:>		(!!KKM
	
r7   c                   \         P                  ! V \        4      p\        4       p\        P
                  ! VR4      p\        4       pWBn        VP                  ^4       RVn	        RVn
        VP                  P                  RR.4       VP                  R4       V P                  VP                  4       R
.4       V P!                  ^\#        V4      4       V^ ,          pV P!                  RVR,          4       R	# )z
If the last-modified header already exists in the L{http.Request}
response headers, the lastModified attribute is ignored and a message
is logged.
Fr  i ʚ;s   last-modifieds   Thu, 01 Jan 1970 00:00:00 GMTr  zPWarning: last-modified specified both in header list and lastModified attribute.r   N)r  r  r  )r   r   r   r)   r#   rO  r   r   rH   r   r  r  r  r   r   r   r   r   )rK   r   r   rV  r  r   s   &     r8   test_lastModifiedAlreadyWritten,RequestTests.test_lastModifiedAlreadyWritten  s     +<<TCUV.ll7E*!!C %%))?@	
 			(!!KKM		
 	!S-.A7,	
r7   c                |    \         P                  ! \        4       R4      pV P                  VP                  / 4       R# )z@
L{http.Request.received_cookies} defaults to an empty L{dict}.
FN)r#   rO  r)   rZ   received_cookiesrf  s   & r8   test_receivedCookiesDefault(RequestTests.test_receivedCookiesDefault#  s,     ll<>51--r2r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  RRRR/4       R# )	zl
L{http.Request.parseCookies} extracts cookies from C{requestHeaders}
and adds them to C{received_cookies}.
F   cookies   test="lemur"; test2="panda"r     "lemur"   test2   "panda"Nr#   rO  r)   r  r  parseCookiesrZ   r  rf  s   & r8   test_parseCookiesRequestTests.test_parseCookies*  s^    
 ll<>51((5S4TU  7J*"M	
r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RRR.4       VP                  4        V P                  VP                  RRRR/4       R	# )
zP
L{http.Request.parseCookies} can extract cookies from multiple Cookie
headers.
Fr   s   test="lemur"s   test2="panda"r  r!  r"  r#  Nr$  rf  s   & r8    test_parseCookiesMultipleHeaders-RequestTests.test_parseCookiesMultipleHeaders6  s`    
 ll<>51((_FV4WX  7J*"M	
r7   c                    \         P                  ! \        4       R4      pVP                  4        V P	                  VP
                  / 4       R# )zR
L{http.Request.parseCookies} can be called on a request without a
cookie header.
FN)r#   rO  r)   r%  rZ   r  rf  s   & r8   test_parseCookiesNoCookie&RequestTests.test_parseCookiesNoCookieB  s8    
 ll<>51--r2r7   c                    \         P                  ! \        4       R4      pVP                  P	                  R. 4       VP                  4        V P                  VP                  / 4       R# )zV
L{http.Request.parseCookies} can be called on a request with an
empty cookie header.
Fr   Nr$  rf  s   & r8   test_parseCookiesEmptyCookie)RequestTests.test_parseCookiesEmptyCookieK  sN    
 ll<>51((B7--r2r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  / 4       R# )zH
L{http.Request.parseCookies} ignores cookies which don't have a
value.
Fr   s   foo; bar; baz;Nr$  rf  s   & r8    test_parseCookiesIgnoreValueless-RequestTests.test_parseCookiesIgnoreValuelessU  sR    
 ll<>51((5F4GH--r2r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  RR/4       R# )zB
L{http.Request.parseCookies} parses cookies with an empty value.
Fr   s   foo=r  r7   Nr$  rf  s   & r8   test_parseCookiesEmptyValue(RequestTests.test_parseCookiesEmptyValue_  sT     ll<>51((WI>--}=r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  RR/4       R# )zN
L{http.Request.parseCookies} leaves trailing whitespace in the
cookie value.
Fr   s   foo=bar r  s   bar Nr$  rf  s   & r8   !test_parseCookiesRetainRightSpace.RequestTests.test_parseCookiesRetainRightSpaceh  sU    
 ll<>51(([MB--/@Ar7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  RR/4       R# )zK
L{http.Request.parseCookies} strips leading whitespace in the
cookie key.
Fr   s    foo=barr  r:  Nr$  rf  s   & r8   test_parseCookiesStripLeftSpace,RequestTests.test_parseCookiesStripLeftSpacer  sU    
 ll<>51(([MB--/?@r7   c                    \         P                  ! \        4       R4      pVP                  P	                  RR.4       VP                  4        V P                  VP                  RRRR/4       R# )	zZ
L{http.Request.parseCookies} parses valid cookies set before or
after malformed cookies.
Fr   s0   12345; test="lemur"; 12345; test2="panda"; 12345r  r!  r"  r#  Nr$  rf  s   & r8   -test_parseCookiesContinueAfterMalformedCookie:RequestTests.test_parseCookiesContinueAfterMalformedCookie|  sc    
 ll<>51((KL	
 	  7J*"M	
r7   c                T   \         P                  ! \        4       R4      pVP                  ^
4       VP                  pVP                  R4       VP                  \        \        R4      4      4       V P                  VP                  4       V P                  VP                  R4       R# )z
L{http.Request.connectionLost} closes L{Request.content} and drops the
reference to the L{HTTPChannel} to assist with garbage collection.
Fr  FinishedN)r#   rO  r)   	gotLengthr{   handleContentChunkr   r   r   r   closedr  r   )rK   rV  r{   s   &  r8   test_connectionLost RequestTests.test_connectionLost  s}    
 ll<>51 	b ++ 	x( 	7>*#=>?'S[[$/r7   c                    \         P                  ! \        4       R4      pVP                  \	        4       R4       V P                  \        VP                  \	        4       R4       R# )z^
Calling L{Request.registerProducer} when a producer is already
registered raises ValueError.
FTN)r#   rO  r)   rI   r    r  r  rf  s   & r8   test_registerProducerTwiceFails,RequestTests.test_registerProducerTwiceFails  sD    
 ll<>51]_d3*c&:&:MOTRr7   c                    \         P                  ! \        4       R4      p\        4       pVP	                  VR4       V P                  VR3.VP                  P                  4       R# )z
Calling L{Request.registerProducer} with an IPushProducer when the
request is not queued registers the producer as a push producer on the
request's transport.
FTNr#   rO  r)   r    rI   rZ   r   	producersrK   rV  r  s   &  r8   7test_registerProducerWhenNotQueuedRegistersPushProducerDRequestTests.test_registerProducerWhenNotQueuedRegistersPushProducer  sO     ll<>51 ?Xt,8T*+S]]-D-DEr7   c                    \         P                  ! \        4       R4      p\        4       pVP	                  VR4       V P                  VR3.VP                  P                  4       R# )z
Calling L{Request.registerProducer} with an IPullProducer when the
request is not queued registers the producer as a pull producer on the
request's transport.
FNrK  rM  s   &  r8   7test_registerProducerWhenNotQueuedRegistersPullProducerDRequestTests.test_registerProducerWhenNotQueuedRegistersPullProducer  sO     ll<>51 ?Xu-8U+,cmm.E.EFr7   c                   \        4       p\        P                  ! VR4      pVP                  4       pVP	                  \        \        R4      4      4       V P                  VP                  R4       V P                  V\        4      # )zg
L{Request.connectionLost} triggers all finish notification Deferreds
and cleans up per-request state.
TzConnection doneN)
r)   r#   rO  notifyFinishr   r   r   r  r   assertFailure)rK   r  r   r  s   &   r8   test_connectionLostNotification,RequestTests.test_connectionLostNotification  si    
 N,,q$''')w~6G'HIJW__d3!!(N;;r7   c                    \         P                  ! \        4       R4      pVP                  4       pVP	                  ^4       VP                  4        V# )z?
L{Request.finish} triggers all finish notification Deferreds.
F)r#   rO  r)   rT  rB  r   rK   r   r  s   &  r8   test_finishNotification$RequestTests.test_finishNotification  sC     ,,|~u5'') 	!r7   c                
   \         P                  ! \        4       R4      pVP                  4       pVP	                  ^4       VP                  R4       VP                  4        V P                  \        VP
                  R4       V# )zm
Calling L{Request.write} after L{Request.finish} has been called results
in a L{RuntimeError} being raised.
F   foobar)	r#   rO  r)   rT  rB  r   r   r  r  rY  s   &  r8   test_writeAfterFinish"RequestTests.test_writeAfterFinish  se    
 ,,|~u5'') 	!i ,yAr7   c                    \        4       p\        P                  ! VR4      pVP                  \	        \        R4      4      4       V P                  \        VP                  4       R# )zv
Calling L{Request.finish} after L{Request.connectionLost} has been
called results in a L{RuntimeError} being raised.
FThe end.N)	r)   r#   rO  r   r   r   r  r  r   r  s   &  r8   test_finishAfterConnectionLost+RequestTests.test_finishAfterConnectionLost  sG    
 .ll7E*7>*#=>?,

3r7   c                    \        4       p\        P                  ! VR4      pVP                  \	        \        R4      4      4       VP                  R4       V P                  \        VP                  4       R# )z
Calling L{Request.write} after L{Request.connectionLost} has been
called does not raise an exception. L{RuntimeError} will be raised
when finish is called on the request.
Fra  r]  N)
r)   r#   rO  r   r   r   r   r  r  r   r  s   &  r8   test_writeAfterConnectionLost*RequestTests.test_writeAfterConnectionLost  sS     .ll7E*7>*#=>?		),

3r7   c                    \         P                  ! \        4       R4      pV P                  \	        V4      R\        V4      3,          4       R# )z
L{Request.__repr__} returns the class name, object address, and
dummy-place holder values when used on a L{Request} which has not yet
been initialized.
FzZ<Request at 0x%x method=(no method yet) uri=(no uri yet) clientproto=(no clientproto yet)>Nr#   rO  r)   rZ   repridrK   r   s   & r8   test_reprUninitialized#RequestTests.test_reprUninitialized  s?     ,,|~u5M035g;.A	
r7   c                    \         P                  ! \        4       R4      pRVn        RVn        RVn        V P                  \        V4      R\        V4      3,          4       R# )z
L{Request.__repr__} returns, as a L{str}, the class name, object
address, and the method, uri, and client protocol of the HTTP request
it represents.  The string is in the form::

  <Request at ADDRESS method=METHOD uri=URI clientproto=PROTOCOL>
Fr  r   r   z><Request at 0x%x method=GET uri=/foo/bar clientproto=HTTP/1.0>N)	r#   rO  r)   r   r   r   rZ   ri  rj  rk  s   & r8   test_reprInitialized!RequestTests.test_reprInitialized  sT     ,,|~u5)!M$')'{n5	
r7   c                     ! R R\         P                  4      pV! \        4       R4      pV P                  \	        V4      R\        V4      3,          4       R# )z
Subclasses of L{Request} inherit a C{__repr__} implementation which
includes the subclass's name in place of the string C{"Request"}.
c                       ] tR tRtRtR# )1RequestTests.test_reprSubclass.<locals>.Otherwisei   r0   N)r1   r2   r3   r4   r6   r0   r7   r8   	Otherwisers     s    r7   rt  Fz\<Otherwise at 0x%x method=(no method yet) uri=(no uri yet) clientproto=(no clientproto yet)>Nrh  )rK   rt  r   s   &  r8   test_reprSubclassRequestTests.test_reprSubclass  sK    	 	 LNE2M035g;.A	
r7   c                   \         P                  ! \        4       R4      p\        4       Vn        VP                  \        4       R4       VP                  4        V P                  RVP                  VP                  P                  34       R# )z}
L{Request.unregisterProducer} unregisters a non-queued non-streaming
producer from the request and the request's transport.
FNNN
r#   rO  r)   r   r   rI   r    unregisterProducerrZ   r  rf  s   & r8   ,test_unregisterNonQueuedNonStreamingProducer9RequestTests.test_unregisterNonQueuedNonStreamingProducer*  sa    
 ll<>51')]_e4 cmm6L6L'MNr7   c                   \         P                  ! \        4       R4      p\        4       Vn        VP                  \        4       R4       VP                  4        V P                  RVP                  VP                  P                  34       R# )zy
L{Request.unregisterProducer} unregisters a non-queued streaming
producer from the request and the request's transport.
FTNrx  ry  rf  s   & r8   )test_unregisterNonQueuedStreamingProducer6RequestTests.test_unregisterNonQueuedStreamingProducer5  sa    
 ll<>51')]_d3 cmm6L6L'MNr7   c                   < V ^8  d   QhRR/# r  returnNr0   )r  rQ   s   "r8   r	  RequestTests.__annotate__@  s     ) )d )r7   c                L    \         P                  ! 4       P                  4        R# )zy
L{http.HTTPFactory.stopFactory} is a no-op (that does not raise an
exception) when the factory hasn't been started yet.
N)r#   r   stopFactoryrJ   s   &r8   test_stopFactoryInvalidState)RequestTests.test_stopFactoryInvalidState@  s    
 	&&(r7   c                   < V ^8  d   QhRR/# r  r0   )r  rQ   s   "r8   r	  r  G  s     3L 3L 3Lr7   c                ^   \         P                  ! 4       pRVn        RVn        RVn        V P                  \        4      ;_uu_ 4        VP                   RRR4       VP                  4        V P                  VP                  \        4       \        4       ;q!n        VP                  p\        V\        4      '       g   Q hV P                  VP                  V4       W1n        V P                  W1P                  4       VP                  R4      pRR.p\!        4       pVf   Q hVP#                  V4       V F  pVP%                  V4       K  	  VP&                  P(                  ^ ,          P+                  4        V P-                  RVP/                  4       4       R#   + '       g   i     ELO; i)zR
L{http.Request.finish} will call the channel's factory to produce a log
message.
NsometimeT   GET /path HTTP/1.1
r   s   sometime "GET /path HTTP/1.1")r#   r   r   _logDateTime_logDateTimeCallr  r  logFilestartFactoryr  legacyGlobalLogFiler   r7  r   r  r   r   r   r   r   r   r   r   r  )rK   r   r  getBackLogFileprotovalr  r>  s   &       r8   test_finishProducesLog#RequestTests.test_finishProducesLogG  sV   
 ""$)#'  ~..OO /goo':; %,I-/(/ .-8888n++W5( 	noo6%%d+(+6!   U#Aq!  	"))+ 	68H8H8JKC /..s   FF,	c                   \        4       p\        P                  ! ^dVR7      pVP                  4        VP	                  R4      p\        4       p\        W14      pV P                  VP                  ^d4       VP                  V4       VP                  R4       VP                  ^c4       V P                  VP                  4       VP                  ^4       V P                  VP                  4       R# )z
L{HTTPChannel} timeouts whenever data from a request body is not
delivered to it in time, even when it gets built from a L{HTTPFactory}.
)timeoutr   Nr   )r   r#   r   r  r   r   r   rZ   r   r   r   r   r   r   r   r  s   &    r8   "test_requestBodyTimeoutFromFactory/RequestTests.test_requestBodyTimeoutFromFactory|  s    
 ""3>((.#%	*8; 	))3/	*MNb001a	//0r7   c                n   \         P                  ! 4       pRVn        RVn        RVn        VP                  4        \        4       Vn        VP                  R4      p^ VP                  n
        RR.p\        4       pVP                  V4       V P                  VP                  R4       V F  pVP                  V4       K  	  VP                  R4       V P                  VP                  R4       VP                  P                   ^ ,          P#                  4        V P                  VP                  R4       R# )	z
L{http.Request.finish} will notify the channel that it is finished, and
will put the transport back in the producing state so that the reactor
can close the connection.
Nr  Tr  r   r<  s   GET r?  )r#   r   r   r  r  r  r   r  r   r   r7  r   r   rZ   r@  r   r   r   )rK   r   r  r  r  r>  s   &     r8   test_finishCleansConnection(RequestTests.test_finishCleansConnection  s     ""$)#' !)%%d+23/(+6!U#,,k:Aq!  	7#,,h7"))+,,k:r7   c                x    \         P                  ! \        4       R4      p\        \         P                  V4       R# )z
L{http.Request} provides
L{http._IDeprecatedHTTPChannelToRequestInterface}, which
defines the interface used by L{http.HTTPChannel}.
FN)r#   rO  r)   r   )_IDeprecatedHTTPChannelToRequestInterfacerf  s   & r8   6test_provides_IDeprecatedHTTPChannelToRequestInterfaceCRequestTests.test_provides_IDeprecatedHTTPChannelToRequestInterface  s&     ll<>51TCCSIr7   c                f    \         P                  ! \        4       R4      pV P                  W4       R# )z'
A L{http.Request} is equal to itself.
FNr#   rO  r)   rZ   rf  s   & r8   test_eqRequestTests.test_eq  s$     ll<>51"r7   c                    \         P                  ! \        4       R4      pV P                  V\         P                  ! \        4       R4      4       R# )z3
A L{http.Request} is not equal to another object.
FN)r#   rO  r)   assertNotEqualrf  s   & r8   test_neRequestTests.test_ne  s3     ll<>51Clne!DEr7   c                Z    \         P                  ! \        4       R4      p\        V4       R# )z 
A L{http.Request} is hashable.
FN)r#   rO  r)   hashrf  s   & r8   test_hashableRequestTests.test_hashable  s     ll<>51S	r7   c                   a . o ! V3R lR4      p\         P                  ! \        4       R4      pV P                  W!! 4       4       V P                  SV.4       R# )z
A L{http.Request} on the left hand side of an equality
comparison to an instance that is not a L{http.Request} hands
the comparison off to that object's C{__eq__} implementation.
c                   :   <a  ] tR tRt o V 3R lV3R lltRtV tR# )8RequestTests.test_eqWithNonRequest.<locals>._NotARequesti  c                &   < V ^8  d   QhRS[ RS[/# r  otherr  objectbool)r  rQ   s   "r8   r	  ERequestTests.test_eqWithNonRequest.<locals>._NotARequest.__annotate__        F t r7   c                *   < SP                  V4       R # Tr  rK   r  eqCallss   &&r8   __eq__?RequestTests.test_eqWithNonRequest.<locals>._NotARequest.__eq__      u%r7   r0   N)r1   r2   r3   r4   r  r6   rO   rQ   r  s   @r8   _NotARequestr           r7   r  FNr  rK   r  rV  r  s   &  @r8   test_eqWithNonRequest"RequestTests.test_eqWithNonRequest  sL     	 	
 ll<>51ln-3%(r7   c                   a . o ! V3R lR4      p\         P                  ! \        4       R4      pV P                  W!! 4       4       V P	                  SV.4       R# )z
A L{http.Request} on the left hand side of an inequality
comparison to an instance that is not a L{http.Request} hands
the comparison off to that object's C{__ne__} implementation.
c                   :   <a  ] tR tRt o V 3R lV3R lltRtV tR# )8RequestTests.test_neWithNonRequest.<locals>._NotARequesti  c                &   < V ^8  d   QhRS[ RS[/# r  r  )r  rQ   s   "r8   r	  ERequestTests.test_neWithNonRequest.<locals>._NotARequest.__annotate__  r  r7   c                *   < SP                  V4       R # r  r  r  s   &&r8   __ne__?RequestTests.test_neWithNonRequest.<locals>._NotARequest.__ne__  r  r7   r0   N)r1   r2   r3   r4   r  r6   rO   r  s   @r8   r  r    r  r7   r  FN)r#   rO  r)   r  rZ   r  s   &  @r8   test_neWithNonRequest"RequestTests.test_neWithNonRequest  sL     	 	
 ll<>51C03%(r7   c                   \         P                  ! V \        4      p\        P                  ! \        4       R4      pVP                  \        4       R4       VP                  4        V P                  ^\        V4      4       V^ ,          pVR,          pV P                  VP                  \        4       V P                  \        4       R# )za
A RuntimeError is logged if a producer is still registered
when an L{http.Request} is finished.
FTr  N)r   r   r   r#   rO  r)   rI   r    r   r   r   r  r   r  r   )rK   r   r   r   r>  s   &    r8   "test_finishProducerStillRegistered/RequestTests.test_finishProducerStillRegistered  s    
 +<<TCUV,,|~u5  $7!S-.A- agg|4|,r7   c           	         \         P                  ! \        \        P                  ! RRR4      R7      4      pV P                  VP                  4       R4       R# )ze
L{http.Request.getClientIP} returns the host part of the
client's address when connected over IPv4.
rZ  	127.0.0.180  peerNr#   rO  r)   r   IPv6AddressrZ   getClientIPrk  s   & r8   test_getClientIPWithIPv4%RequestTests.test_getClientIPWithIPv4  sD    
 ,,g11%eLM
 	,,.<r7   c           	         \         P                  ! \        \        P                  ! RRR4      R7      4      pV P                  VP                  4       R4       R# )ze
L{http.Request.getClientIP} returns the host part of the
client's address when connected over IPv6.
rZ  z::1r  r  Nr  rk  s   & r8   test_getClientIPWithIPv6%RequestTests.test_getClientIPWithIPv6  sD    
 ,,g11%FG
 	,,.6r7   c                    \         P                  ! \        \        P                  ! R4      R7      4      pV P                  VP                  4       R4       R# )zr
L{http.Request.getClientIP} returns L{None} for the client's
IP address when connected over a non-TCP transport.
/path/to/socketr  N)r#   rO  r)   r   UNIXAddressrZ   r  rk  s   & r8   test_getClientIPWithNonTCPPeer+RequestTests.test_getClientIPWithNonTCPPeer  sA    
 ,,g112CDE
 	,,.5r7   c                    \         P                  ! R4      p\        P                  ! \	        VR7      4      pV P                  VP                  4       V4       R# )z[
L{http.Request.getClientAddress} returns the client's address
as an L{IAddress} provider.
r  r  N)r   r  r#   rO  r)   r  getClientAddress)rK   r  r   s   &  r8   test_getClientAddress"RequestTests.test_getClientAddress   s?    
 $$%67,,|89g..0&9r7   r0   N)Sr1   r2   r3   r4   r5   rb  rg  rp  rt  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r
  r  r  r  r  r  r&  r)  r,  r/  r2  r5  r8  r;  r>  rE  rH  rN  rQ  rV  rZ  r^  rb  re  rl  ro  ru  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r6   rO   rP   s   @r8   r[  r[    s    4$;G0;7C2C


 
/.
..'' ."V	VY	YQS&=
0?
0*X	

:
@
(
<
<%
N3



333>BA
0*S	F	G
<
4
4

$
 	O	O) )3L 3Lj1,;>J#F)$)$-=76: :r7   r[  c                   X   a  ] tR tRt o RtR tRRRRRR	/tR
 tR tR t	R t
R tRtV tR# )MultilineHeadersTestsi*  z
Tests to exercise handling of multiline headers by L{HTTPClient}.  RFCs 1945
(HTTP 1.0) and 2616 (HTTP 1.1) state that HTTP message header fields can
span multiple lines if each extra line is preceded by at least one space or
horizontal tab.
c                "    RV n         RV n        R# )z^
Initialize variables used to verify that the header-processing functions
are getting called.
FN)handleHeaderCalledhandleEndHeadersCalledrJ   s   &r8   r  MultilineHeadersTests.setUp2  s    
 #(&+#r7   rz   s   10s   X-Multilines   line-0	line-1s   X-Multiline2s   line-2 line-3c                X    RV n         V P                  W P                  V,          4       R# )z5
Dummy implementation of L{HTTPClient.handleHeader}.
TN)r  rZ   r   )rK   r  r  s   &&&r8   ourHandleHeader%MultilineHeadersTests.ourHandleHeaderB  s%     #'22378r7   c                    RV n         R# )z9
Dummy implementation of L{HTTPClient.handleEndHeaders}.
TN)r  rJ   s   &r8   ourHandleEndHeaders)MultilineHeadersTests.ourHandleEndHeadersI  s     '+#r7   c                   \        4       pV P                  Vn        V P                  Vn        VP                  R4       VP                  R4       V P                  VP                  R4       V P                  V P                  4       V P                  V P                  4       VP                  R4       V P                  V P                  4       V P                  V P                  4       V P                  VP                  ^
4       R# )z
A header isn't processed by L{HTTPClient.extractHeader} until it is
confirmed in L{HTTPClient.lineReceived} that the header has been
received completely.
rT     Content-Length: 10Nr7   )rG  r  r  r  r  rO  r  r   r   r  r  r   rZ   rP  s   & r8   test_extractHeader(MultilineHeadersTests.test_extractHeaderO  s     N--!55	'	,-QXXt,001445 	
s//03342&r7   c                ~   \        4       pV P                  Vn        V P                  Vn        VP                  R4       VP                  R4       V P                  V P                  4       V P                  V P                  4       V P                  VP                  R4       V P                  VP                  R4       R# )z
An HTTP request with no headers will not cause any calls to
L{handleHeader} but will cause L{handleEndHeaders} to be called on
L{HTTPClient} subclasses.
rT  r7   r  rM  N)rG  r  r  r  r  rO  r   r  r   r  rZ   r  r   rP  s   & r8   test_noHeaders$MultilineHeadersTests.test_noHeadersf  s     N--!55	' 	
s001334K06*r7   c                   \        4       pV P                  Vn        V P                  Vn        VP                  R4       VP                  R4       V P                  V P                  4       VP                  R4       VP                  R4       V P                  V P                  4       VP                  R4       VP                  R4       VP                  R4       V P                  V P                  4       V P                  VP                  R4       V P                  VP                  R	4       V P                  VP                  ^
4       R
# )z
L{HTTPClient} parses multiline headers by buffering header lines until
an empty line or a line that does not start with whitespace hits
lineReceived, confirming that the header has been received completely.
rT  s   X-Multiline: line-0s   	line-1s   X-Multiline2: line-2s    line-3r  r7   r  rM  N)rG  r  r  r  r  rO  r   r  r   r  rZ   r  r   r   rP  s   & r8   test_multilineHeaders+MultilineHeadersTests.test_multilineHeadersy  s     N--!55	'	-.001	{#	.///0	z"	,- 	
s334K06*2&r7   )r  r  N)r1   r2   r3   r4   r5   r  r   r  r  r  r  r  r6   rO   rP   s   @r8   r  r  *  sG     , 	5))O9+'.+&' 'r7   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )Expect100ContinueServerTestsi  aQ  
Test that the HTTP server handles 'Expect: 100-continue' header correctly.

The tests in this class all assume a simplistic behavior where user code
cannot choose to deny a request. Once ticket #288 is implemented and user
code can run before the body of a POST is processed this should be
extended to support overriding this behavior.
c                   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       VP                  R4       V P                  VP                  4       R	.4       R# )
zs
HTTP/1.0 requests do not get 100-continue returned, even if 'Expect:
100-continue' is included (RFC 2616 10.1.1).
s   GET / HTTP/1.0
   Host: www.example.com
   Content-Length: 3
   Expect: 100-continue
rG  r7   r%  N)r  r  r  r  r     '''
3
abc'''
)
r   r#   r   r   r   r   r   rZ   r   r   )rK   r   r   s   &  r8   test_HTTP10(Expect100ContinueServerTests.test_HTTP10  s    
 $%	""$!6y)239:5689W%*C0V$!!OO		
r7   c                j   \        4       p\        P                  ! 4       p\        Vn        VP                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       VP                  R4       V P                  VP                  4       R4       VP                  R4       VP                  4       pV P                  VP                  R4      4       V\        R4      R	 pV P                  VR
.4       R	# )z
If a HTTP/1.1 client sends a 'Expect: 100-continue' header, the server
responds with a 100 response code before handling the request body, if
any. The normal resource rendering code will then be called, which
will send an additional response code.
s   GET / HTTP/1.1
r  r  r  r7   rG  s   HTTP/1.1 100 Continue

r%  N)r  r  r  r  r  r  )r   r#   r   r   r   r   r   rZ   r   r   r  r   r   )rK   r   r   r   s   &   r8   test_expect100ContinueHeader9Expect100ContinueServerTests.test_expect100ContinueHeader  s    $%	""$!6y)239:8956 	*C0W% 	*,LMV$??$++,LMNC @ACD!!		
r7   r0   N)	r1   r2   r3   r4   r5   r  r  r6   rO   rP   s   @r8   r  r    s     
<&
 &
r7   r  c                <    V  Uu/ uF  q"W,          bK  	  up# u upi )al  
Create a new dict containing only a subset of the items of an existing
dict.

@param keys: An iterable of the keys which will be added (with values from
    C{d}) to the result.

@param d: The existing L{dict} from which to copy items.

@return: The new L{dict} with keys given by C{keys} and values given by the
    corresponding values in C{d}.
@rtype: L{dict}
r0   )keysr  ks   && r8   subr    s      ""TqtGT"""s   c                   0   a  ] tR tRt o RtR tR tRtV tR# ) DeprecatedRequestAttributesTestsi  zA
Tests for deprecated attributes of L{twisted.web.http.Request}.
c           	        \         P                  ! \        \        P                  ! RRR4      R7      4      pVP                  ^ 4       VP                  RRR4       VP                  4        V P                  V P                  .R7      pV P                  ^\        V4      4       V P                  R	\        R
R/\        R	R
.V^ ,          4      4       R# )zO
L{Request.getClientIP} is deprecated in favor of
L{Request.getClientAddress}.
rZ  r  i90  r  r   r  r  offendingFunctionscategoryr  zjtwisted.web.http.Request.getClientIP was deprecated in Twisted 18.4.0; please use getClientAddress insteadN)r#   rO  r)   r   r  rB  requestReceivedr  flushWarningstest_getClientIPrZ   r   DeprecationWarningr  )rK   r   warningss   &  r8   r  1DeprecatedRequestAttributesTests.test_getClientIP  s    
 ,,g11%eLM
 	!k:%%$:O:O9P%QCM*.M Y'!5		
r7   c                0   \        4       p\        P                  ! V4      pVP                  4        V P	                  V P
                  .R7      pV P                  ^\        V4      4       V P                  R\        RR/\        RR.V^ ,          4      4       R# )z[
L{Request.noLongerQueued} is deprecated, as we no longer process
requests simultaneously.
r  r  r  zHtwisted.web.http.Request.noLongerQueued was deprecated in Twisted 16.3.0N)
r)   r#   rO  noLongerQueuedr  test_noLongerQueuedrZ   r   r  r  )rK   r   r   r  s   &   r8   r  4DeprecatedRequestAttributesTests.test_noLongerQueued  s    
 .,,w' %%$:R:R9S%TCM*.( Y'!5		
r7   r0   N)	r1   r2   r3   r4   r5   r  r  r6   rO   rP   s   @r8   r  r    s     
4
 
r7   r  c                   v   a  ] tR tRt o RtRtR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tRtV tR# )ChannelProductionTestsi1  z5
Tests for the way HTTPChannel manages backpressure.
s#   GET / HTTP/1.1
Host: localhost

c                x    Tp\         P                  ! 4       p\        V4      Vn        VP	                  V4       W13# )z
Setup a L{HTTPChannel} and a transport and associate them.

@param transport: A transport to back the L{HTTPChannel}
@param requestFactory: An object that can construct L{Request} objects.
@return: A tuple of the channel and the transport.
)r#   r   rB   r   r   )rK   r   r   r   s   &&& r8   buildChannelAndTransport/ChannelProductionTests.buildChannelAndTransport8  s;     	""$!9.!Iy)!!r7   c                    V P                  \        4       \        4      w  rV P                  VP                  V4       V P                  VP                  4       R# )z]
L{HTTPChannel} registers itself as a producer with its transport when a
connection is made.
N)r!  r   rv   rZ   r  r   	streamingrK   r   r   s   &  r8   test_HTTPChannelIsAProducer2ChannelProductionTests.test_HTTPChannelIsAProducerG  sJ    
 "::/
 	++W5	++,r7   c                    V P                  \        4       \        4      w  rVP                  4        V P	                  VP
                  R4       V P	                  VP                  R4       R# )zF
L{HTTPChannel} unregisters itself when it has loseConnection called.
N)r!  r   rv   rI  r  r  r$  r%  s   &  r8   8test_HTTPChannelUnregistersSelfWhenCallingLoseConnectionOChannelProductionTests.test_HTTPChannelUnregistersSelfWhenCallingLoseConnectionS  sV     "::/
 	 i(($/i))40r7   c                    V P                  \        4       \        4      w  rVP                  \	        4       R4       V P                  \        VP                  \	        4       R4       R# )zx
If two producers are registered on a L{HTTPChannel} without the first
being unregistered, a L{RuntimeError} is thrown.
TN)r!  r   rv   rI   r    r  r  r%  s   &  r8   (test_HTTPChannelRejectsMultipleProducers?ChannelProductionTests.test_HTTPChannelRejectsMultipleProducers_  sQ    
 "::/
 	  $7,(@(@-/SWXr7   c                    V P                  \        4       \        4      w  rVP                  4        V P	                  VP
                  R4       R# )zZ
If there is no producer, the L{HTTPChannel} can still have
C{unregisterProducer} called.
Nr!  r   rv   rz  r  _requestProducerr%  s   &  r8   +test_HTTPChannelCanUnregisterWithNoProducerBChannelProductionTests.test_HTTPChannelCanUnregisterWithNoProducerk  B    
 "::/
 	""$g..5r7   c                    V P                  \        4       \        4      w  rVP                  4        V P	                  VP
                  R4       R# )zV
If there is no request producer currently registered, C{stopProducing}
does nothing.
Nr/  r%  s   &  r8   ,test_HTTPChannelStopWithNoRequestOutstandingCChannelProductionTests.test_HTTPChannelStopWithNoRequestOutstandingw  r3  r7   c                   V P                  \        4       \        4      w  rVP                  V P                  4       VP
                  ^ ,          P                  p\        4       pVP                  VR4       V P                  VP                  . 4       VP                  4        V P                  VP                  R.4       R# )z
If there is a request producer registered with L{HTTPChannel}, calling
C{stopProducing} causes that producer to be stopped as well.
TstopN)r!  r   r   r   r   r   r  r    rI   rZ   eventsstopProducingrK   r   r   r   r  s   &    r8   #test_HTTPChannelStopRequestProducer:ChannelProductionTests.test_HTTPChannelStopRequestProducer  s    
 "::1

 	T\\*""1%.. !?  40 	"- 	6(3r7   c                .   V P                  \        4       \        4      w  rV P                  VP                  R4       VP                  4        V P                  VP                  R4       VP                  4        V P                  VP                  R4       R# )z
When L{HTTPChannel} has C{pauseProducing} called on it by the transport
it will call C{pauseProducing} on the transport. When unpaused, the
L{HTTPChannel} will call C{resumeProducing} on its transport.
r<  r?  N)r!  r   rv   rZ   r@  pauseProducingresumeProducingr%  s   &  r8   ;test_HTTPChannelPropagatesProducingFromTransportToTransportRChannelProductionTests.test_HTTPChannelPropagatesProducingFromTransportToTransport  s     "::/

 	00+> 	 00(; 	!00+>r7   c                ,   V P                  \        4       \        4      w  r^ Vn        VP	                  V P
                  4       VP	                  R4       VP                  ^ ,          P                  p\        4       pVP                  VR4       V P                  VP                  R4       V P                  VP                  . 4       VP                  4        V P                  VP                  R4       V P                  VP                  R.4       VP                  4        V P                  VP                  R4       V P                  VP                  RR.4       VP                  4        VP!                  4        V P                  VP                  R4       R# )z
If a L{Request} object has registered itself as a producer with a
L{HTTPChannel} object, and the L{HTTPChannel} object is paused, both
the transport and L{Request} objects get paused.
s   123Tr?  pauseresumer<  N)r!  r   r   r7  r   r   r   r  r    rI   rZ   r@  r9  r?  r@  rz  r   r;  s   &    r8   3test_HTTPChannelPropagatesPausedProductionToRequestJChannelProductionTests.test_HTTPChannelPropagatesPausedProductionToRequest  sN    "::1
 ,-( 	T\\*V$""1%.. !?  40 	00(;"- 	 00(;7)4 	!00(;7H*=> 	""$ 00+>r7   c                   V P                  \        4       \        4      w  r^ Vn        VP	                  V P
                  4       VP	                  R4       VP                  ^ ,          P                  p\        4       pVP                  VR4       V P                  VP                  R4       V P                  VP                  . 4       VP                  4        V P                  VP                  R4       V P                  VP                  R.4       VP                  4        VP                  4        V P                  VP                  R4       VP!                  4        V P                  VP                  R4       R# )z
If a L{Request} object completes its response while the transport is
paused, the L{HTTPChannel} does not resume the transport.
s   extraTr?  rD  r<  N)r!  r   r   r7  r   r   r   r  r    rI   rZ   r@  r9  r?  rz  r   r@  r;  s   &    r8   /test_HTTPChannelStaysPausedWhenRequestCompletesFChannelProductionTests.test_HTTPChannelStaysPausedWhenRequestCompletes  s5   
 "::1
 ,-( 	T\\*X&""1%.. !?  40 	00(;"- 	 00(;7)4 	""$ 00(; 	!00+>r7   c                ~    ! R R\         4      pV! 4       pVP                  4        V P                  \        VP                  4       V P	                  V! 4       \
        4      w  r2V P                  VP                  R4       VP                  4        V P                  VP                  R4       VP                  V P                  4       V P                  VP                  R4       V P                  VP                  4       P                  R4      4       VP                  4        V P                  VP                  R4       R# )z
If the L{HTTPChannel} has paused the transport, it still tolerates
receiving data, and does not attempt to pause the transport again.
c                   *   a  ] tR tRt o RtR tRtV tR# )gChannelProductionTests.test_HTTPChannelToleratesDataWhenTransportPaused.<locals>.NoDoublePauseTransporti  zX
A version of L{StringTransport} that fails tests if it is paused
while already paused.
c                j    V P                   R 8X  d   \        R4      h\        P                  ! V 4       R# )r?  zTransport was paused twice!N)r@  r  r   r?  rJ   s   &r8   r?  vChannelProductionTests.test_HTTPChannelToleratesDataWhenTransportPaused.<locals>.NoDoublePauseTransport.pauseProducing  s*    %%1&'DEE..t4r7   r0   N)r1   r2   r3   r4   r5   r?  r6   rO   rP   s   @r8   NoDoublePauseTransportrM    s     
5 5r7   rP  r<  r?  s   HTTP/1.1 200 OK
N)r   r?  r  r  r!  rv   rZ   r@  r   r   r   r   r  r@  )rK   rP  r   r   s   &   r8   0test_HTTPChannelToleratesDataWhenTransportPausedGChannelProductionTests.test_HTTPChannelToleratesDataWhenTransportPaused  s   		5_ 		5 +,	  ",	(@(@A!::"$&6

 	00+> 	 00(; 	T\\* 	00(;	)445KLM 	!00+>r7   c                  a a S P                  \        4       \        4      w  po\        4       o\        P                  ! 4       p\
        Vn        VP                  S4       VP                  S P                  4       VP                  ^ ,          P                  pVP                  P                  pV V3R lpVP                  V4      # )zv
If the L{HTTPChannel} has a L{IPullProducer} registered with it it can
adapt that producer into an L{IPushProducer}.
c                 |   < SP                  4       P                  R ^4      ^,          pRpSP                  W4       R# )r   s<   1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
N)r   r   rZ   )ignresponseBodyexpectedResponseBodyrK   r   s   &  r8   validateOChannelProductionTests.test_HTTPChannelToleratesPullProducers.<locals>.validateD  s;    $??,22;B1EL	 ! \@r7   )r!  r   rD   r#   r   DummyPullProducerHandlerProxyr   r   r   r   r   r  rG   r  r  )rK   r   r   responseCompleterX  r   s   f    @r8   &test_HTTPChannelToleratesPullProducers=ChannelProductionTests.test_HTTPChannelToleratesPullProducers3  s    
 "::7
 $%	""$!>y)T\\*""1%.."2299	A   ++H55r7   c                   \        4       p\        4       p\        P                  ! 4       p^dVn        VP
                  Vn        VP                  V4       VP                  ^c4       V P                  VP                  V4       V P                  VP                  R4       VP                  ^4       V P                  VP                  R4       V P                  VP                  R4       R# )zC
L{HTTPChannel} unregisters itself when it times out a connection.
TN)r   r   r#   r   r   r   r   r   r  r  r$  )rK   r   r   r   s   &   r8   ,test_HTTPChannelUnregistersSelfWhenTimingOutCChannelProductionTests.test_HTTPChannelUnregistersSelfWhenTimingOutV  s     #%	""$ !OOy) 	bi(('2i))40 	ai(($/i))40r7   r0   N)r1   r2   r3   r4   r5   r   r!  r&  r)  r,  r1  r5  r<  rA  rF  rI  rQ  r\  r_  r6   rO   rP   s   @r8   r  r  1  s]      CG"
-
1
Y
6
640?**?X(?T+?Z!6F1 1r7   r  c                   *   a  ] tR tRt o RtR tRtV tR# )HTTPChannelSanitizationTestsin  z0
Test that L{HTTPChannel} sanitizes its output.
c           	     <   \          F  p\        4       p\        P                  ! 4       pVP	                  V4       VP                  RRRRV3.R7       R\        ,           R,           pV P                  VP                  4       RP                  RVR	.4      4       K  	  R
# )zm
L{HTTPChannel.writeHeaders} removes linear whitespace from the
list of header names and values it receives.
r  r  s   OKr  )r  codereasonr   s   Foo: rG  r  r7   N)
r*   r   r#   r   r   writeHeadersr+   rZ   r   r  )rK   	componentr   r   sanitizedHeaderLines   &    r8   *test_writeHeadersSanitizesLinearWhitespaceGHTTPChannelSanitizationTests.test_writeHeadersSanitizesLinearWhitespaces  s    
 9I')I&&(G""9-  # ),-	 !  #+^";g"E!*+	 9r7   r0   N)r1   r2   r3   r4   r5   ri  r6   rO   rP   s   @r8   rb  rb  n  s      r7   rb  c                   *   a  ] tR tRt o RtR tRtV tR# )HTTPClientDeprecationTestsi  z-
Test that L{http.HTTPClient} is deprecated.
c           
     D    V P                  RR\        R^^^ 4      4       R# )z>
Accessing L{http.HTTPClient} produces a deprecation warning.
ztwisted.web.http
HTTPClientTwistedN)getDeprecatedModuleAttributer   rJ   s   &r8   test_deprecated*HTTPClientDeprecationTests.test_deprecated  s&     	))Ir1a(	
r7   r0   N)r1   r2   r3   r4   r5   rq  r6   rO   rP   s   @r8   rl  rl    s     
 
r7   rl  c                   *   a  ] tR tRt o RtR tRtV tR# )HTTPClientSanitizationTestsi  z4
Test that L{http.HTTPClient} sanitizes its output.
c                2   \          F  p\        4       p\        P                  ! 4       pVP	                  V4       VP                  W4       V P                  VP                  4       P                  4       RP                  \        \        .4      .4       K  	  R# )zh
L{HTTPClient.sendHeader} replaces linear whitespace in its
header keys and values with a single space.
s   : N)r*   r   r#   rn  r   r   rZ   r   r   r  r+   )rK   rg  r   r  s   &   r8   (test_sendHeaderSanitizesLinearWhitespaceDHTTPClientSanitizationTests.test_sendHeaderSanitizesLinearWhitespace  ss    
 9I')I__&F!!),i3!,,.^^<=> 9r7   r0   N)r1   r2   r3   r4   r5   rv  r6   rO   rP   s   @r8   rt  rt    s      r7   rt  )xr5   r;  rn   rV   	functoolsr   ior   r   	itertoolsr   typingr   r   r!   r   urllib.parser
   r   r   zope.interfacer   r   r   zope.interface.verifyr   rm  incrementalr   twisted.internetr   twisted.internet.errorr   r   twisted.internet.taskr   twisted.internet.testingr   r   r   twisted.loggerr   twisted.protocolsr   twisted.python.compatr   r   twisted.python.componentsr   twisted.python.failurer   twisted.python.logr   r  twisted.test.test_internetr    twisted.trialtwisted.trial.unittestr"   twisted.webr#   r$   r%   twisted.web.httpr&   r'   r(   twisted.web.test.requesthelperr)   r*   r+   r,   _utilr-   r  r/   rB   rO  rD   rZ  rS   rv   r   INonQueuedRequestFactoryr   DummyNewHTTPHandlerProxyr   r  rn  r   r   r   r   r  r  r  r'  rE  rQ  rb  r  r  r  r  r!  r  r  r*  rG  rK  r[  r  r  r  r  r  SynchronousTestCaserb  rl  rt  r0   r7   r8   <module>r     sV       %  "  $ - A A .   $ A ' 
 . & : 7 * = 4 " + 0 0 S S  /66.;t|| ; !99Q R 
H%% 
<t|| " 11AB  
$
'
'(1* 1 )1 44GH 	') 	' 33EF , ,,!7 !7HcA8$$&7 cAL0< 0f, .	:< 	:p5(++-> p5f%H%% %D))H%% ))XZDh// ZDz3)) 3l/
x(( /
dD8H D8NQ
8#4#4 Q
h
sEH%%'8 sElk
8$$ k
\#RO(++ ROj4?? )x00 ).o:8$$&7 o:d#k'H-- k'\N
8#4#46G N
b#"4
x'8'8 4
nz1X.. z1z	!8#?#? !H
!=!= 
 (">"> r7   