+
    Dfj,                       R t ^ RIt^ RIHtHt ^ RIt^ RIHtHt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 ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t%H&t&H't'H(t(H)t)H*t*H+t+ Rt, ^ RI-t-^ RI.t-^ RI/t-^ RI0t0^ RI1t1^ RI2H3t3H4t4 ^ RI5H6t6  ! R R4      t8 ! R R4      t9R3R lt:R3R lt;R t< ! R R]Pz                  4      t>]+! ]>4      t? ! R R]Pz                  4      t@]+! ]@4      tA ! R R ]@4      tB]+! ]B4      tC ! R! R"]Pz                  4      tD]+! ]D4      tE ! R# R$4      tF]+! ]F4      tG ! R% R&4      tH ! R' R(]P                  ]H4      tJ ! R) R*]P                  ]H4      tK ! R+ R,]P                  ]H4      tL ! R- R.]P                  ]H4      tM ! R/ R0]P                  ]H4      tN ! R1 R2]P                  4      tOR#   ]7 d    Rt, EL8i ; i)4z
Test HTTP/2 support.
N)directlyProvides
providedBy)defererrorreactortask)IPv4Address)MemoryReactorClockStringTransport)deferToThread)failure)	iterbytes)requireModule)DummyProducer)!certificatesForAuthorityAndServer)unittest)http)Site)Data)DelayedHTTPHandlerDelayedHTTPHandlerProxyDummyHTTPHandlerDummyHTTPHandlerProxyDummyPullProducerHandlerProxy._IDeprecatedHTTPChannelToRequestInterfaceProxy_makeRequestProxyFactory)DecoderEncoder)H2ConnectionzHTTP/2 support not enabledc                      a  ] tR t^7t o RtR tR tR t. ^3R ltRR lt	RR lt
R	 tRR
 ltRR ltRR lt. 3R ltRtV tR# )FrameFactoryz
A class containing lots of helper methods and state to build frames. This
allows test cases to easily build correct HTTP/2 frames to feed to
hyper-h2.
c                $    \        4       V n        R # Nr   encoderselfs   &=/usr/lib/python3/dist-packages/twisted/web/test/test_http2.py__init__FrameFactory.__init__>       y    c                $    \        4       V n        R # r"   r#   r%   s   &r'   refreshEncoderFrameFactory.refreshEncoderA   r*   r+   c                    R # )s   PRI * HTTP/2.0

SM

 r%   s   &r'   clientConnectionPreface$FrameFactory.clientConnectionPrefaceD   s    2r+   c                L   \         P                  P                  V4      pV P                  P	                  V4      Vn        VP                  P                  R4       V F  pVP                  P                  V4       K   	  VP                  4        F  w  rx\        WWV4       K  	  V# )zC
Builds a single valid headers frame out of the contained headers.
END_HEADERS)

hyperframeframeHeadersFramer$   encodedataflagsadditemssetattr)	r&   headersr:   streamIDpriorityKwargsfflagkvs	   &&&&,    r'   buildHeadersFrameFrameFactory.buildHeadersFrameG   s     ))(3$$W-	M"DGGKK  #((*DAA! + r+   Nc                    Ve   \        V4      M	\        4       p\        P                  P                  V4      pWn        W$n        V# )z4
Builds a single data frame out of a chunk of data.
)setr5   r6   	DataFramer9   r:   )r&   r9   r:   r?   rA   s   &&&& r'   buildDataFrameFrameFactory.buildDataFrameV   s;     $/E
SU&&x0r+   c                    \         P                  P                  ^ 4      pV'       d   VP                  P	                  R4       Wn        V# )z!
Builds a single settings frame.
ACK)r5   r6   SettingsFramer:   r;   settings)r&   rO   ackrA   s   &&& r'   buildSettingsFrameFrameFactory.buildSettingsFrame`   s7     **1-GGKK
r+   c                P    \         P                  P                  V4      pW#n        V# )z%
Builds a single WindowUpdate frame.
)r5   r6   WindowUpdateFramewindow_increment)r&   r?   	incrementrA   s   &&& r'   buildWindowUpdateFrame#FrameFactory.buildWindowUpdateFramek   s%     ..x8&r+   c                h    \         P                  P                  ^ 4      pW$n        Wn        W4n        V# )z
Builds a single GOAWAY frame.
)r5   r6   GoAwayFrame
error_codelast_stream_idadditional_data)r&   lastStreamID	errorCodeadditionalDatarA   s   &&&& r'   buildGoAwayFrameFrameFactory.buildGoAwayFrames   s0     ((+ '*r+   c                P    \         P                  P                  V4      pW#n        V# )z#
Builds a single RST_STREAM frame.
)r5   r6   RstStreamFramer[   )r&   r?   r_   rA   s   &&& r'   buildRstStreamFrame FrameFactory.buildRstStreamFrame}   s$     ++H5 r+   c                h    \         P                  P                  V4      pW5n        W%n        WEn        V# )z!
Builds a single priority frame.
)r5   r6   PriorityFrame
depends_onstream_weight	exclusive)r&   r?   weight	dependsOnrk   rA   s   &&&&& r'   buildPriorityFrameFrameFactory.buildPriorityFrame   s.     **84  r+   c                    \         P                  P                  V4      pW%n        V P                  P                  V4      Vn        \        V4      Vn        VP                  P                  R4       V# )z%
Builds a single Push Promise frame.
r4   )
r5   r6   PushPromiseFramepromised_stream_idr$   r8   r9   rH   r:   r;   )r&   r?   promisedStreamIDr>   r:   rA   s   &&&&& r'   buildPushPromiseFrame"FrameFactory.buildPushPromiseFrame   sV     --h7/$$W-e*	M"r+   )r$   N   )F)    r+   )rx   )rx   F)__name__
__module____qualname____firstlineno____doc__r(   r-   r1   rE   rJ   rQ   rW   ra   re   rn   rt   __static_attributes____classdictcell____classdict__s   @r'   r    r    7   sT     !!3 02A 	 PR 	 	r+   r    c                   @   a  ] tR t^t o RtR tR tR tR t]t	Rt
V tR# )FrameBuffera  
A test object that converts data received from Twisted's HTTP/2 stack and
turns it into a sequence of hyperframe frame objects.

This is primarily used to make it easier to write and debug tests: rather
than have to serialize the expected frames and then do byte-level
comparison (which can be unclear in debugging output), this object makes it
possible to work with the frames directly.

It also ensures that headers are properly decompressed.
c                2    \        4       V n        R V n        R# )r+   N)r   decoder_datar%   s   &r'   r(   FrameBuffer.__init__   s    y
r+   c                8    V ;P                   V,          un         R # r"   )r   )r&   r9   s   &&r'   receiveDataFrameBuffer.receiveData   s    

d
r+   c                    V # r"   r0   r%   s   &r'   __iter__FrameBuffer.__iter__   s    r+   c                Z   \        V P                  4      ^	8  d   \        4       h\        P                  P
                  P                  V P                  R,          4      w  r\        V P                  4      V^	,           8  d   \        4       hVP                  \        V P                  ^	^	V,            4      4       V P                  ^	V,           R V n        \        V\        P                  P                  4      '       d-   V P                  P                  VP                  RR7      Vn        V# )	   :Nr   NNT)raw)lenr   StopIterationr5   r6   Frameparse_frame_header
parse_body
memoryview
isinstancer7   r   decoder9   )r&   r6   lengths   &  r'   nextFrameBuffer.next   s    tzz?Q/!"((..AA$**R.Qtzz?VaZ'/!DJJq1v:$>?@ZZF
-
eZ--::;;,,UZZT,BEJr+   )r   r   N)ry   rz   r{   r|   r}   r(   r   r   r   __next__r~   r   r   s   @r'   r   r      s%     
  Hr+   r   c                   aa Sf   \        4       o. pVP                  SP                  V SR7      4       VP                  VV3R lV 4       4       VR,          P                  P                  R4       V# )a  
Provides a sequence of HTTP/2 frames that encode a single HTTP request.
This should be used when you want to control the serialization yourself,
e.g. because you want to interleave other frames with these. If that's not
necessary, prefer L{buildRequestBytes}.

@param headers: The HTTP/2 headers to send.
@type headers: L{list} of L{tuple} of L{bytes}

@param data: The HTTP data to send. Each list entry will be sent in its own
frame.
@type data: L{list} of L{bytes}

@param frameFactory: The L{FrameFactory} that will be used to construct the
frames.
@type frameFactory: L{FrameFactory}

@param streamID: The ID of the stream on which to send the request.
@type streamID: L{int}
r>   r?   c              3   J   <"   T F  pSP                  VSR 7      x  K  	  R# 5i)r?   N)rJ   ).0chunkframeFactoryr?   s   & r'   	<genexpr>%buildRequestFrames.<locals>.<genexpr>   s'      KO%##EH#==4s    #
END_STREAM)r    appendrE   extendr:   r;   r>   r9   r   r?   framess   &&ff r'   buildRequestFramesr      sk    * #~F
MM,0080TU
MM KO  2J&Mr+   c                J    \        WW#4      pRP                  R V 4       4      # )a  
Provides the byte sequence for a collection of HTTP/2 frames representing
the provided request.

@param headers: The HTTP/2 headers to send.
@type headers: L{list} of L{tuple} of L{bytes}

@param data: The HTTP data to send. Each list entry will be sent in its own
frame.
@type data: L{list} of L{bytes}

@param frameFactory: The L{FrameFactory} that will be used to construct the
frames.
@type frameFactory: L{FrameFactory}

@param streamID: The ID of the stream on which to send the request.
@type streamID: L{int}
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   	serializer   rA   s   & r'   r   $buildRequestBytes.<locals>.<genexpr>   s     26aKKMM6   )r   joinr   s   &&&& r'   buildRequestBytesr      s%    &  |FF8826222r+   c                N    \        4       pVP                  V 4       \        V4      # )a  
Given a sequence of bytes, decodes them into frames.

Note that this method should almost always be called only once, before
making some assertions. This is because decoding HTTP/2 frames is extremely
stateful, and this function doesn't preserve any of that state between
calls.

@param data: The serialized HTTP/2 frames.
@type data: L{bytes}

@returns: A list of HTTP/2 frames.
@rtype: L{list} of L{hyperframe.frame.Frame} subclasses.
)r   r   list)r9   buffers   & r'   framesFromBytesr      s#     ]F
t<r+   c                   .   a  ] tR tRt o RtRtR tRtV tR# )ChunkedHTTPHandleri  z
A HTTP request object that writes chunks of data back to the network based
on the URL.

Must be called with a path /chunked/<num_chunks>
s   hello world!c                    \        V P                  P                  R 4      R,          4      pV P                  ^4       \	        V4       F  pV P                  V P                  4       K   	  V P                  4        R# )   /Nr   )inturisplitsetResponseCoderangewrite	chunkDatafinish)r&   chunks_s   &  r'   processChunkedHTTPHandler.process  sU    TXX^^D)"-.S!vAJJt~~&  	r+   r0   N)	ry   rz   r{   r|   r}   r   r   r~   r   r   s   @r'   r   r     s       I r+   r   c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	ConsumerDummyHandleri(  z
This is a HTTP request handler that works with the C{IPushProducer}
implementation in the L{H2Stream} object. No current IRequest object does
that, but in principle future implementations could: that codepath should
therefore be tested.
c                    \         P                  P                  ! V .VO5/ VB  V P                  P	                  4        R V n        RV n        R# )FN)r   Requestr(   channelpauseProducing_requestReceivedr   r&   argskwargss   &*,r'   r(   ConsumerDummyHandler.__init__0  s?    d4T4V4 	##% %
r+   c                :    V P                   P                  4        R# )z
Start the data pipe.
N)r   resumeProducingr%   s   &r'   
acceptDataConsumerDummyHandler.acceptData8  s     	$$&r+   c                X    R V n         \        P                  P                  ! V .VO5/ VB # )T)r   r   r   requestReceivedr   s   &*,r'   r   $ConsumerDummyHandler.requestReceived>  s)     $||++DB4B6BBr+   c                    V P                  ^4       V P                  P                  4       V n        RpV P	                  V4       V P                  4        R# )   s0   this is a response from a consumer dummy handlerN)r   contentreadr   r   r   )r&   
returnDatas   & r'   r   ConsumerDummyHandler.processB  s>    S!\\&&(
H


:r+   )r   r   N)ry   rz   r{   r|   r}   r(   r   r   r   r~   r   r   s   @r'   r   r   (  s$     'C r+   r   c                   *   a  ] tR tRt o RtR tRtV tR# )AbortingConsumerDummyHandleriM  z
This is a HTTP request handler that works with the C{IPushProducer}
implementation in the L{H2Stream} object. The difference between this and
the ConsumerDummyHandler is that after resuming production it immediately
aborts it again.
c                n    V P                   P                  4        V P                   P                  4        R# )z0
Start and then immediately stop the data pipe.
N)r   r   stopProducingr%   s   &r'   r   'AbortingConsumerDummyHandler.acceptDataU  s$     	$$&""$r+   r0   N)ry   rz   r{   r|   r}   r   r~   r   r   s   @r'   r   r   M  s     % %r+   r   c                   *   a  ] tR tRt o RtR tRtV tR# )DummyProducerHandlerib  z
An HTTP request handler that registers a dummy producer to serve the body.

The owner must call C{finish} to complete the response.
c                \    V P                  ^4       V P                  \        4       R4       R# )r   TN)r   registerProducerr   r%   s   &r'   r   DummyProducerHandler.processi  s"    S!mot4r+   r0   N)ry   rz   r{   r|   r}   r   r~   r   r   s   @r'   r   r   b  s     5 5r+   r   c                   0   a  ] tR tRt o RtR tR tRtV tR# )NotifyingRequestFactoryiq  a  
A L{http.Request} factory that calls L{http.Request.notifyFinish} on all
L{http.Request} objects before it returns them, and squirrels the resulting
L{defer.Deferred} away on the class for later use. This is done as early
as possible to ensure that we always see the result.
c                n    . V n         Wn        \        V P                  4       F  p\        W4       K  	  R # r"   )results_wrappedFactoryr   r   )r&   wrappedFactory	interfaces   && r'   r(    NotifyingRequestFactory.__init__y  s.    -
 $D$8$89IT- :r+   c                    V P                   ! V/ VB pV P                  P                  VP                  4       4       \	        V4      # r"   )r   r   r   notifyFinishr   )r&   r   r   reqs   &*, r'   __call__ NotifyingRequestFactory.__call__  s=    ""D3F3C,,./=cBBr+   )r   r   N)	ry   rz   r{   r|   r}   r(   r   r~   r   r   s   @r'   r   r   q  s     .C Cr+   r   c                   >   a  ] tR tRt o Rt]'       d   ]tR tRtV t	R# )HTTP2TestHelpersi  zQ
A superclass that contains no tests but provides test helpers for HTTP/2
tests.
c                d    V P                  \        P                  \        VP                  4       R# )z}
Confirm that all streams are blocked: that is, the priority tree
believes that none of the streams have data ready to send.
N)assertRaisespriorityDeadlockErrorr   )r&   
connections   &&r'   assertAllStreamsBlocked(HTTP2TestHelpers.assertAllStreamsBlocked  s"    
 	(00$
8K8KLr+   r0   N)
ry   rz   r{   r|   r}   skipH2skipr   r~   r   r   s   @r'   r   r     s      
 M Mr+   r   c                     a  ] tR tRt o . R'Ot. R(Ot. R)Ot. R*OtRt. R+O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,V t-R&# ),HTTP2ServerTestsi     '''
None
'''
$   '''
25
hello world, it's http/2!'''
c                    \        4       p\        4       pVP                  4       pV\        W#V4      ,          pVP	                  V4       \        V4       F  pVP                  V4       K  	  WE3# )a  
Takes a single L{H2Connection} object and connects it to a
L{StringTransport} using a brand new L{FrameFactory}.

@param connection: The L{H2Connection} object to connect.
@type connection: L{H2Connection}

@param headers: The headers to send on the first request.
@type headers: L{Iterable} of L{tuple} of C{(bytes, bytes)}

@param body: Chunks of body to send, if any.
@type body: L{Iterable} of L{bytes}

@return: A tuple of L{FrameFactory}, L{StringTransport}
)r    r
   r1   r   makeConnectionr   dataReceived)r&   r   r>   bodyr   	transportrequestBytesbytes   &&&&    r'   connectAndReceive"HTTP2ServerTests.connectAndReceive  si      $~#%	#;;=)'FF!!),l+D##D) , &&r+   c                   a a \        4       p\        Vn        S P                  VS P                  . 4      w  poV V3R lpVP
                  ^,          P                  V4      # )zu
Send request over a TCP connection and confirm that we get back the
expected data in the order and style we expect.
c                   < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \
        ;QJ d#    R VR,           4       F  '       d   K   RM	  RM! R VR,           4       4      4       SP	                  \        V^,          \        P                  P                  4      4       SP	                  \        V^,          \        P                  P                  4      4       SP	                  \        V^,          \        P                  P                  4      4       SP                  \        V^,          P                  4      \        SP                  4      4       SP                  V^,          P                  SP                  4       SP                  V^,          P                  R4       SP	                  RV^,          P                  9   4       R# )   c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5irw   N	stream_idr   s   & r'   r   GHTTP2ServerTests.test_basicRequest.<locals>.validate.<locals>.<genexpr>       E*Qq 0*   rw   NNFTr+   r   N)r   valueassertEqualr   
assertTrueallr   r5   r6   r7   rI   dictr9   getResponseHeadersgetResponseDatar:   r?   r   r&   r  s   & r'   validate4HTTP2ServerTests.test_basicRequest.<locals>.validate  s7   $Y__%67FS[!,OOCCE&*ECCCE&*EEFOOJvay*2B2B2O2OPQOOJvay*2B2B2L2LMNOOJvay*2B2B2L2LMNT&)..148O8O3PQVAY^^T-A-ABVAY^^S1OOLF1IOO;<r+   )r   r   requestFactoryr  getRequestHeaders_streamCleanupCallbacksaddCallbackr&   r   r   r$  r  s   f   @r'   test_basicRequest"HTTP2ServerTests.test_basicRequest  sV     "^
$9
!--j$:P:PRTU9	= 11!4@@JJr+   c                   a a \        4       p\        Vn        S P                  VS P                  S P
                  4      w  poV V3R lpVP                  ^,          P                  V4      # )zF
Send a POST request and confirm that the data is safely transferred.
c                   < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \
        ;QJ d    R VRR  4       F  '       d   K   RM	  RM! R VRR  4       4      4       SP	                  \        VR,          \        P                  P                  4      4       SP	                  \        VR,          \        P                  P                  4      4       SP	                  \        VR	,          \        P                  P                  4      4       SP                  \        VR,          P                  4      \        SP                  4      4       SP                  VR,          P                  SP                  4       SP                  VR	,          P                  R4       SP	                  RVR	,          P                  9   4       R# )
r  c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5ir  r  r   s   & r'   r   FHTTP2ServerTests.test_postRequest.<locals>.validate.<locals>.<genexpr>       F+Qq 0+r  NFTr+   r   r   )r   r  r  r   r  r  r   r5   r6   r7   rI   r   r9   postResponseHeaderspostResponseDatar:   r#  s   & r'   r$  3HTTP2ServerTests.test_postRequest.<locals>.validate
  s?   $Y__%67F S[!,OOCCF&+FCCCF&+FFGOOJvbz:3C3C3P3PQROOJvbz:3C3C3M3MNOOOJvbz:3C3C3M3MNOT&*//2D9Q9Q4RSVBZ__d.C.CDVBZ__c2OOLF2J,<,<<=r+   )r   r   r&  r  postRequestHeaderspostRequestDatar(  r)  r*  s   f   @r'   test_postRequest!HTTP2ServerTests.test_postRequest   s^     "^
$9
!--//1E1E
9	>  11!4@@JJr+   c                2  a aaa	 . ROoRoS P                    UUu. uF  w  rVR8w  g   K  W3NK  	  ppp\        4       p\        Vn        S P	                  WCS P
                  4      w  po	VVV V	3R lpVP                  ^,          P                  V4      # u uppi )zU
Send a POST request without length and confirm that the data is safely
transferred.
   content-lengths&   '''
None
hello world, it's http/2!'''
c                   < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \
        ;QJ d    R VRR  4       F  '       d   K   RM	  RM! R VRR  4       4      4       SP	                  \        VR,          \        P                  P                  4      4       SP	                  \        VR,          \        P                  P                  4      4       SP	                  \        VR	,          \        P                  P                  4      4       SP                  \        VR,          P                  4      \        S4      4       SP                  VR,          P                  S4       SP                  VR	,          P                  R4       SP	                  RVR	,          P                  9   4       R# )
r  c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5ir  r  r   s   & r'   r   NHTTP2ServerTests.test_postRequestNoLength.<locals>.validate.<locals>.<genexpr>:  r1  r  NFTr+   r   r2  r3  r   )r   r  r  r   r  r  r   r5   r6   r7   rI   r   r9   r:   )r?   r   r5  r4  r&   r  s   & r'   r$  ;HTTP2ServerTests.test_postRequestNoLength.<locals>.validate5  s5   $Y__%67F S[!,OOCCF&+FCCCF&+FFGOOJvbz:3C3C3P3PQROOJvbz:3C3C3M3MNOOOJvbz:3C3C3M3MNOT&*//2D9L4MNVBZ__.>?VBZ__c2OOLF2J,<,<<=r+   )   :statuss   200   request   /post_endpoint   command   POSTs   versions   HTTP/2)r<  s   38)r7  r   r   r&  r  r8  r(  r)  )
r&   xyr7  r   r   r$  r5  r4  r  s
   f      @@@r'   test_postRequestNoLength)HTTP2ServerTests.test_postRequestNoLength  s    

 H  $66
6tq!?P:PFQF6 	 
 "^
$9
!--D,@,@
9	> 	>  11!4@@JJ5
s
   BBc           	       a a	a
 ^(p\        4       p\        4       o	\        4       p\        Vn        \        \        ^V^,          ^4      4      o
S
 Uu. uF$  p\        S P                  S P                  W$4      NK&  	  ppVP                  4       p\        P                  P                  \        V!  4      pVRP                  R V 4       4      ,          pVP!                  S	4       \#        V4       F  pVP%                  V4       K  	  V	V V
3R lp\&        P(                  ! \        VP*                  P-                  4       4      4      P/                  V4      # u upi )zQ
Many interleaved POST requests all get received and responded to
appropriately.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   r6   s   & r'   r   <HTTP2ServerTests.test_interleavedRequests.<locals>.<genexpr>b        Gu!2!2r   c                   < \        SP                  4       4      pSP                  \        V4      ^y4       S EF#  pV Uu. uFD  pVP                  V8X  g   K  \        V\        P                  P                  4      '       d   KB  VNKF  	  ppSP                  \        V4      ^4       SP                  \        V^ ,          P                  4      \        SP                  4      4       SP                  V^,          P                  SP                  4       SP                  V^,          P                  R4       SP                  RV^,          P                  9   4       EK&  	  R# u upi )rw   r+   r   N)r   r  r  r   r  r   r5   r6   rT   r   r9   r4  r5  r  r:   )r   r   r?   rA   streamFramesbr&   	streamIDss   &    r'   r$  ;HTTP2ServerTests.test_interleavedRequests.<locals>.validateh  s"   $QWWY/F
 S[,7 & $ #{{h.  'q**:*:*L*LM A#      \!2A6  a--.T5M5M0N   a!5!5t7L7LM  a!5!5s;Q0E0E EF & s    E"'E"E")r    r
   r   r   r&  r   r   r   r7  r8  r1   	itertoolschainfrom_iterablezipr   r	  r   r
  r   DeferredListr(  valuesr)  )r&   REQUEST_COUNTrA   ar?   r   r  r  r$  rU  rV  s   f        @@r'   test_interleavedRequests)HTTP2ServerTests.test_interleavedRequestsG  s/    NN0 q-!"3Q78	
 &	
 & '')=)=q &	 	 
 002 ..sF|< G GGG	l+DNN4  ,	G6 !!$q'@'@'G'G'I"JKWW
 	
[
s   *Ec           	       a a
 \        4       p\        4       o
\        4       p\        Vn        S P
                  pRV^&   R Uu. uF  p\        V. W4      NK  	  ppV^ ,          ^ ,          P                  P                  R4       ^@V^ ,          ^ ,          n	        V^,          ^ ,          P                  P                  R4       ^ V^,          ^ ,          n	        VP                  ^^^RR7      pV^,          P                  ^ V4       \        P                  P                  V4      pVP                  4       pVRP!                  R V 4       4      ,          pVP#                  S
4       \%        V4       F  pVP'                  V4       K  	  V
V 3R lp	\(        P*                  ! \-        VP.                  P1                  4       4      4      P3                  V	4      # u upi )	zB
Data in responses is interleaved according to HTTP/2 priorities.
PRIORITYT)r?   rl   rm   rk   r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   rP  s   & r'   r   @HTTP2ServerTests.test_sendAccordingToPriority.<locals>.<genexpr>  rR  r   c                 2  < \        SP                  4       4      pSP                  \        V4      ^4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  pp. ROpSP                  W44       R# u upi )   N)rw      rw   rw   rh  rw   rw   rh     rh  ri  rh  ri  ri  ri  )	r   r  r  r   r   r5   r6   rI   r  )r   r   rA   rV  expectedOrderrU  r&   s   &    r'   r$  ?HTTP2ServerTests.test_sendAccordingToPriority.<locals>.validate  s}    $QWWY/F S["- &,%+z!Z=M=M=W=W/XV   JMY6	s   ,B+B)z:pathz
/chunked/4)rw   rh  ri  )r    r
   r   ChunkedHTTPHandlerProxyr&  r'  r   r:   r;   rj   rn   insertrX  rY  rZ  r1   r   r	  r   r
  r   r\  r   r(  r]  r)  )r&   rA   r_  r'  r?   r   priorityFramer  r  r$  rU  s   f         @r'   test_sendAccordingToPriority-HTTP2ServerTests.test_sendAccordingToPriority  s   " NN2 226! &
% 0"aB% 	 
 	q	!z*%'q	!"q	!z*%'q	!",,	 - 
 	q	M*..v6002 G GGG	l+DNN4  ,	7 !!$q'@'@'G'G'I"JKWW
 	
W
s   Gc                   \        4       p\        4       p\        4       p\        Vn        VP                  4       pV\        V P                  . V4      ,          pWAP                  ^^V P                  R.R7      P                  4       ,          pVP                  V4       \        V4       F(  pVP                  V4       VP                  '       g   K(   M	  \        VP                  4       4      pV P!                  \#        V4      ^4       V P%                  \'        VR,          \(        P*                  P,                  4      4       V P%                  VP                  4       R# )zB
A protocol error from the remote peer terminates the connection.
r4   )r?   rs   r>   r:   Nr   )r    r
   r   r   r&  r1   r   r'  rt   r   r	  r   r
  disconnectingr   r  r  r   r  r   r5   r6   rZ   )r&   rA   rU  r_  r  r  r   s   &      r'   &test_protocolErrorTerminatesConnection7HTTP2ServerTests.test_protocolErrorTerminatesConnection  s    NN0 002)$*@*@"aHH//** /	 0 

 )+	 	
l+DNN4   , !+
 	Va(
6":z/?/?/K/KLM(r+   c                  a a \        4       p\        Vn        S P                  VS P                  S P
                  4      w  poVP                  ^,          P                  P                  pS P                  VP                  4       \        SP                  4       4      pS P                  \        V4      ^4       VP                  4        S P!                  VP                  4       S P!                  VP"                  R4       \        SP                  4       4      pS P                  \        V4      ^4       V V3R lpVP$                  ^,          P'                  V4      # )z
The H2Stream data implements IPushProducer, and can have its data
production controlled by the Request if the Request chooses to.
s   hello world, it's http/2!c                    < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  RVR,          P
                  9   4       R# r  r   Nr   r   r  r  r   r  r:   r#  s   & r'   r$  ;HTTP2ServerTests.test_streamProducingData.<locals>.validate  sE    $Y__%67F S[!,OOLF2J,<,<<=r+   )r   ConsumerDummyHandlerProxyr&  r  r7  r8  streams_requestoriginalassertFalser   r   r  r  r   r   r  r   r(  r)  )r&   r   r   requestr   r$  r  s   f     @r'   test_streamProducingData)HTTP2ServerTests.test_streamProducingData  s   
 "^
$=
!--//1E1E
9 $$Q'0099112
 !!23Va(
 	001'CD
 !!23Va(	> 11!4@@JJr+   c                  a a	 \        4       p\        4       o	\        4       p\        Vn        \        S P                  S P                  V4      p\        4       VR,          n	        VP                  4       pVRP                  R V 4       4      ,          pVP                  S	4       \        V4       F  pVP                  V4       K  	  VP                  ^,          P                   P"                  pS P%                  VP&                  4       VP(                  ^,          pVP+                  4        V	V 3R lpVP-                  V4      # )z
The H2Stream data implements IPushProducer, and can have its data
production controlled by the Request if the Request chooses to.
When the production is stopped, that causes the stream connection to
be lost.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   AHTTP2ServerTests.test_abortStreamProducingData.<locals>.<genexpr>2        ?1r   c                 *  < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \        VR,          \        P                  P                  4      4       SP                  VR,          P                  ^4       R# )   Nr   )
r   r  r  r   r  r   r5   r6   rd   r  )r?   r   rU  r&   s   & r'   r$  @HTTP2ServerTests.test_abortStreamProducingData.<locals>.validateE  sf    $QWWY/F S[!,OOJvbz:3C3C3R3RSTVBZ1115r+   r   )r    r
   r   !AbortingConsumerDummyHandlerProxyr&  r   r7  r8  rH   r:   r1   r   r	  r   r
  r{  r|  r}  r~  r   r(  r   r)  )
r&   rA   r_  r   r  r  r  cleanupCallbackr$  rU  s
   f        @r'   test_abortStreamProducingData.HTTP2ServerTests.test_abortStreamProducingData"  s    NN< $D$;$;T=Q=QSTU5r
002 ? ???	l+DNN4  ,
 ))A,''00112 33A6 		6 **844r+   c                J  a a \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          P                  P                  pVP                  R4       VP                  R4       VP                  ^,          pVP                  VP                  ^^R7      P                  4       4       S P                  VP                  4       S P                  VP                  RJ 4       VP                  R4       V V3R lpVP!                  V4      # )z
When a RstStream frame is received, the L{H2Connection} and L{H2Stream}
objects tear down the L{http.Request} and swallow all outstanding
writes.
   first chunk   second chunk)r_   Ns   third chunkc                 *  < \        SP                  4       4      pSP                  \        V4      ^4       SP                  V^,          P                  ^4       SP                  \        V^,          \        P                  P                  4      4       R# r  N
r   r  r  r   r  r  r   r5   r6   r7   r#  s   & r'   r$  9HTTP2ServerTests.test_terminatedRequest.<locals>.validate{  e    $Y__%67FS[!,VAY00!4OOJvay*2B2B2O2OPQr+   )r   DummyProducerHandlerProxyr&  r  r'  r{  r|  r}  r   r(  r
  re   r   r  _disconnectedr   r)  r&   r   r   r  r  r$  r  s   f     @r'   test_terminatedRequest'HTTP2ServerTests.test_terminatedRequestP  s     "^
$=
!"&"8"8..#
i
 $$Q'0099 	n%o& %<<Q? 	,,Q!,<FFH	

 	--.4/0 	n%	R **844r+   c                \  a a \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          P                  P                  pVP                  R4       VP                  R4       VP                  ^,          pVP                  VP                  ^ R7      P                  4       4       S P                  VP                  4       S P                  VP                  RJ 4       S P!                  VP"                  4       V V3R lpVP%                  V4      # )z
When a GoAway frame is received, the L{H2Connection} and L{H2Stream}
objects tear down all outstanding L{http.Request} objects and stop all
writing.
r  r  r^   Nc                 *  < \        SP                  4       4      pSP                  \        V4      ^4       SP                  V^,          P                  ^4       SP                  \        V^,          \        P                  P                  4      4       R# r  r  r#  s   & r'   r$  <HTTP2ServerTests.test_terminatedConnection.<locals>.validate  r  r+   )r   r  r&  r  r'  r{  r|  r}  r   r(  r
  ra   r   r  r  r   r~  _stillProducingr)  r  s   f     @r'   test_terminatedConnection*HTTP2ServerTests.test_terminatedConnection  s    "^
$=
!"&"8"8..#
i
 $$Q'0099 	n%o& %<<Q? 	))q)9CCE	

 	--.4/0 	334	R **844r+   c                   a a \        4       p\        Vn        S P                  R.,           pS P	                  W. 4      w  poV V3R lpVP
                  ^,          P                  V4      # )zY
Requests containing Expect: 100-continue cause provisional 100
responses to be emitted.
c                   < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \
        ;QJ d#    R VR,           4       F  '       d   K   RM	  RM! R VR,           4       4      4       SP	                  \        V^,          \        P                  P                  4      4       SP                  V^,          P                  R.4       SP	                  RVR,          P                  9   4       R# )	ri  c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5ir  r  r   s   & r'   r   QHTTP2ServerTests.test_respondWith100Continue.<locals>.validate.<locals>.<genexpr>  r  r  r  FTr   N)rB  s   100r   )r   r  r  r   r  r  r   r5   r6   r7   r9   r:   r#  s   & r'   r$  >HTTP2ServerTests.test_respondWith100Continue.<locals>.validate  s    $Y__%67FS[!,OOCCE&*ECCCE&*EEFOOJvay*2B2B2O2OPQVAY^^.B-CDOOLF2J,<,<<=r+   )s   expects   100-continue)r   r   r&  r'  r  r(  r)  )r&   r   r>   r   r$  r  s   f    @r'   test_respondWith100Continue,HTTP2ServerTests.test_respondWith100Continue  sc    
 "^
$9
! ((,H+II--j2F9
	> 11!4@@JJr+   c                  a a \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          pVP                  P                  pVP                  ^,          pVP                  4        S P                  VP                  4       S P                  VP                  RJ 4       V V3R lpVP                  V4      # )z
Triggering the call to L{H2Stream._respondToBadRequestAndDisconnect}
leads to a 400 error being sent automatically and the stream being torn
down.
Nc                 v  < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \        V^,          \        P                  P                  4      4       SP                  V^,          P                  R.4       SP	                  RVR,          P                  9   4       R# )r  r   N)rB  s   400r   )r   r  r  r   r  r   r5   r6   r7   r9   r:   r#  s   & r'   r$  6HTTP2ServerTests.test_respondWith400.<locals>.validate  s    $Y__%67FS[!,OOJvay*2B2B2O2OPQVAY^^.B-CDOOLF2J,<,<<=r+   )r   r  r&  r  r'  r{  r|  r}  r(  !_respondToBadRequestAndDisconnectr  r  r   r)  )r&   r   r   streamr  r  r$  r  s   f      @r'   test_respondWith400$HTTP2ServerTests.test_respondWith400  s     "^
$=
!--j$:P:PRTU9 ##A&//**$<<Q? 	002 	--.4/0	> **844r+   c                t  a aa \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          pVP                  P                  p. ROoS F  pVP                  V4       K  	  VP                  4        VV V3R lpVP                  ^,          P                  V4      # )z
Calling L{Request.loseConnection} causes all data that has previously
been sent to be flushed, and then the stream cleanly closed.
c                   < \        SP                  4       4      pSP                  \        V4      ^	4       SP	                  \
        ;QJ d#    R VR,           4       F  '       d   K   RM	  RM! R VR,           4       4      4       SP	                  \        V^,          \        P                  P                  4      4       SP	                  RVR,          P                  9   4       V Uu. uF;  p\        V\        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  VSR.,           4       R# u upi )	r   c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5ir  r  r   s   & r'   r   QHTTP2ServerTests.test_loseH2StreamConnection.<locals>.validate.<locals>.<genexpr>  r  r  r  FTr   r+   Nr   r   r  r  r   r  r  r   r5   r6   r7   r:   rI   r9   )r?   r   rA   receivedDataChunks
dataChunksr&   r  s   &   r'   r$  >HTTP2ServerTests.test_loseH2StreamConnection.<locals>.validate  s    $Y__%67F S[!,OOCCE&*ECCCE&*EEFOOJvay*2B2B2O2OPQOOLF2J,<,<<= !'" &1*Q
8H8H8R8R*S  " "cU""s   *,E	E	)   hello   world   here   are   some   writes)r   r  r&  r  r'  r{  r|  r}  r   loseConnectionr(  r)  )	r&   r   r   r  r  r   r$  r  r  s	   f      @@r'   test_loseH2StreamConnection,HTTP2ServerTests.test_loseH2StreamConnection  s     "^
$=
!--j$:P:PRTU9 ##A&//** O
EMM%    	 	$ 11!4@@JJr+   c                    \        4       p\        Vn        V P                  WP                  . 4       VP
                  ^,          pVP                  P                  pV P                  \        VP                  VR4       R# )z;
The L{H2Stream} object forbids registering two producers.
TN)r   r  r&  r  r'  r{  r|  r}  r   
ValueErrorr   )r&   r   r  r  s   &   r'   test_cannotRegisterTwoProducers0HTTP2ServerTests.test_cannotRegisterTwoProducers)  sd     "^
$=
!z+A+A2F ##A&//***f&=&=wMr+   c                l  a aa \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          pVP                  P                  oSP                  P                  pVP                  V3R l4       V V3R lpVP                  ^,          P                  V4      # )zt
L{Request} objects that have registered pull producers get blocked and
unblocked according to HTTP/2 flow control.
c                 $   < SP                  4       # r"   )r   )rJ  r  s   &r'   <lambda>;HTTP2ServerTests.test_handlesPullProducer.<locals>.<lambda>E  s    w~~/?r+   c                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  V. RO4       R# u upi )r   Nr   )   0   1   2   3   4   5   6   7   8   9r+   
r   r  r  r:   r   r5   r6   rI   r9   r  r?   r   rA   r  r&   r  s   &   r'   r$  ;HTTP2ServerTests.test_handlesPullProducer.<locals>.validateH  s    $Y__%67F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Q   ,B5B)r   r   r&  r  r'  r{  r|  r}  _actualProducerresultr)  r(  )r&   r   r   r  producerCompleter$  r  r  s   f     @@r'   test_handlesPullProducer)HTTP2ServerTests.test_handlesPullProducer7  s    
 "^
$A
!--j$:P:PRTU9 ##A&//**"2299$$%?@	 11!4@@JJr+   c                6   \        4       p\        Vn        V P                  WP                  . 4       VP
                  ^,          P                  P                  pV P                  VP                  4       4       VP
                  ^,          P                  4        R# )z:
L{Request} objects can correctly ask isSecure on HTTP/2.
N)r   r   r&  r  r'  r{  r|  r}  r~  isSecureabortConnection)r&   r   r  s   &  r'   test_isSecureWorksProperly+HTTP2ServerTests.test_isSecureWorksProperlyY  ss     "^
$;
!z+A+A2F$$Q'0099))+,1--/r+   c                R  a a \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          P                  P                  p\        P                  ! RVP                  4       V V3R lpVP                  ^,          P                  V4      # )z<
L{H2Connection} correctly unblocks when a stream is ended.
{Gz?c                     < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  RVR,          P
                  9   4       R# )rh  r   Nr   rx  )r   r   r&   r  s   * r'   validateCompleteCHTTP2ServerTests.test_lateCompletionWorks.<locals>.validateCompleter  sE    $Y__%67F S[!,OOLF2J,<,<<=r+   )r   r   r&  r  r'  r{  r|  r}  r   	callLaterr   r(  r)  )r&   r   r   r  r  r  s   f    @r'   test_lateCompletionWorks)HTTP2ServerTests.test_lateCompletionWorkse  s     "^
$;
!--j$:P:PRTU9 $$Q'0099$/	> 11!4@@AQRRr+   c                  a a \        4       p\        Vn        S P                  VS P                  . 4      w  poVP
                  ^,          pVP                  P                  pVP                  ^4       VP                  . RO4       VP                  4        VP                  ^,          pV V3R lpVP                  V4      # )zG
L{H2Stream} objects can send a series of frames via C{writeSequence}.
c                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  V. RO4       R# u upi )r   Nr   )   Hello   ,   world!r+   r  r  s   &   r'   r$  @HTTP2ServerTests.test_writeSequenceForChannels.<locals>.validate  s    $Y__%67F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Z)IJr  )r  r  r  )r   r   r&  r  r'  r{  r|  r}  r   writeSequencer   r(  r)  )r&   r   r   r  r  completionDeferredr$  r  s   f      @r'   test_writeSequenceForChannels.HTTP2ServerTests.test_writeSequenceForChannels{  s     "^
$;
!--j$:P:PRTU9##A&//**$89'??B
	K "--h77r+   c                  a aaa	a
a \        4       o
\        4       o\        4       o\        Sn        S
P                  4       pVS
P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . S
4      ,          pSP                  S4       \        V4       F  pSP!                  V4       K  	  SP"                  ^,          pVP$                  P&                  oSP)                  R4       . ROo	V	V3R lp\*        P,                  ! \.        RV4      pVP1                  VV
3R l4       VV	V 3R lpSP2                  ^,          P1                  V4      # )z
Delaying writes from L{Request} causes the L{H2Connection} to block on
sending until data is available. However, data is *not* sent if there's
no room in the flow control window.
   fiverc                  \   < S F  p SP                  V 4       K  	  SP                  4        R # r"   )r   r   )r   r  r  s    r'   write_chunks7HTTP2ServerTests.test_delayWrites.<locals>.write_chunks  s#    #e$ $NNr+   r  c                  d   < SP                  SP                  ^^2R7      P                  4       4      # )rw   r?   rV   )r
  rW   r   )r   r_  rA   s   *r'   r  3HTTP2ServerTests.test_delayWrites.<locals>.<lambda>  s*    !..((!r(BLLNr+   c                   < \        SP                  4       4      pSP                  \        V4      ^	4       SP	                  \
        ;QJ d#    R VR,           4       F  '       d   K   RM	  RM! R VR,           4       4      4       SP	                  \        V^,          \        P                  P                  4      4       SP	                  RVR	,          P                  9   4       V Uu. uF;  p\        V\        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  VR.S,           R.,           4       R# u upi )
r   c              3   >   "   T F  qP                   ^8H  x  K  	  R# 5ir  r  r   s   & r'   r   FHTTP2ServerTests.test_delayWrites.<locals>.validate.<locals>.<genexpr>  r  r  :r  NNFTr   r  r+   Nr   r  )r?   r   rA   r  rU  r  r&   s   &   r'   r$  3HTTP2ServerTests.test_delayWrites.<locals>.validate  s    $QWWY/F S[!,OOCCE&*ECCCE&*EEFOOJvay*2B2B2O2OPQOOLF2J,<,<<= !'" &1*Q
8H8H8R8R*S  " "
Z'3%/"s   *,EE)r  r  r  r  )r    r
   r   r   r&  r1   rQ   h2rO   SettingCodesINITIAL_WINDOW_SIZEr   r   r'  r	  r   r
  r{  r|  r}  r   r   
deferLaterr   r)  r(  )r&   r  r  r  r  dr$  r_  rU  r  rA   r  s   f      @@@@@r'   test_delayWrites!HTTP2ServerTests.test_delayWrites  s*    NN2002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , 1//** 	h:
	 OOGT<8		
	$ ((+77AAr+   c                   \        4       p\        4       p\        4       p\        Vn        VP                  4       pV\        V P                  . VR7      ,          pWAP                  ^R7      P                  4       ,          pVP                  V4       VP                  V4       \        VP                  4       4      pV P                  \        V4      ^4       V P!                  ^VP"                  4       R# )z]
A client that immediately resets after sending the body causes Twisted
to send no response.
r>   r9   r   r   N)r    r
   r   r   r&  r1   r   r'  re   r   r	  r
  r   r  r  r   assertNotInr(  )r&   r   r  r_  r  r   s   &     r'   test_resetAfterBody$HTTP2ServerTests.test_resetAfterBody  s    
 $~#%	N0#;;=)**,
 	
 	88!8DNNPP	#	|$ !23Va(A556r+   c                  a aa \         P                  ! 4       o ! V3R lR\        4      p\        4       o\        P
                  ! 4       p\        V4      Sn        VSn        \        4       Sn
        S P                  SS P                  . 4       VV 3R lpSP                  V4       SP                  ^,          p\         P                  ! SV.4      # )zi
A custom L{Request} subclass that requires the site and factory in the
constructor is able to get them.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )THTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.SuperRequesti  c                   < \         P                  ! V .VO5/ VB  SP                  V P                  P                  V P                  P
                  34       R # r"   )r   r(   callbackr   sitefactory)r&   r   r   r  s   &*,r'   r(   ]HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.SuperRequest.__init__  s@     ))$@@@

DLL--t||/C/CDEr+   r0   N)ry   rz   r{   r|   r(   r~   r   )r   r  s   @r'   SuperRequestr    s     F Fr+   r  c                    < V w  rSP                  VSP                  4       SP                  VSP                  4       R # r"   )assertIsr  r  )r   r  r  r   r&   s   &  r'   validateFactoryAndSite^HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.validateFactoryAndSite	  s0     MDMM$
0MM':#5#56r+   )r   Deferredr   r   r   HTTPFactoryr   r&  r  objectr  r  r'  r)  r(  gatherResults)r&   r  httpFactoryr  r  r   r  s   f    @@r'   -test_RequestRequiringFactorySiteInConstructor>HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor  s    
 NN	F+ 	F
 "^
&&($<\$J
! )
 (
z4+A+A2F	7
 	
,- %<<Q?""A#788r+   c                t  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#VP                  P                  pS P                  \        V4      ^4       V 3R lpV^ ,          pVP                  V4       VP                  ^,          p\        P                  ! Wg.4      # )zm
A request sent to a HTTP/2 connection fires the
L{http.Request.notifyFinish} callback with a L{None} value.
c                 *   < SP                  V 4       R # r"   )assertIsNone)r  r&   s   &r'   r$  ?HTTP2ServerTests.test_notifyOnCompleteRequest.<locals>.validate!  s    f%r+   )r   r   r   r&  r  r'  r   r  r   r)  r(  r   r  )r&   r   r   r  	deferredsr$  r  r  s   f       r'   test_notifyOnCompleteRequest-HTTP2ServerTests.test_notifyOnCompleteRequest  s    
 "^
$;<L$M
!--j$:P:PRTU--55	Y+	& aL	h %<<Q?""A#788r+   c                  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#VP                  P                  pS P                  \        V4      ^4       V 3R lpV 3R lpV^ ,          pVP                  WV4       VP                  ^R7      P                  4       pVP                  V4       V# )z_
A HTTP/2 reset stream fires the L{http.Request.notifyFinish} deferred
with L{ConnectionLost}.
c                 *   < SP                  R 4       R# z#Didn't errback, called back insteadNfailignr&   s   &r'   r  ;HTTP2ServerTests.test_notifyOnResetStream.<locals>.callback<      II;<r+   c                    < SP                  V \        P                  4       SP                  V P                  \
        P                  4       R # r"   assertIsInstancer   Failurer  typer   ConnectionLostreasonr&   s   &r'   errback:HTTP2ServerTests.test_notifyOnResetStream.<locals>.errback?  2    !!&'//:MM&++u';';<r+   r   )r   r   r   r&  r  r'  r   r  r   addCallbacksre   r   r
  )	r&   r   r   r  r#  r  r7  r  invalidDatas	   f        r'   test_notifyOnResetStream)HTTP2ServerTests.test_notifyOnResetStream,  s    
 "^
$;<N$O
!"&"8"8..#
 --55	Y+	=	
 aL	x) #666BLLN,r+   c                  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#\        S P
                  . V^R7      pVP                  V4       VP                  P                  pS P                  \        V4      ^4       V 3R lpV 3R lpV F  pVP                  Wg4       K  	  VP                  R^R7      P                  4       p	VP                  V	4       \        P                  ! V4      # )z
A HTTP/2 protocol error triggers the L{http.Request.notifyFinish}
deferred for all outstanding requests with a Failure that contains the
underlying exception.
r   r?   c                 *   < SP                  R 4       R# r(  r)  r+  s   &r'   r  =HTTP2ServerTests.test_failWithProtocolError.<locals>.callbackg  r.  r+   c                    < SP                  V \        P                  4       SP                  V P                  \        P
                  P                  4       R # r"   )r1  r   r2  r  r  
exceptionsProtocolErrorr5  s   &r'   r7  <HTTP2ServerTests.test_failWithProtocolError.<locals>.errbackj  s8    !!&'//:!!&,,0K0KLr+      yor9   r?   )r   r   r   r&  r  r'  r   r
  r   r  r   r:  rJ   r   r   r  
r&   r   r   r  secondRequestr#  r  r7  r  r;  s
   f         r'   test_failWithProtocolError+HTTP2ServerTests.test_failWithProtocolErrorM  s     "^
$;<N$O
!"&"8"8..#
 *""B\A
 	. --55	Y+	=	
 ANN8- 
 #11ut1LVVX,""9--r+   c                  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#\        S P
                  . V^R7      pVP                  V4       VP                  P                  pS P                  \        V4      ^4       V 3R lpV 3R lpV F  pVP                  Wg4       K  	  VP                  ^R7      P                  4       p	VP                  V	4       \        P                  ! V4      # )z
A HTTP/2 GoAway triggers the L{http.Request.notifyFinish}
deferred for all outstanding requests with a Failure that contains a
RemoteGoAway error.
r?  c                 *   < SP                  R 4       R# r(  r)  r+  s   &r'   r  4HTTP2ServerTests.test_failOnGoaway.<locals>.callback  r.  r+   c                    < SP                  V \        P                  4       SP                  V P                  \
        P                  4       R # r"   r0  r5  s   &r'   r7  3HTTP2ServerTests.test_failOnGoaway.<locals>.errback  r9  r+   r  )r   r   r   r&  r  r'  r   r
  r   r  r   r:  ra   r   r   r  rH  s
   f         r'   test_failOnGoaway"HTTP2ServerTests.test_failOnGoawayy  s     "^
$;<N$O
!"&"8"8..#
 *""B\A
 	. --55	Y+	=	
 ANN8-  #333CMMO,""9--r+   c                  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#\        S P
                  . V^R7      pVP                  V4       VP                  P                  pS P                  \        V4      ^4       V 3R lpV 3R lpV F  pVP                  Wg4       K  	  VP                  4        \        P                  ! V4      # )z
The transport telling the HTTP/2 connection to stop producing will
fire all L{http.Request.notifyFinish} errbacks with L{error.}
r?  c                 *   < SP                  R 4       R# r(  r)  r+  s   &r'   r  ;HTTP2ServerTests.test_failOnStopProducing.<locals>.callback  r.  r+   c                    < SP                  V \        P                  4       SP                  V P                  \
        P                  4       R # r"   r0  r5  s   &r'   r7  :HTTP2ServerTests.test_failOnStopProducing.<locals>.errback  r9  r+   )r   r   r   r&  r  r'  r   r
  r   r  r   r:  r   r   r  )	r&   r   r   r  rI  r#  r  r7  r  s	   f        r'   test_failOnStopProducing)HTTP2ServerTests.test_failOnStopProducing  s     "^
$;<N$O
!"&"8"8..#
 *""B\A
 	. --55	Y+	=	
 ANN8-  	  """9--r+   c                v  a  \        4       p\        \        4      Vn        S P	                  VS P
                  . 4      w  r#VP                  P                  pS P                  \        V4      ^4       V 3R lpV 3R lpV^ ,          pVP                  WV4       VP                  ^,          pVP                  4        V# )z
A HTTP/2 stream that has had _respondToBadRequestAndDisconnect called
on it from a request handler calls the L{http.Request.notifyFinish}
errback with L{ConnectionLost}.
c                 *   < SP                  R 4       R# r(  r)  r+  s   &r'   r  7HTTP2ServerTests.test_notifyOnFast400.<locals>.callback  r.  r+   c                    < SP                  V \        P                  4       SP                  V P                  \
        P                  4       R # r"   r0  r5  s   &r'   r7  6HTTP2ServerTests.test_notifyOnFast400.<locals>.errback  r9  r+   )r   r   r   r&  r  r'  r   r  r   r:  r{  r  )	r&   r   r   r  r#  r  r7  r  r  s	   f        r'   test_notifyOnFast400%HTTP2ServerTests.test_notifyOnFast400  s     "^
$;<N$O
!"&"8"8..#
 --55	Y+	=	
 aL	x) ##A&002r+   c           	        \        4       p\        V4      pVP                  Vn        \        Vn        ^p\        4       p\        4       pVP                  4       pVP                  V4       VP                  V4       VP                  \        V P                  . WCR7      4       VP                  4        ^ Vn        VP                  V4       V P                  VP                   4       R# )z
A HTTP/2 stream that has had _respondToBadRequestAndDisconnect
called on it does not write control frame data if its
transport is paused and its control frame limit has been
reached.
r   N)r	   r   r  r   r&  r    r
   r1   r	  r
  r   r'  r   _maxBufferedControlFrameBytesr  r  disconnected)r&   memoryReactorr   r?   r   r  r1   s   &      r'   test_fast400WithCircuitBreaker/HTTP2ServerTests.test_fast400WithCircuitBreaker  s     +,!-0
,66
 %7
!#~#%	 #/"F"F"H!!), 78&&L	
 	!!#34
044X>	../r+   c                N   \        4       p\        Vn        \        4       p\	        4       pVP                  4       pVP                  V4       VP                  V4       VP                  4        \        ^ ^d4       F1  pVP                  VP                  / 4      P                  4       4       K3  	  \        VP                  4       4      pV P                  \        V4      ^4       VP!                  4        \        VP                  4       4      pV P                  \        V4      ^e4       R# )zx
If a the L{H2Connection} has been paused by the transport, it will
not write automatic frame data triggered by writes.
N)r   r   r&  r    r
   r1   r	  r
  r   r   rQ   r   r   r  r  r   r   )r&   r   r   r  r1   r   r   s   &      r'    test_bufferingAutomaticFrameData1HTTP2ServerTests.test_bufferingAutomaticFrameData  s     "^
$9
!#~#%	"."F"F"H!!), 78 	!!# q#A##L$C$CB$G$Q$Q$ST  !!23Va( 	""$ !23Vc*r+   c                j   \        4       p\        Vn        \        4       p\	        4       pVP                  4       pVP                  V4       VP                  V4       VP                  4        ^dVn	        V P                  VP                  4       \        ^ ^4       F1  pVP                  VP                  / 4      P                  4       4       K3  	  V P                  VP                  4       VP                  VP                  / 4      P                  4       4       V P                  VP                   4       R# )z
If the L{H2Connection} has been paused by the transport, it will
not write automatic frame data triggered by writes. If this buffer
gets too large, the connection will be dropped.
N)r   r   r&  r    r
   r1   r	  r
  r   rb  r~  rr  r   rQ   r   r  rc  )r&   r   r   r  r1   r   s   &     r'   2test_bufferingAutomaticFrameDataWithCircuitBreakerCHTTP2ServerTests.test_bufferingAutomaticFrameDataWithCircuitBreaker<  s     "^
$9
!#~#%	"."F"F"H!!), 78 	!!# 47
0 	001q"A##L$C$CB$G$Q$Q$ST 001 	 ? ? C M M OP	../r+   c                    ! R R\         4      p\        4       p\        Vn        \	        4       pV! 4       pVP                  VR4       VP                  4       pVP                  V4       VP                  V4       V P                  VP                  4       \        VP                  4       4      pV P                  \        V4      ^4       V P                  VP                  ^ 4       \!        ^ ^4       F1  pVP                  VP#                  / 4      P%                  4       4       K3  	  \        VP                  4       4      pV P                  \        V4      ^4       V P                  VP                  ^c4       VP'                  4        \        VP                  4       4      pV P                  \        V4      ^4       V P                  VP                  ^Z4       R# )z
If the L{H2Connection} has buffered control frames, is unpaused, and then
paused while unbuffering, it persists the buffer and stops trying to write.
c                   &   a  ] tR tRt o R tRtV tR# )eHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWrite.<locals>.AutoPausingStringTransportid  c                n    \         P                  ! V .VO5/ VB  V P                  P                  4        R # r"   )r
   r   producerr   r   s   &*,r'   r   kHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWrite.<locals>.AutoPausingStringTransport.writee  s*    %%d<T<V<,,.r+   r0   N)ry   rz   r{   r|   r   r~   r   r   s   @r'   AutoPausingStringTransportro  d  s     / /r+   rs  TN)r
   r   r   r&  r    r   r1   r	  r
  assertIsNotNone_consumerBlockedr   r  r  r   _bufferedControlFrameBytesr   rQ   r   r   )r&   rs  r   r   r  r1   r   r   s   &       r'   0test_bufferingContinuesIfProducerIsPausedOnWriteAHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWrite^  su   	/ 	/ "^
$9
!#~.0	"":t4"."F"F"H!!), 78 	Z889 !23Va(>>B q"A##L$C$CB$G$Q$Q$ST  !!23Va(>>G 	""$ !23Va(>>Gr+   c                   \        4       p\        V4      pVP                  Vn        \        4       p\	        4       pVP                  4       pVP                  V4       VP                  V4       VP                  4        ^ Vn	        VP                  R^R7      P                  4       pVP                  V4       V P                  VP                  4       R# )z
A client that triggers a L{h2.exceptions.ProtocolError} over a
paused connection that's reached its buffered control frame
limit causes that connection to be aborted.
rF  rG  N)r	   r   r  r    r
   r1   r	  r
  r   rb  rJ   r   r  rc  )r&   rd  r   r   r  r1   r;  s   &      r'   +test_circuitBreakerAbortsAfterProtocolError<HTTP2ServerTests.test_circuitBreakerAbortsAfterProtocolError  s     +,!-0
,66
#~#%	 #/"F"F"H!!), 78 	!!#34
0 #11ut1LVVX 	,	../r+   r0   N   :method   GETs
   :authoritys	   localhost   :pathr   s   :schemes   httpss
   user-agents   twisted-test-code)   custom-headerr  )r  r  )r~  rH  r  )r  rE  r  r  )r<  s   25s   hello s   world, s   it's s   http/2!)rA  )rD  r   )rG  r  rI  )r<  s   13)rA  rC  rF  rI  )r<  s   36).ry   rz   r{   r|   r'  r7  r8  r!  r"  r4  r5  r  r+  r9  rL  r`  ro  rs  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r$  r<  rJ  rQ  rX  r_  re  rh  rk  rw  rz  r~   r   r   s   @r'   r  r    s	     DO *O B':K8K8)KV>
@E
N%)N+KZ,5\35j25hK8%5N+KZN KD
0S,8>@BD7. 9D9.B*.X(.T'.R%N(0T+> 0D+HZ0 0r+   r  c                      a  ] tR tRt o Rt. ROtRt. ROt. RO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# )H2FlowControlTestsi  zL
Tests that ensure that we handle HTTP/2 flow control limits appropriately.
r  r  c                  a a	 \        4       p\        4       o	\        4       p\        Vn        VP                  4       pW1P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . V4      ,          pVP                  S	4       \        V4       F  pVP!                  V4       K  	  \#        S P$                  4      ^,
          p\'        V4       F5  pVP)                  ^^R7      pVP!                  VP                  4       4       K7  	  V	V 3R lpVP*                  ^,          P-                  V4      # )z
When a L{Request} object is not using C{IProducer} to generate data and
so is not having backpressure exerted on it, the L{H2Stream} object
will buffer data until the flow control window is opened.
r  c                    < \        SP                  4       4      pSP                  R VR,          P                  9   4       RP	                  R V 4       4      pSP                  SP                  V4       R# )r   r+   c              3      "   T F=  p\        V\        P                  P                  4      '       g   K/  VP                  x  K?  	  R # 5ir"   r   r5   r6   rI   r9   r   s   & r'   r   MH2FlowControlTests.test_bufferExcessData.<locals>.validate.<locals>.<genexpr>  .      * &1*Q
8H8H8R8R*S
   ,AANr   )r   r  r  r:   r   r  r"  r?   r   actualResponseDatarU  r&   s   &  r'   r$  :H2FlowControlTests.test_bufferExcessData.<locals>.validate  sg    $QWWY/F OOLF2J,<,<<= "% * &* " T113EFr+   )r    r
   r   r   r&  r1   rQ   r  rO   r   r  r   r   r'  r	  r   r
  r   r"  r   rW   r(  r)  )
r&   rA   r_  r  r  bonusFramesr   r6   r$  rU  s
   f        @r'   test_bufferExcessData(H2FlowControlTests.test_bufferExcessData  s    NN0 002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , $../!3{#A,,a1,EENN5??,- $

	G ((+77AAr+   c                  a a \        4       p\        4       o\        4       p\        Vn        VP                  4       pW1P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . V4      ,          pVP                  S4       \        V4       F  pVP!                  V4       K  	  VP"                  ^,          pVP$                  P&                  pS P)                  VP*                  4       VP-                  R4       S P/                  VP*                  4       S P1                  VP2                  P4                  R.4       VP!                  VP7                  ^^R7      P                  4       4       S P/                  VP*                  4       S P1                  VP2                  P4                  R.4       VP!                  VP7                  ^ ^R7      P                  4       4       S P/                  VP*                  4       S P1                  VP2                  P4                  R.4       VP!                  VP7                  ^^R7      P                  4       4       S P)                  VP*                  4       S P1                  VP2                  P4                  RR.4       VP-                  R4       S P/                  VP*                  4       S P1                  VP2                  P4                  . RO4       VP!                  VP7                  ^^2R7      P                  4       4       S P)                  VP*                  4       S P1                  VP2                  P4                  . RO4       VP9                  4        VP;                  4        VV 3R lpVP<                  ^,          P?                  V4      # )zo
L{Request} objects that have registered producers get blocked and
unblocked according to HTTP/2 flow control.

   helloworldpauser  resumec                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  V. RO4       R# u upi )r   Nr   )r  r  r+   r  r?   r   rA   r  rU  r&   s   &   r'   r$  DH2FlowControlTests.test_producerBlockingUnblocking.<locals>.validate9  s    $QWWY/F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Z)LMr  )r  r  r  )r  r  r  r  ) r    r
   r   r  r&  r1   rQ   r  rO   r   r  r   r   r'  r	  r   r
  r{  r|  r}  r  _producerProducingr   r~  r  rq  eventsrW   unregisterProducerr   r(  r)  	r&   rA   r_  r  r  r  r  r$  rU  s	   f       @r'   test_producerBlockingUnblocking2H2FlowControlTests.test_producerBlockingUnblocking  s    
 NN4 002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , 1//** 	112 	m$ 	223))007)< 	
q//a/HRRTU223))007)< 	
q//a/HRRTU223))007)< 	
q//a/HRRTU112))007H2EF
 	m$223))002NO 	
q//b/ISSUV112##%K	
 	""$
	N ((+77AAr+   c                  a aaa	a
a \        4       o	\        4       o\        4       o\        Sn        S	P                  4       pVS	P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . S	4      ,          pSP                  S4       \        V4       F  pSP!                  V4       K  	  SP"                  ^,          oSP$                  P&                  o
S P)                  SP*                  4       S
P-                  R4       S P/                  SP*                  4       S P1                  S
P2                  P4                  R.4       S
P-                  R4       VV	V
V V3R lp\6        P8                  ! \:        ^ V4      pVV 3R lpSP<                  ^,          P?                  V4      p\@        PB                  ! WF.4      # )zA
Exactly filling the flow control window still blocks producers.
r  r     hc                  .  < S P                  SP                  ^^2R7      P                  4       4       SP                  SP                  4       SP                  SP                  P                  RR.4       SP                  4        SP                  4        R# )rw   r  r  r  N)
r
  rW   r   r  r  r  rq  r  r  r   )r_  rA   r  r&   r  s   r'   window_open=H2FlowControlTests.test_flowControlExact.<locals>.window_openn  sv    NN((!r(BLLN OOF556W--44w6IJ&&(NNr+   c                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  V. RO4       R# u upi )r   Nr   )r  r  r  r+   r  r  s   &   r'   r$  :H2FlowControlTests.test_flowControlExact.<locals>.validatez  s    $QWWY/F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Z)HIr  )"r    r
   r   r  r&  r1   rQ   r  rO   r   r  r   r   r'  r	  r   r
  r{  r|  r}  r  r  r   r~  r  rq  r  r   r  r   r(  r)  r   r\  )r&   r  r  r  windowDeferr$  validateDeferr_  rU  rA   r  r  s   f      @@@@@r'   test_flowControlExact(H2FlowControlTests.test_flowControlExactG  s    NN4 002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , 1//** 	112 	m$223))007)< 	d	 	 oogq+>
	J 11!4@@J!!;">??r+   c           	       a a \        4       p\        4       o\        4       p\        Vn        VP                  4       pW1P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . V4      ,          pVP                  S4       \        V4       F  pVP!                  V4       K  	  VP"                  ^,          pVP$                  P&                  pS P)                  VP*                  4       VP-                  R4       VP/                  4        VP1                  4        S P)                  VP2                  4       \4        P6                  ! ^ VP                   VP9                  ^^2R7      P                  4       4       VV 3R lpVP:                  ^,          P=                  V4      # )z
L{Request} objects that end a stream that is currently blocked behind
flow control can still end the stream and get cleaned up.
r  r  c                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  V. RO4       R# u upi )r   Nr   )r  r  r+   r  r  s   &   r'   r$  =H2FlowControlTests.test_endingBlockedStream.<locals>.validate  s    $QWWY/F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Z)BCr  )r    r
   r   r  r&  r1   rQ   r  rO   r   r  r   r   r'  r	  r   r
  r{  r|  r}  r  r  r   r  r   finishedr   r  rW   r(  r)  r  s	   f       @r'   test_endingBlockedStream+H2FlowControlTests.test_endingBlockedStream  sp   
 NN4 002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , 1//** 	112 	m$""$ 	(() 	NN$$a2$>HHJ	

	D ((+77AAr+   c                :  a a	 \        4       p\        4       o	\        4       p\        Vn        VP                  4       pV\        S P                  . V4      ,          pVP                  S	4       \        V4       F  pVP                  V4       K  	  VP                  ^,          pVP                  P                  pVP                  ^,          pVP                  4        VP!                  4        S P#                  VP$                  4       V	V 3R lpVP'                  V4      # )z,
We safely handle responses without bodies.
c                 x  < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  RVR,          P
                  9   4       V Uu. uF;  p\        V\        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  VR.4       R# u upi rh  r   r+   Nr   r   r  r  r   r  r:   r   r5   r6   rI   r9   r  s   &   r'   r$  =H2FlowControlTests.test_responseWithoutBody.<locals>.validate      $QWWY/FS[!, OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S      ,B7B7)r    r
   r   r  r&  r1   r   r'  r	  r   r
  r{  r|  r}  r(  r  r   r  r  r)  
r&   rA   r_  r  r  r  r  r  r$  rU  s
   f        @r'   test_responseWithoutBody+H2FlowControlTests.test_responseWithoutBody  s     NN 5 002)$*@*@"aHH	l+DNN4  , 1//**33A6 	""$ 	(()	" **844r+   c                  a a	 \        4       p\        4       o	\        4       p\        Vn        VP                  4       pV\        S P                  . V4      ,          pVP                  S	4       \        V4       F  pVP                  V4       K  	  VP                  ^,          pVP                  P                  pVP                  ^,          pVP                  4        VP!                  4        S P#                  VP$                  4       VP                  VP'                  ^^2R7      P)                  4       4       V	V 3R lpVP+                  V4      # )zS
WindowUpdate frames received after we've completed the stream are
safely handled.
r  c                 x  < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  RVR,          P
                  9   4       V Uu. uF;  p\        V\        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  VR.4       R# u upi r  r  r  s   &   r'   r$  GH2FlowControlTests.test_windowUpdateForCompleteStream.<locals>.validate  r  r  )r    r
   r   r  r&  r1   r   r'  r	  r   r
  r{  r|  r}  r(  r  r   r  r  rW   r   r)  r  s
   f        @r'   "test_windowUpdateForCompleteStream5H2FlowControlTests.test_windowUpdateForCompleteStream  s    NN 5 002)$*@*@"aHH	l+DNN4  , 1//**33A6 	""$ 	(() 	
q//b/ISSUV	" **844r+   c                N  a a \        4       p\        4       o\        4       p\        Vn        VP                  4       pW1P                  \        P                  P                  P                  ^/4      P                  4       ,          pV\        S P                  . V4      ,          pVP                  S4       \        V4       F  pVP!                  V4       K  	  VP"                  ^,          pVP$                  P&                  pS P)                  VP*                  4       VP-                  R4       S P)                  VP*                  4       S P/                  VP0                  P2                  . 4       VP!                  VP5                  ^^R7      P                  4       4       S P)                  VP*                  4       S P/                  VP0                  P2                  . 4       VP7                  4        VP9                  4        VV 3R lpVP:                  ^,          P=                  V4      # )z
L{Request} objects that have registered producers that are not blocked
behind flow control do not have their producer notified.
   wordr  c                 D  < \        SP                  4       4      pSP                  R VR,          P                  9   4       V Uu. uF;  p\	        V\
        P                  P                  4      '       g   K/  VP                  NK=  	  ppSP                  VRR.4       R# u upi )r   r  r+   Nr   r  r  s   &   r'   r$  ;H2FlowControlTests.test_producerUnblocked.<locals>.validate`  s    $QWWY/F OOLF2J,<,<<= !' &1*Q
8H8H8R8R*S   Z'38r  )r    r
   r   r  r&  r1   rQ   r  rO   r   r  r   r   r'  r	  r   r
  r{  r|  r}  r  r  r   r  rq  r  rW   r  r   r(  r)  r  s	   f       @r'   test_producerUnblocked)H2FlowControlTests.test_producerUnblocked2  s   
 NN4 002,,[[%%991=

)+	 	)$*@*@"aHH	l+DNN4  , 1//** 	112 	g 	112))00"5 	
q//a/HRRTU112))00"5 	""$
	9 ((+77AAr+   c                  a a \        4       p\        4       o\        4       p\        Vn        \        S P                  S P                  V4      pVP                  ^VP                  ^ ^R7      4       VP                  4       pVRP                  R V 4       4      ,          pVP                  S4       \        V4       F  pVP                  V4       K  	  VV 3R lpVP                  ^,          P!                  V4      # )z|
When a WindowUpdate frame is received for the whole connection but no
data is currently waiting, nothing exciting happens.
r  r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   BH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.<genexpr>|  r  r   c                    < \        SP                  4       4      pSP                  R VR,          P                  9   4       RP	                  R V 4       4      pSP                  SP                  V4       R# )r   r+   c              3      "   T F=  p\        V\        P                  P                  4      '       g   K/  VP                  x  K?  	  R # 5ir"   r  r   s   & r'   r   TH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.validate.<locals>.<genexpr>  r  r  Nr   )r   r  r  r:   r   r  r5  r  s   &  r'   r$  AH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.validate  sg    $QWWY/F OOLF2J,<,<<= "% * &* " T224FGr+   )r    r
   r   r   r&  r   r7  r8  rm  rW   r1   r   r	  r   r
  r(  r)  )r&   rA   r_  r   r  r  r$  rU  s   f      @r'   test_unnecessaryWindowUpdate/H2FlowControlTests.test_unnecessaryWindowUpdaten  s    
 NN0 $D$;$;T=Q=QSTUa1111JK002 ? ???	l+DNN4  ,
	H ((+77AAr+   c                   \        4       p\        4       p\        4       p\        Vn        . pVP                  VP                  V P                  ^R7      4       VP                  VP                  ^^R7      4       VP                  4       pVRP                  R V 4       4      ,          pVP                  V4       VP                  V4       V P                  V4       R# )z
When a WindowUpdate frame is received for a stream but no data is
currently waiting, that stream is not marked as unblocked and the
priority tree continues to assert that no stream can progress.
r   r  r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   KH2FlowControlTests.test_unnecessaryWindowUpdateForStream.<locals>.<genexpr>  s     71r   N)r    r
   r   r   r&  r   rE   r7  rW   r1   r   r	  r
  r   )r&   rA   r  connr   r9   s   &     r'   %test_unnecessaryWindowUpdateForStream8H2FlowControlTests.test_unnecessaryWindowUpdateForStream  s     N#%	~3
 a))$2I2ITU)VWa..Q.GH((*7777I&$$$T*r+   c                   \        4       p\        4       p\        4       p\        Vn        \        V P                  V P                  V4      pVP                  4       pVRP                  R V 4       4      ,          pVP                  V4       \        V4       F  pVP                  V4       K  	  VP                  ^,          P                  4        VP                  ^^R7      pVP                  VP!                  4       4       \#        VP%                  4       4      pV P'                  \)        VR,          \*        P,                  P.                  4      4       R# )zY
When a WindowUpdate frame is received for a stream that has been
aborted it is ignored.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   EH2FlowControlTests.test_windowUpdateAfterTerminate.<locals>.<genexpr>  r  r   r  Nr   )r    r
   r   r   r&  r   r7  r8  r1   r   r	  r   r
  r{  r  rW   r   r   r  r  r   r5   r6   rd   )r&   rA   rU  r_  r   r  r  windowUpdateFrames   &       r'   test_windowUpdateAfterTerminate2H2FlowControlTests.test_windowUpdateAfterTerminate  s
   
 NN0 $D$;$;T=Q=QSTU002 ? ???	l+DNN4  , 	
		!$$& 44a14M	(2245 !+ 	
6":z/?/?/N/NOPr+   c                  a aaa	 \        4       o	\        4       o\        4       o\        Sn        \        S P                  S P                  S	4      pS	P                  4       pVRP                  R V 4       4      ,          pSP                  S4       \        V4       F  pSP                  V4       K  	  VV	3R lpVV 3R lpSP                  ^,          P                  V4      pVP                  V4      # )z[
When a WindowUpdate frame is received for a stream that has been
completed it is ignored.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   DH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.<genexpr>  r  r   c                  l   < SP                  ^^R7      pSP                  VP                  4       4       R# )rw   r  N)rW   r
  r   )r   r  r_  rA   s   * r'   update_windowHH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.update_window  s/     ! 8 8!q 8 QNN,6689r+   c                     < \        SP                  4       4      pSP                  R VR,          P                  4       R# )r   Nr   )r   r  assertInr:   r   r   rU  r&   s   * r'   r$  CH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.validate  s-    $QWWY/F MM,r
(8(89r+   )r    r
   r   r   r&  r   r7  r8  r1   r   r	  r   r
  r(  r)  )
r&   r   r  r  r  r$  r  r_  rU  rA   s
   f      @@@r'   test_windowUpdateAfterComplete1H2FlowControlTests.test_windowUpdateAfterComplete  s    
 NN0 $D$;$;T=Q=QSTU002 ? ???	l+DNN4  ,	:
	: %%a(44]C}}X&&r+   c                X   \        4       p\        4       p\        4       p\        Vn        RR	,          .^,          p\        R V 4       4       pV P                  RR
 RV3.,           p\        WdVR7      pVR
 VP                  VP                  ^\        P                  P                  P                  R7      4       VP                  4       pVRP                  R V 4       4      ,          pVP!                  V4       VP#                  V4       \%        VP'                  4       4      pV U	u. uF;  p	\)        V	\*        P,                  P.                  4      '       g   K/  V	P0                  NK=  	  p
p	V P3                  ^ .V
4       V U	u. uF1  p	\)        V	\*        P,                  P4                  4      '       g   K/  V	NK3  	  pp	V U	u. uF1  p	\)        V	\*        P,                  P6                  4      '       g   K/  V	NK3  	  pp	V P9                  V4       V P9                  V4       R# u up	i u up	i u up	i )zz
When a DATA frame is received at the same time as RST_STREAM,
Twisted does not send WINDOW_UPDATE frames for the stream.
    c              3   8   "   T F  p\        V4      x  K  	  R # 5ir"   )r   )r   r9   s   & r'   r   ;H2FlowControlTests.test_dataAndRstStream.<locals>.<genexpr>  s     <)$CII)s   Nzcontent-lengthr  )r?   r_   r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   r  	  r  r   i @  r   )r    r
   r   r   r&  sumr7  r   r   re   r  errors
ErrorCodesINTERNAL_ERRORr1   r   r	  r
  r   r  r   r5   r6   rT   r  r  r7   rI   r~  )r&   r   r  r_  	frameData
bodyLengthr>   r   r  rA   windowUpdateFrameIDsheadersFrames
dataFramess   &            r'   test_dataAndRstStream(H2FlowControlTests.test_dataAndRstStream  s   
 $~#%	N0
 &'!+	<)<<=
))#2.3CZ2P1QQ#,
 2J,,bii&:&:&I&I - 	
 $;;= ? ???	# 	
|$ !!23
  
!Z--??@ AKK 	  

 	!23
 
!Az/?/?/L/L!MAAv 	 
 "(UA:a9I9I9S9S+Taa
U'$ 

 Vs$   ),HH,H"4H" ,H'1H'c                T   \        4       p\        V4      pVP                  Vn        \        Vn        \        4       p\        4       pVP                  4       pVP                  V4       VP                  V4       ^pVP                  V P                  VR7      P                  4       pVP                  V4       VP                  4        ^ Vn        VP                  4        VP!                  V4       V P#                  VP%                  4       4       V P'                  VP(                  4       R# )z
Aborting a request associated with a paused connection that's
reached its buffered control frame limit causes that
connection to be aborted.
r   N)r	   r   r  r   r&  r    r
   r1   r	  r
  rE   r7  r   r   rb  clearabortRequestr~  r  r  rc  )r&   rd  r   r   r  r1   r?   headersFrameDatas   &       r'   #test_abortRequestWithCircuitBreaker6H2FlowControlTests.test_abortRequestWithCircuitBreaker#	  s    +,!-0
,66
$9
!#~#%	 #/"F"F"H!!), 78 '99++h : 

)+ 	 	 01 	!!#34
0 	 	) 	*+ 		../r+   r0   N)r}  r  r  r  r  r  r  )ry   rz   r{   r|   r}   r'  r"  r7  r8  r5  r  r  r  r  r  r  r  r  r  r  r  r  r  r~   r   r   s   @r'   r  r    s      *O DOA+BZQBf@@D8Bt25h95v:Bx!BF+2Q@ 'D5%n)0 )0r+   r  c                   @   a  ] tR tRt o . ROtR tR tR tR tRt	V t
R# )	HTTP2TransportCheckingiO	  c                    \        4       p\        4       p\        Vn        VP	                  VR4       V P                  VP                  VJ 4       R# )zE
L{H2Connection} can be registered with the transport as a producer.
TN)r
   r   r   r&  r   r  rq  )r&   rU  r_  s   &  r'   "test_registerProducerWithTransport9HTTP2TransportChecking.test_registerProducerWithTransportZ	  s?     N0	1d#

a(r+   c                8  a aa	a
 \        4       p\        4       o	\        4       o\        Sn        \        S P                  . V4      pVP                  4       pVRP                  R V 4       4      ,          pSP                  S	4       S	P                  SR4       \        V4       F  pSP                  V4       K  	  SP                  4        SP                  ^,          o
VV	V
V 3R lpV	V 3R lp\        P                   ! \"        RV4      pVP%                  V4       V# )zd
L{H2Connection} can be paused by its consumer. When paused it stops
sending data to the transport.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   NHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.<genexpr>r	  r  r   Tc                    < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  \        VR,          \        P                  P                  4      4       SP                  4        SP                  4        SP                  4        SP                  4        SP                  4        S# )r  r   )
r   r  r  r   r~  r   r5   r6   rI   r   )r   r   r_  rU  r  r&   s   * r'   validateNotSentTHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.validateNotSent	  s    $QWWY/FS[!,Zr
J4D4D4N4NOP ""r+   c                     < \        SP                  4       4      pSP                  \        V4      ^4       SP	                  RVR,          P
                  9   4       R# rw  rx  r  s   * r'   r  UHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.validateComplete	  sD    $QWWY/F S[!,OOLF2J,<,<<=r+   r  )r    r
   r   r   r&  r   r'  r1   r   r	  r   r   r
  r   r(  r   r  r   r)  )r&   rA   r   r  r  r
  r  r  r_  rU  r  s   f       @@@r'   $test_pausingProducerPreventsDataSend;HTTP2TransportChecking.test_pausingProducerPreventsDataSende	  s    
 NN0 $D$:$:BB002 ? ???		1d# l+DNN4  , 	
 33A6	# 	#	> OOGT?;	&'r+   c                   \        4       p\        4       p\        4       p\        Vn        \        V P                  . V4      pVP                  4       pVRP                  R V 4       4      ,          pVP                  V4       VP                  VR4       \        V4       F  pVP                  V4       K  	  VP                  4        \        VP                  4       4      pV P!                  \#        V4      ^4       V P%                  \'        VR,          \(        P*                  P,                  4      4       V P%                  VP.                  4       R# )zW
L{H2Connection} can be stopped by its producer. That causes it to lose
its transport.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   <HTTP2TransportChecking.test_stopProducing.<locals>.<genexpr>	  r  r   TNr   )r    r
   r   r   r&  r   r'  r1   r   r	  r   r   r
  r   r   r  r  r   r~  r   r5   r6   rI   r  )r&   rA   rU  r_  r   r  r  s   &      r'   test_stopProducing)HTTP2TransportChecking.test_stopProducing	  s   
 NN0 $D$:$:BB002 ? ???		1d# l+DNN4  ,
 	
 +Va(F2J
0@0@0J0JKL**+r+   c                  a a	a
a \        RRR4      o	\        RRR4      o
\        4       p\        S	S
R7      p\        4       p\        Vn        VP                  V4       \        S P                  . V4      pVP                  4       pVRP                  R V 4       4      ,          p\        V4       F  pVP                  V4       K  	  VP                  ^,          oS P                  SP                  4       S	4       S P                  SP!                  4       S
4       VP"                  ^,          pV	V
V V3R	 lpVP%                  V4      # )
zc
A L{H2Stream} object correctly passes through host and peer information
from its L{H2Connection}.
TCPz
17.52.24.8i  z17.188.0.12i}  )hostAddresspeerAddressr+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   rP  s   & r'   r   EHTTP2TransportChecking.test_passthroughHostAndPeer.<locals>.<genexpr>	  rR  r   c                     < SP                  SP                  4       S4       SP                  SP                  4       S4       R # r"   )r  getHostgetPeer)r   r  r  r&   r  s   *r'   r$  DHTTP2TransportChecking.test_passthroughHostAndPeer.<locals>.validate	  s1    V^^-{;V^^-{;r+   )r   r    r
   r   r   r&  r	  r   r'  r1   r   r   r
  r{  r  r  r  r(  r)  )r&   r   r  r   r   r  r  r  r$  r  r  r  s   f        @@@r'   test_passthroughHostAndPeer2HTTP2TransportChecking.test_passthroughHostAndPeer	  s   
 "%s;!%>#~#U	!^
$9
!!!),#D$:$:BM#;;= G GGGl+D##D) , ##A&);7);7 %<<Q?	< 	< **844r+   r0   Nr|  )ry   rz   r{   r|   r'  r  r  r  r  r~   r   r   s   @r'   r  r  O	  s'     	)<|,>!5 !5r+   r  c                   *   a  ] tR tRt o RtR tRtV tR# )HTTP2SchedulingTestsi	  z
The H2Connection object schedules certain events (mostly its data sending
loop) using callbacks from the reactor. These tests validate that the calls
are scheduled correctly.
c                   \         P                  ! 4       p\        V4      pVP                  ! 4       pV P	                  \        V4      ^4       V^ ,          pV P                  VP                  4       4       V P	                  VP                  ^ 4       V P	                  VP                  VP                  4       V P	                  VP                  R4       V P	                  VP                  / 4       R# )ze
When a H2Connection is established it schedules one call to be run as
soon as the reactor has time.
Nr0   )r   Clockr   getDelayedCallsr  r   r  activetimefunc_sendPrioritisedDatar   kw)r&   r   r_  callscalls   &    r'   "test_initiallySchedulesOneDataCall7HTTP2SchedulingTests.test_initiallySchedulesOneDataCall	  s    
 **,!'')UQ'Qx 	&A&A$:$:;B'"%r+   r0   N)ry   rz   r{   r|   r}   r-  r~   r   r   s   @r'   r"  r"  	  s     & &r+   r"  c                      a  ] tR tRt o Rt. ROt]! 4       tR tR t	R t
]3R l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# )HTTP2TimeoutTestsi
  z8
The L{H2Connection} object times out idle connections.
c                (    VP                   Vn         R# )a  
Unfortunately, TimeoutMixin does not allow passing an explicit reactor
to test timeouts. For that reason, we need to monkeypatch the method
set up by the TimeoutMixin.

@param connection: The HTTP/2 connection object to patch.
@type connection: L{H2Connection}

@param reactor: The reactor whose callLater method we want.
@type reactor: An object implementing
    L{twisted.internet.interfaces.IReactorTime}
N)r  )r&   r   r   s   &&&r'   patch_TimeoutMixin_clock*HTTP2TimeoutTests.patch_TimeoutMixin_clock
  s      '00
r+   c                   \         P                  ! 4       p\        V4      p^dVn        V P	                  WC4       \        4       p\        V4      Vn        VP                  V4       \        V4       F  pVP                  V4       K  	  W4V3# )a]  
Performs test setup by building a HTTP/2 connection object, a transport
to back it, a reactor to run in, and sending in some initial data as
needed.

@param initialData: The initial HTTP/2 data to be fed into the
    connection after setup.
@type initialData: L{bytes}

@param requestFactory: The L{Request} factory to use with the
    connection.
)r   r$  r   timeOutr2  r
   r   r&  r	  r   r
  )r&   initialDatar&  r   r  r  r  s   &&&    r'   initiateH2Connection&HTTP2TimeoutTests.initiateH2Connection#
  s}     **,G$%%d4#%	6~FI& k*Dd# + y))r+   c                R   \        V4      pV P                  \        V4      V4       V P                  \	        VR,          \
        P                  P                  4      4       V P                  VR,          P                  V4       V P                  VR,          P                  V4       R# )z
Confirm that the data that was sent matches what we expect from a
timeout: namely, that it ends with a GOAWAY frame carrying an
appropriate error code and last stream ID.
Nr   )
r   r  r   r  r   r5   r6   rZ   r[   r\   )r&   r9   
frameCountr_   r^   r   s   &&&&& r'   assertTimedOut HTTP2TimeoutTests.assertTimedOut?
  sy     !&Vj1
6":z/?/?/K/KLM..	:22LAr+   c                   WP                   J d   \        P                  p\        4       pVP	                  4       pV P                  V\        R7      w  rEpWn        VP                  ! ^d4       V P                  VP                  4       ^\        P                  P                  P                  ^ R7       V P                  VP                  4       V P!                  VP"                  4       WEV3# )au  
Does the common setup for tests that want to test the aborting
functionality of the HTTP/2 stack.

@param abortTimeout: The value to use for the abortTimeout. Defaults to
    whatever is set on L{H2Connection.abortTimeout}.
@type abortTimeout: L{int} or L{None}

@return: A tuple of the reactor being used for the connection, the
    connection itself, and the transport.
r&  r:  r_   r^   )_DEFAULTr   abortTimeoutr    r1   r7  r   advancer;  r  r  r  r  NO_ERRORr  rr  r~  rc  )r&   rA  r   r6  r   r  r  s   &&     r'   prepareAbortTest"HTTP2TimeoutTests.prepareAbortTestL
  s     ==('44L#~"::<#'#<#<+ $= $
 y ) 	OOii**33	 	 	
 		//0//0i''r+   c                
   \        4       pVP                  4       pV P                  V\        R7      w  r4pVP	                  4       pVP
                  ! ^c4       V P                  WeP	                  4       4       V P                  VP                  4       VP
                  ! ^4       V P                  VP	                  4       ^\        P                  P                  P                  ^ R7       V P                  VP                  4       R# )zy
When a L{H2Connection} does not receive any data for more than the
time out interval, it closes the connection cleanly.
r>  r?  N)r    r1   r7  r   r  rB  r  r~  rr  r;  r  r  r  rC  r  )r&   r   r6  r   r  r  preambles   &      r'   test_timeoutAfterInactivity-HTTP2TimeoutTests.test_timeoutAfterInactivityr
  s    
 $~"::<#'#<#<+ $= $
 y ??$ 	 	??#45001 	OOii**33	 	 	
 		//0r+   c                   \        4       pRpV P                  V\        R7      w  r4p\        VP	                  4       4       FA  pVP                  V4       VP                  ! ^c4       V P                  VP                  4       KC  	  VP                  ! ^4       V P                  VP                  4       ^\        P                  P                  P                  ^ R7       V P                  VP                  4       R# )z=
When a L{H2Connection} receives data, the timeout is reset.
r+   r>  r?  N)r    r7  r   r   r1   r
  rB  r~  rr  r;  r  r  r  r  rC  r  )r&   r   r6  r   r  r  r  s   &      r'   test_timeoutResetByRequestData0HTTP2TimeoutTests.test_timeoutResetByRequestData
  s    
 $~#'#<#<+ $= $
 y lBBDEDd# OOB Y445 F 	OOii**33	 	 	
 		//0r+   c                  a	 \        4       pRp. o	\        V P                  . V4      pVP                  4       pVRP	                  R V 4       4      ,          pV	3R lpV P                  VVR7      w  rVpVP                  VP                  4       4       VP                  ! ^c4       V P                  \        S	4      ^4       \        ^
4       FH  pS	^ ,          P                  R4       VP                  ! ^c4       V P                  VP                  4       KJ  	  VP                  ! ^4       V P                  VP                  4       ^\         P"                  P$                  P&                  ^R7       R# )z:
When a L{H2Connection} sends data, the timeout is reset.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   DHTTP2TimeoutTests.test_timeoutResetByResponseData.<locals>.<genexpr>
       >v!vr   c                 B   < \        WR 7      pSP                  V4       V# ))queued)r   r   )r  rR  r   requestss   && r'   saveRequestFHTTP2TimeoutTests.test_timeoutResetByResponseData.<locals>.saveRequest
  s    $V;COOC Jr+   r>  s
   some bytesr?  N)r    r   r'  r1   r   r7  r
  rB  assertEqualsr   r   r   r~  rr  r;  r  r  r  r  PROTOCOL_ERROR)
r&   r   r6  r   rT  r   r  r  rJ  rS  s
   &        @r'   test_timeoutResetByResponseData1HTTP2TimeoutTests.test_timeoutResetByResponseData
  s7   
 $~#D$:$:BM"::<sxx>v>>>	
 $(#<#<& $= $
 y
 	,>>@A 	#h-+rAQKm,OOBY445	  	OOii**99	 	 	
r+   c                   \        4       p\        V P                  . V4      pVP                  4       pVRP	                  R V 4       4      ,          pV P                  V\        R7      w  rEpVP                  ! ^e4       V P                  VP                  4       ^\        P                  P                  P                  ^R7       V P                  VP                  4       R# )zz
When a L{H2Connection} times out with active streams, the error code
returned is L{h2.errors.ErrorCodes.PROTOCOL_ERROR}.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   OHTTP2TimeoutTests.test_timeoutWithProtocolErrorIfStreamsOpen.<locals>.<genexpr>
  rP  r   r>  r?  N)r    r   r'  r1   r   r7  r   rB  r;  r  r  r  r  rW  r  rr  )r&   r   r   r6  r   r  r  s   &      r'   *test_timeoutWithProtocolErrorIfStreamsOpen<HTTP2TimeoutTests.test_timeoutWithProtocolErrorIfStreamsOpen
  s    
 $~#D$:$:BM"::<sxx>v>>>#'#<#</ $= $
 y 	OOii**99	 	 	
 		//0r+   c                   \        4       p\        V P                  . V4      pVP                  4       pVRP	                  R V 4       4      ,          pV P                  V\        R7      w  rEpVP                  4       p\        VP                  ! 4       4      pVP                  R4       \        VP                  ! 4       4      p	V P                  V^,
          V	4       VP                  ! ^e4       V P                  VP                  4       V4       R# )zE
When a L{H2Connection} loses its connection it cancels its timeout.
r+   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir"   r   r   s   & r'   r   CHTTP2TimeoutTests.test_noTimeoutIfConnectionLost.<locals>.<genexpr>  rP  r   r>  r6  N)r    r   r'  r1   r   r7  r   r  r   r%  connectionLostr  rB  )
r&   r   r   r6  r   r  r  sentDataoldCallCountcurrentCallCounts
   &         r'   test_noTimeoutIfConnectionLost0HTTP2TimeoutTests.test_noTimeoutIfConnectionLost
  s     $~#D$:$:BM"::<sxx>v>>>#'#<#</ $= $
 y
 ??$72245 	H% w6689)+;< 	*H5r+   c                L   V P                  4       w  rp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       R# )z
When a L{H2Connection} has timed the connection out, and the transport
doesn't get torn down within 15 seconds, it gets forcibly closed.
NrD  rB  r  rr  r~  rc  r&   r   r  r  s   &   r'   ,test_timeoutEventuallyForcesConnectionClosed>HTTP2TimeoutTests.test_timeoutEventuallyForcesConnectionClosed  s{    
 $(#8#8#: y 		//0//0	//0	../r+   c                   V P                  4       w  rpVP                  ! ^4       VP                  R4       VP                  ! ^4       V P                  VP                  4       V P                  VP                  4       R# )z
When a L{H2Connection} has timed the connection out, getting
C{connectionLost} called on it cancels the forcible connection close.
N)rD  rB  rb  r  rr  r~  rc  rj  s   &   r'   $test_losingConnectionCancelsTheAbort6HTTP2TimeoutTests.test_losingConnectionCancelsTheAbort'  sg    
 $(#8#8#: y 	D! 		//0//0r+   c                    V P                  RR7      w  rpVP                  ! R4       V P                  VP                  4       V P	                  VP
                  4       R# )z
When a L{H2Connection} has timed the connection out but the
C{abortTimeout} is set to L{None}, the connection is never aborted.
N)rA  l        ri  rj  s   &   r'   'test_losingConnectionWithNoAbortTimeOut9HTTP2TimeoutTests.test_losingConnectionWithNoAbortTimeOut7  sP    
 $(#8#8d#8#K y 		//0//0r+   c                    V P                  4       w  rpVP                  ! ^4       V P                  VP                  4       V P                  VP                  4       VP                  \        P                  4       R# )ze
If a timed out transport doesn't close after 15 seconds, the
L{HTTPChannel} will forcibly close it.
N)rD  rB  r  rr  rc  rb  r   ConnectionDonerj  s   &   r'   "test_connectionLostAfterForceClose4HTTP2TimeoutTests.test_connectionLostAfterForceCloseD  s_    
 $(#8#8#: y 		//0	../
 	E001r+   c                   \        4       p\        V4      pVP                  Vn        ^<Vn        \	        4       p\        4       pVP                  4       pVP                  V4       VP                  V4       \        VP                  VP                  ,           4       FB  pVP                  VP                  ^4      P                  4       4       VP                  ^4       KD  	  V P                  VP                  4       R# )zB
A client that sends only invalid frames is eventually timed out.
N)r	   r   r  r5  r    r
   r1   r	  r
  r   rA  re   r   rB  r  rc  )r&   rd  r   r   r  r1   r   s   &      r'   ,test_timeOutClientThatSendsOnlyInvalidFrames>HTTP2TimeoutTests.test_timeOutClientThatSendsOnlyInvalidFramesU  s     +,!-0
,66

#~#%	"."F"F"H!!), 78 z))J,C,CCDA##L$D$DQ$G$Q$Q$ST!!!$ E 		../r+   r0   Nr|  )ry   rz   r{   r|   r}   r'  r  r@  r2  r7  r;  rD  rH  rK  rX  r]  rf  rk  rn  rq  ru  rx  r~   r   r   s   @r'   r0  r0  
  sp      xH1*8B -5 $(L 1D 1D*
X146801 12"0 0r+   r0  c                   f   a  ] tR tRt o Rt]'       g   ]! R4      '       g   ]tV 3R lR ltRt	V t
R# )EndToEndTestsiq  zC
Tests that run real TCP-based communication with a HTTP/2 server.
OpenSSLc                   < V ^8  d   QhRR/# )r  returnNr0   )formatr   s   "r'   __annotate__EndToEndTests.__annotate__y  s     2 2 2r+   c                  a"   \        R4      w  r\        RR4      pRVn        \        P                  ! ^ \        V4      VP                  4       4      pVP                  4       P                  oV P                  VP                  4       V3R lp\        V4      G Rj  xL
 w  rgV P                  VR4       V P                  VR4       R#  L,5i)zB
Twisted's HTTP/2 server can talk to a third-party HTTP/2 client.
z
test.locals   hello worldzapplication/octet-streamTc                     < \         P                  ! R RR7      p V P                  RS R24      pVP                  VP                  3pV P                  4        V# )TF)http2verifyzhttps://127.0.0.1:/)httpxClientgethttp_versionr   close)clientresponser  portNums      r'   run_http2_query7EndToEndTests.test_realRequest.<locals>.run_http2_query  sO    \\U;Fzz$6wiq"ABH++X-=-=>FLLNMr+   NzHTTP/2)r   r   isLeafr   	listenSSLr   optionsr  port
addCleanupstopListeningr   r  )	r&   r   
serverCertresourcer  r  httpVersionr   r  s	   &       @r'   test_realRequestEndToEndTests.test_realRequesty  s      :,G(BC  DNJ4F4F4HI,,.%%**+	 (5_'E!Eh/.1 "Fs   BCC	-Cr0   N)ry   rz   r{   r|   r}   r  r   r  r  r~   r   r   s   @r'   r{  r{  q  s(      ]9--2 2r+   r{  rv   )Pr}   rX  zope.interfacer   r   r  twisted.internetr   r   r   r   twisted.internet.addressr   twisted.internet.testingr	   r
   twisted.internet.threadsr   twisted.pythonr   twisted.python.compatr   twisted.python.reflectr   twisted.test.test_internetr   twisted.test.test_sslverifyr   twisted.trialr   twisted.webr   twisted.web.serverr   twisted.web.staticr   twisted.web.test.test_httpr   r   r   r   r   r   r   r  r  	h2.errorsh2.exceptionsr5   r   hpack.hpackr   r   twisted.web._http2r   ImportErrorr    r   r   r   r   r   r   rl  r   rz  r   r  r   r  r   NotifyingRequestFactoryProxyr   TestCaser  r  r  r"  r0  r{  r0   r+   r'   <module>r     s    7  8 8 0 H 2 " + 0 4 I "  # #   
* ,/a aH' 'TB3.( ( 33EF 4<< D 55IJ %#7 %  %= % !
	54<< 	5 55IJ C C0  88OP M M"K0x((*: K0\(a
0**,< a
0HT5X..0@ T5n&8,,.> &8l0))+; l0^2H%% 2Y  *)F*s   >"G 	GG