
    tf                    ^   d Z ddlZddlmZmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZmZmZm Z  dZ!	 ddl"Z"ddl#Z"ddl$Z"ddl%Z%ddl&Z&ddl'm(Z(m)Z) ddl*m+Z+ n# e,$ r dZ!Y nw xY w G d d          Z- G d d          Z.d.dZ/d.dZ0d Z1 G d dej2                  Z3 e e3          Z4 G d dej2                  Z5 e e5          Z6 G d de5          Z7 e e7          Z8 G d dej2                  Z9 e e9          Z: G d  d!          Z; e e;          Z< G d" d#          Z= G d$ d%ej>        e=          Z? G d& d'ej>        e=          Z@ G d( d)ej>        e=          ZA G d* d+ej>        e=          ZB G d, d-ej>        e=          ZCdS )/z
Test HTTP/2 support.
    N)directlyProvides
providedBy)defererrorreactortask)IPv4Address)MemoryReactorClockStringTransport)failure)	iterbytes)DummyProducer)unittest)http)DelayedHTTPHandlerDelayedHTTPHandlerProxyDummyHTTPHandlerDummyHTTPHandlerProxyDummyPullProducerHandlerProxy._IDeprecatedHTTPChannelToRequestInterfaceProxy_makeRequestProxyFactory)DecoderEncoder)H2ConnectionzHTTP/2 support not enabledc                   h    e Zd ZdZd Zd Zd Zg dfdZddZdd
Z	d Z
ddZddZddZg fdZdS )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                 ,    t                      | _        d S Nr   encoderselfs    Z/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/test/test_http2.py__init__zFrameFactory.__init__8       yy    c                 ,    t                      | _        d S r   r   r!   s    r#   refreshEncoderzFrameFactory.refreshEncoder;   r%   r&   c                     dS )Ns   PRI * HTTP/2.0

SM

 r!   s    r#   clientConnectionPrefacez$FrameFactory.clientConnectionPreface>   s    22r&      c                 J   t           j                            |          }| j                            |          |_        |j                            d           |D ]}|j                            |           |                                D ]\  }}t          |||           |S )zS
        Builds a single valid headers frame out of the contained headers.
        END_HEADERS)

hyperframeframeHeadersFramer    encodedataflagsadditemssetattr)	r"   headersr4   streamIDpriorityKwargsfflagkvs	            r#   buildHeadersFramezFrameFactory.buildHeadersFrameA   s     ))(33$$W--	M""" 	 	DGKK"((** 	 	DAqAq!r&   Nc                     |t          |          nt                      }t          j                            |          }||_        ||_        |S )zD
        Builds a single data frame out of a chunk of data.
        )setr/   r0   	DataFramer3   r4   )r"   r3   r4   r9   r;   s        r#   buildDataFramezFrameFactory.buildDataFrameP   sE     $/E


SUU&&x00r&   Fc                     t           j                            d          }|r|j                            d           ||_        |S )z1
        Builds a single settings frame.
        r   ACK)r/   r0   SettingsFramer4   r5   settings)r"   rG   ackr;   s       r#   buildSettingsFramezFrameFactory.buildSettingsFrameZ   sB     **1-- 	GKK
r&   c                 R    t           j                            |          }||_        |S )z5
        Builds a single WindowUpdate frame.
        )r/   r0   WindowUpdateFramewindow_increment)r"   r9   	incrementr;   s       r#   buildWindowUpdateFramez#FrameFactory.buildWindowUpdateFramee   s'     ..x88&r&   r   r&   c                 n    t           j                            d          }||_        ||_        ||_        |S )z/
        Builds a single GOAWAY frame.
        r   )r/   r0   GoAwayFrame
error_codelast_stream_idadditional_data)r"   lastStreamID	errorCodeadditionalDatar;   s        r#   buildGoAwayFramezFrameFactory.buildGoAwayFramem   s6     ((++ '*r&   c                 R    t           j                            |          }||_        |S )z3
        Builds a single RST_STREAM frame.
        )r/   r0   RstStreamFramerQ   )r"   r9   rU   r;   s       r#   buildRstStreamFramez FrameFactory.buildRstStreamFramew   s&     ++H55 r&   c                 n    t           j                            |          }||_        ||_        ||_        |S )z1
        Builds a single priority frame.
        )r/   r0   PriorityFrame
depends_onstream_weight	exclusive)r"   r9   weight	dependsOnr_   r;   s         r#   buildPriorityFramezFrameFactory.buildPriorityFrame   s4     **844  r&   c                     t           j                            |          }||_        | j                            |          |_        t          |          |_        |j        	                    d           |S )z5
        Builds a single Push Promise frame.
        r.   )
r/   r0   PushPromiseFramepromised_stream_idr    r2   r3   rA   r4   r5   )r"   r9   promisedStreamIDr8   r4   r;   s         r#   buildPushPromiseFramez"FrameFactory.buildPushPromiseFrame   s_     --h77/$$W--e**	M"""r&   Nr,   )F)r   r&   )r   )r   F)__name__
__module____qualname____doc__r$   r(   r+   r?   rC   rI   rN   rW   rZ   rb   rg   r*   r&   r#   r   r   1   s         ! ! !! ! !3 3 3 02A       	 	 	 	            PR 	 	 	 	 	 	r&   r   c                   .    e Zd ZdZd Zd Zd Zd ZeZdS )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                 :    t                      | _        d| _        d S )Nr&   )r   decoder_datar!   s    r#   r$   zFrameBuffer.__init__   s    yy


r&   c                 &    | xj         |z  c_         d S r   )rq   )r"   r3   s     r#   receiveDatazFrameBuffer.receiveData   s    

d



r&   c                     | S r   r*   r!   s    r#   __iter__zFrameBuffer.__iter__   s    r&   c                 (   t          | j                  dk     rt                      t          j        j                            | j        d d                   \  }}t          | j                  |dz   k     rt                      |                    t          | j        dd|z                                 | j        d|z   d          | _        t          |t          j        j
                  r&| j                            |j        d          |_        |S )N	   T)raw)lenrq   StopIterationr/   r0   Frameparse_frame_header
parse_body
memoryview
isinstancer1   rp   decoder3   )r"   r0   lengths      r#   nextzFrameBuffer.next   s    tz??Q//!"(.AA$*RaR.QQvtz??VaZ''//!DJq1v:~$>??@@@ZF
-
eZ-:;; 	C,,UZT,BBEJr&   N)	ri   rj   rk   rl   r$   rs   ru   r   __next__r*   r&   r#   rn   rn      s[        
 
          HHHr&   rn   r,   c                    t                      g }|                                        |                      |                    fd|D                        |d         j                            d           |S )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}
    Nr8   r9   c              3   F   K   | ]}                     |           V  dS )r9   N)rC   ).0chunkframeFactoryr9   s     r#   	<genexpr>z%buildRequestFrames.<locals>.<genexpr>   sG        BG##EH#==     r&   
END_STREAM)r   appendr?   extendr4   r5   r8   r3   r   r9   framess     `` r#   buildRequestFramesr      s    * #~~F
MM,0080TTUUU
MM     KO      2J&&&Mr&   c                 d    t          | |||          }d                    d |D                       S )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   >   K   | ]}|                                 V  d S r   	serializer   r;   s     r#   r   z$buildRequestBytes.<locals>.<genexpr>   s*      22aAKKMM222222r&   )r   joinr   s        r#   buildRequestBytesr      s8    &  |XFFF88226222222r&   c                 f    t                      }|                    |            t          |          S )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.
    )rn   rs   list)r3   buffers     r#   framesFromBytesr      s-     ]]F
t<<r&   c                       e Zd ZdZdZd ZdS )ChunkedHTTPHandlerz
    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                 
   t          | j                            d          d                   }|                     d           t	          |          D ]}|                     | j                   |                                  d S )N   /r      )inturisplitsetResponseCoderangewrite	chunkDatafinish)r"   chunks_s      r#   processzChunkedHTTPHandler.process  ss    TX^^D))"-..S!!!v 	' 	'AJJt~&&&&r&   N)ri   rj   rk   rl   r   r   r*   r&   r#   r   r     s4           I    r&   r   c                   *    e Zd ZdZd Zd Zd Zd ZdS )ConsumerDummyHandlera  
    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                     t          j        j        | g|R i | | j                                         d| _        d | _        d S )NF)r   Requestr$   channelpauseProducing_requestReceivedrq   r"   argskwargss      r#   r$   zConsumerDummyHandler.__init__*  sN    d4T444V444 	##%%% %


r&   c                 8    | j                                          dS )z&
        Start the data pipe.
        N)r   resumeProducingr!   s    r#   
acceptDatazConsumerDummyHandler.acceptData2  s     	$$&&&&&r&   c                 D    d| _         t          j        j        | g|R i |S )NT)r   r   r   requestReceivedr   s      r#   r   z$ConsumerDummyHandler.requestReceived8  s-     $|+DB4BBB6BBBr&   c                     |                      d           | j                                        | _        d}|                     |           |                                  d S )Nr   s0   this is a response from a consumer dummy handler)r   contentreadrq   r   r   )r"   
returnDatas     r#   r   zConsumerDummyHandler.process<  sS    S!!!\&&((
H


:r&   N)ri   rj   rk   rl   r$   r   r   r   r*   r&   r#   r   r   "  s]           ' ' 'C C C    r&   r   c                       e Zd ZdZd ZdS )AbortingConsumerDummyHandlerz
    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                 j    | j                                          | j                                          dS )z@
        Start and then immediately stop the data pipe.
        N)r   r   stopProducingr!   s    r#   r   z'AbortingConsumerDummyHandler.acceptDataO  s2     	$$&&&""$$$$$r&   N)ri   rj   rk   rl   r   r*   r&   r#   r   r   G  s-         % % % % %r&   r   c                       e Zd ZdZd ZdS )DummyProducerHandlerz
    An HTTP request handler that registers a dummy producer to serve the body.

    The owner must call C{finish} to complete the response.
    c                 t    |                      d           |                     t                      d           d S )Nr   T)r   registerProducerr   r!   s    r#   r   zDummyProducerHandler.processc  s6    S!!!moot44444r&   N)ri   rj   rk   rl   r   r*   r&   r#   r   r   \  s-         5 5 5 5 5r&   r   c                       e Zd ZdZd Zd ZdS )NotifyingRequestFactorya(  
    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                 p    g | _         || _        t          | j                  D ]}t          | |           d S r   )results_wrappedFactoryr   r   )r"   wrappedFactory	interfaces      r#   r$   z NotifyingRequestFactory.__init__s  sJ    -
 $D$899 	. 	.IT9----	. 	.r&   c                      | j         |i |}| j                            |                                           t	          |          S r   )r   r   r   notifyFinishr   )r"   r   r   reqs       r#   __call__z NotifyingRequestFactory.__call__}  sI    "d"D3F33C,,..///=cBBBr&   N)ri   rj   rk   rl   r$   r   r*   r&   r#   r   r   k  sA         . . .C C C C Cr&   r   c                        e Zd ZdZereZd ZdS )HTTP2TestHelpersz]
    A superclass that contains no tests but provides test helpers for HTTP/2
    tests.
    c                 \    |                      t          j        t          |j                   dS )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#   assertAllStreamsBlockedz(HTTP2TestHelpers.assertAllStreamsBlocked  s(    
 	(0$
8KLLLLLr&   N)ri   rj   rk   rl   skipH2skipr   r*   r&   r#   r   r     sA         
  M M M M Mr&   r   c                      e Zd Zg dZg dZg dZg dZdZg dZdZ	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d)S )*HTTP2ServerTests   :method   GETs
   :authoritys	   localhost   :pathr   s   :schemes   httpss
   user-agents   twisted-test-code)   custom-header   1)r      2)r      POSTr   )r      /post_endpointr   r   )   content-lengths   25s   hello s   world, s   it's s   http/2!)   :statuss   200)   requestr   )   commandr   s   versions   HTTP/2)r   s   13   '''
None
'''
)r   r   r   r   r   r   )r   s   36$   '''
25
hello world, it's http/2!'''
c                 
   t                      }t                      }|                                }|t          |||          z  }|                    |           t          |          D ]}|                    |           ||fS )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   r+   r   makeConnectionr   dataReceived)r"   r   r8   bodyr   	transportrequestBytesbytes           r#   connectAndReceivez"HTTP2ServerTests.connectAndReceive  s      $~~#%%	#;;==)'4FFF!!),,,l++ 	* 	*D##D))))Y&&r&   c                      t                      }t          |_                             | j        g           \  } fd}|j        d                             |          S )z
        Send request over a TCP connection and confirm that we get back the
        expected data in the order and style we expect.
        c                    t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 t          |d         t          j        j
                                                 t          |d         t          j        j
                                                 t          |d         j                  t          j                                                 |d         j        j                                       |d         j        d                               d|d         j        v            d S )N   c              3   ,   K   | ]}|j         d k    V  dS r,   N	stream_idr   s     r#   r   zGHTTP2ServerTests.test_basicRequest.<locals>.validate.<locals>.<genexpr>  )      EEQq 0EEEEEEr&   r,         r&   r   )r   valueassertEqualry   
assertTrueallr   r/   r0   r1   rB   dictr3   getResponseHeadersgetResponseDatar4   r9   r   r"   r   s     r#   validatez4HTTP2ServerTests.test_basicRequest.<locals>.validate  sf   $Y__%6%677FS[[!,,,OOCEE&*EEEEEFFFOOJvay*2B2OPPQQQOOJvay*2B2LMMNNNOOJvay*2B2LMMNNNT&).1148O3P3PQQQVAY^T-ABBBVAY^S111OOLF1IO;<<<<<r&   r,   )r   r   requestFactoryr  getRequestHeaders_streamCleanupCallbacksaddCallbackr"   r   r   r  r   s   `   @r#   test_basicRequestz"HTTP2ServerTests.test_basicRequest  sr     "^^
$9
!--j$:PRTUU9	= 	= 	= 	= 	= 	= 1!4@@JJJr&   c                      t                      }t          |_                             | j         j                  \  } fd}|j        d                             |          S )zV
        Send a POST request and confirm that the data is safely transferred.
        c                    t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 t          |d         t          j        j
                                                 t          |d         t          j        j
                                                 t          |d         j                  t          j                                                 |d         j        j                                       |d         j        d                               d|d         j        v            d S )Nr  c              3   ,   K   | ]}|j         d k    V  dS r  r  r   s     r#   r   zFHTTP2ServerTests.test_postRequest.<locals>.validate.<locals>.<genexpr>	  )      FFQq 0FFFFFFr&   r   r&   r   )r   r  r  ry   r  r  r   r/   r0   r1   rB   r  r3   postResponseHeaderspostResponseDatar4   r  s     r#   r  z3HTTP2ServerTests.test_postRequest.<locals>.validate  si   $Y__%6%677F S[[!,,,OOCFF&+FFFFFGGGOOJvbz:3C3PQQRRROOJvbz:3C3MNNOOOOOJvbz:3C3MNNOOOT&*/22D9Q4R4RSSSVBZ_d.CDDDVBZ_c222OOLF2J,<<=====r&   r,   )r   r   r  r  postRequestHeaderspostRequestDatar  r  r  s   `   @r#   test_postRequestz!HTTP2ServerTests.test_postRequest  sy     "^^
$9
!--/1E
 
9	> 	> 	> 	> 	> 	>  1!4@@JJJr&   c                      g ddd  j         D             }t                      }t          |_                             || j                  \  } fd}|j        d                             |          S )zm
        Send a POST request without length and confirm that the data is safely
        transferred.
        )r   r   r   r   )r   s   38s&   '''
None
hello world, it's http/2!'''
c                 (    g | ]\  }}|d k    ||fS )r   r*   )r   xys      r#   
<listcomp>z=HTTP2ServerTests.test_postRequestNoLength.<locals>.<listcomp>%  s2     
 
 
q!!?P:P:PQF:P:P:Pr&   c                    t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 t          |d         t          j        j
                                                 t          |d         t          j        j
                                                 t          |d         j                  t                                                   |d         j                                       |d         j        d                               d|d         j        v            d S )Nr  c              3   ,   K   | ]}|j         d k    V  dS r  r  r   s     r#   r   zNHTTP2ServerTests.test_postRequestNoLength.<locals>.validate.<locals>.<genexpr>4  r  r&   r  r   r   r&   r   )r   r  r  ry   r  r  r   r/   r0   r1   rB   r  r3   r4   )r9   r   r"  r!  r"   r   s     r#   r  z;HTTP2ServerTests.test_postRequestNoLength.<locals>.validate/  se   $Y__%6%677F S[[!,,,OOCFF&+FFFFFGGGOOJvbz:3C3PQQRRROOJvbz:3C3MNNOOOOOJvbz:3C3MNNOOOT&*/22D9L4M4MNNNVBZ_.>???VBZ_c222OOLF2J,<<=====r&   r,   )r#  r   r   r  r  r$  r  r  )r"   r#  r   r   r  r"  r!  r   s   `    @@@r#   test_postRequestNoLengthz)HTTP2ServerTests.test_postRequestNoLength  s    

 
 
 H
 
#6
 
 
 "^^
$9
!--*D,@
 
9	> 	> 	> 	> 	> 	> 	> 	>  1!4@@JJJr&   c                    	 d}t                      t                      t                      }t          |_        t          t          d|dz  d                    	 fd	D             }                                }t          j	        
                    t          |           }|d                    d |D                       z  }|                               t          |          D ]}|                    |            	fd}t!          j        t          |j                                                                                |          S )zi
        Many interleaved POST requests all get received and responded to
        appropriately.
        (   r,   r
  c                 H    g | ]}t          j        j        |          S r*   )r   r#  r$  )r   r9   r;   r"   s     r#   r*  z=HTTP2ServerTests.test_interleavedRequests.<locals>.<listcomp>P  sD     
 
 
  ')=q( 
 
 
r&   r&   c              3   >   K   | ]}|                                 V  d S r   r   r   r0   s     r#   r   z<HTTP2ServerTests.test_interleavedRequests.<locals>.<genexpr>\  ,       G Gu!2!2 G G G G G Gr&   c                 P   t                                                    }                    t          |          d           D ]܊fd|D             }                    t          |          d                               t	          |d         j                  t	          j                                                 |d         j        j                                       |d         j        d                               d|d         j	        v            d S )	Ny   c                 h    g | ].}|j         k    t          |t          j        j                  ,|/S r*   )r  r   r/   r0   rK   )r   r;   r9   s     r#   r*  zOHTTP2ServerTests.test_interleavedRequests.<locals>.validate.<locals>.<listcomp>m  sH          {h..&q**:*LMM / ...r&   r  r   r,   r
  r&   r   )
r   r  r  ry   r  r3   r!  r"  r  r4   )r   r   streamFramesr9   br"   	streamIDss      @r#   r  z;HTTP2ServerTests.test_interleavedRequests.<locals>.validateb  s5   $QWWYY//F
 S[[,777 & G G       #        \!2!2A666  a-..T5M0N0N     a!5t7LMMM  a!5s;;;Q0E EFFFFG Gr&   )r   r   r   r   r  r   r   r+   	itertoolschainfrom_iterablezipr   r   r   r   r   DeferredListr  valuesr  )
r"   REQUEST_COUNTar   r   r   r  r8  r;   r9  s
   `      @@@r#   test_interleavedRequestsz)HTTP2ServerTests.test_interleavedRequestsA  s}    NNNN0 q-!"3Q7788	
 
 
 
 
 &	
 
 
 0022 ..sF|<< G G G G GGGG	l++ 	! 	!DNN4    	G 	G 	G 	G 	G 	G 	G6 !$q'@'G'G'I'I"J"JKKWW
 
 	
r&   c                    	 t                      t                      t                      }t          |_         j        	d	d<   	fddD             }|d         d         j                            d           d|d         d         _        |d         d         j                            d           d	|d         d         _        	                    d
ddd          }|d         
                    d|           t          j                            |          }                                }|d                    d |D                       z  }|                               t#          |          D ]}|                    |            fd}t'          j        t+          |j                                                                                |          S )zR
        Data in responses is interleaved according to HTTP/2 priorities.
        )z:pathz
/chunked/4r
  c                 4    g | ]}t          g |          S r*   )r   )r   r9   r;   r  s     r#   r*  zAHTTP2ServerTests.test_sendAccordingToPriority.<locals>.<listcomp>  s8     
 
 
 0"aBB
 
 
r&   )r,   r     r   PRIORITY@   r,       rE     T)r9   r`   ra   r_   r&   c              3   >   K   | ]}|                                 V  d S r   r   r2  s     r#   r   z@HTTP2ServerTests.test_sendAccordingToPriority.<locals>.<genexpr>  r3  r&   c                     t                                                    }                    t          |          d           d |D             }g d}                    ||           d S )N   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   )r   r/   r0   rB   r  r   s     r#   r*  zSHTTP2ServerTests.test_sendAccordingToPriority.<locals>.validate.<locals>.<listcomp>  s?        !z!Z=M=W/X/X  r&   )r,   r  r,   r,   r  r,   r,   r  rE  r  rE  r  rE  rE  rE  )r   r  r  ry   )r   r   r9  expectedOrderr8  r"   s       r#   r  z?HTTP2ServerTests.test_sendAccordingToPriority.<locals>.validate  s~    $QWWYY//F S[["--- %+  I JIIMY66666r&   )r   r   r   ChunkedHTTPHandlerProxyr  r  r4   r5   r^   rb   insertr:  r;  r<  r+   r   r   r   r   r   r>  r   r  r?  r  )
r"   rA  r   priorityFramer   r   r  r8  r;   r  s
   `      @@@r#   test_sendAccordingToPriorityz-HTTP2ServerTests.test_sendAccordingToPriority  s   " NNNN2 26!
 
 
 
 
%
 
 
 	q	!z***%'q	!"q	!z***%'q	!",,	 - 
 
 	q	M***..v660022 G G G G GGGG	l++ 	! 	!DNN4    	7 	7 	7 	7 	7 	7 !$q'@'G'G'I'I"J"JKKWW
 
 	
r&   c                    t                      }t                      }t                      }t          |_        |                                }|t          | j        g |          z  }||                    dd| j        dg          	                                z  }|
                    |           t          |          D ] }|                    |           |j        r n!t          |                                          }|                     t#          |          d           |                     t'          |d         t(          j        j                             |                     |j                   dS )zR
        A protocol error from the remote peer terminates the connection.
        r,   r
  r.   )r9   rf   r8   r4   r  r   N)r   r   r   r   r  r+   r   r  rg   r   r   r   r   disconnectingr   r  r  ry   r  r   r/   r0   rP   )r"   r;   r8  rA  r   r   r   s          r#   &test_protocolErrorTerminatesConnectionz7HTTP2ServerTests.test_protocolErrorTerminatesConnection  s]    NNNN0 0022)$*@"aHHH//* /	 0 
 

 )++	 	
l++ 	 	DNN4      !++
 	Va(((
6":z/?/KLLMMM(((((r&   c                     t                      }t          |_                             | j         j                  \  }|j        d         j        j        } 	                    |j
                   t                                                    }                     t          |          d           |                                                      |j
                                        |j        d           t                                                    }                     t          |          d            fd}|j        d                             |          S )z
        The H2Stream data implements IPushProducer, and can have its data
        production controlled by the Request if the Request chooses to.
        r,   s   hello world, it's http/2!r
  c                     t                                                    }                    t          |          d                               d|d         j        v            d S Nr  r   r   r   r  r  ry   r  r4   r  s     r#   r  z;HTTP2ServerTests.test_streamProducingData.<locals>.validate  s\    $Y__%6%677F S[[!,,,OOLF2J,<<=====r&   )r   ConsumerDummyHandlerProxyr  r  r#  r$  streams_requestoriginalassertFalser   r   r  r  ry   r   r  rq   r  r  )r"   r   r   requestr   r  r   s   `     @r#   test_streamProducingDataz)HTTP2ServerTests.test_streamProducingData  sO   
 "^^
$=
!--/1E
 
9 $Q'091222
 !!2!233Va(((
 	0111'CDDD
 !!2!233Va(((	> 	> 	> 	> 	> 	> 1!4@@JJJr&   c                    	 t                      }t                      	t                      }t          |_        t           j         j        |          }t                      |d         _	        |
                                }|d                    d |D                       z  }|                    	           t          |          D ]}|                    |           |j        d         j        j        }                     |j                   |j        d         }|                                 	 fd}|                    |          S )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   r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zAHTTP2ServerTests.test_abortStreamProducingData.<locals>.<genexpr>,  *       ? ?1 ? ? ? ? ? ?r&   r,   c                 B   t                                                    }                    t          |          d                               t          |d         t          j        j                                                 |d         j	        d           d S )Nr
  r   r,   )
r   r  r  ry   r  r   r/   r0   rY   r  )r9   r   r8  r"   s     r#   r  z@HTTP2ServerTests.test_abortStreamProducingData.<locals>.validate?  s    $QWWYY//F S[[!,,,OOJvbz:3C3RSSTTTVBZ1155555r&   )r   r   r   !AbortingConsumerDummyHandlerProxyr  r   r#  r$  rA   r4   r+   r   r   r   r   r[  r\  r]  r^  r   r  r   r  )
r"   r;   rA  r   r   r   r_  cleanupCallbackr  r8  s
   `        @r#   test_abortStreamProducingDataz.HTTP2ServerTests.test_abortStreamProducingData  sL    NNNN< $D$;T=QSTUU55r
0022 ? ? ? ? ????	l++ 	! 	!DNN4     )A,'01222 3A6 		6 	6 	6 	6 	6 	6 **8444r&   c                 X    t                      }t          |_                             | j        g           \  }|j        d         j        j        }|                    d           |                    d           |j	        d         }|
                    |                    dd                                                                          |j                                        |j        du            |                    d            fd}|                    |          S )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.
        r,      first chunk   second chunk)rU   Ns   third chunkc                 B   t                                                    }                    t          |          d                               |d         j        d                               t          |d         t          j        j	                             d S Nr
  r,   
r   r  r  ry   r  r  r   r/   r0   r1   r  s     r#   r  z9HTTP2ServerTests.test_terminatedRequest.<locals>.validateu      $Y__%6%677FS[[!,,,VAY0!444OOJvay*2B2OPPQQQQQr&   )r   DummyProducerHandlerProxyr  r  r  r[  r\  r]  r   r  r   rZ   r   r  _disconnectedr   r  r"   r   r   r_  rf  r  r   s   `     @r#   test_terminatedRequestz'HTTP2ServerTests.test_terminatedRequestJ  s?    "^^
$=
!"&"8"8.#
 #
i
 $Q'09 	n%%%o&&& %<Q? 	,,Q!,<<FFHH	
 	
 	

 	-...4/000 	n%%%	R 	R 	R 	R 	R 	R **8444r&   c                 `    t                      }t          |_                             | j        g           \  }|j        d         j        j        }|                    d           |                    d           |j	        d         }|
                    |                    d                                                                          |j                                        |j        du                                 |j                    fd}|                    |          S )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,   ri  rj  r   rT   Nc                 B   t                                                    }                    t          |          d                               |d         j        d                               t          |d         t          j        j	                             d S rl  rm  r  s     r#   r  z<HTTP2ServerTests.test_terminatedConnection.<locals>.validate  rn  r&   )r   ro  r  r  r  r[  r\  r]  r   r  r   rW   r   r  rp  r   r^  _stillProducingr  rq  s   `     @r#   test_terminatedConnectionz*HTTP2ServerTests.test_terminatedConnection  sB    "^^
$=
!"&"8"8.#
 #
i
 $Q'09 	n%%%o&&& %<Q? 	))q)99CCEE	
 	
 	

 	-...4/000 	3444	R 	R 	R 	R 	R 	R **8444r&   c                      t                      }t          |_         j        dgz   }                     ||g           \  } fd}|j        d                             |          S )zq
        Requests containing Expect: 100-continue cause provisional 100
        responses to be emitted.
        )s   expects   100-continuec                    t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 |d         j
        dg                               d|d         j        v            d S )NrE  c              3   ,   K   | ]}|j         d k    V  dS r  r  r   s     r#   r   zQHTTP2ServerTests.test_respondWith100Continue.<locals>.validate.<locals>.<genexpr>  r	  r&   r,   )r   s   100r   r   )r   r  r  ry   r  r  r   r/   r0   r1   r3   r4   r  s     r#   r  z>HTTP2ServerTests.test_respondWith100Continue.<locals>.validate  s    $Y__%6%677FS[[!,,,OOCEE&*EEEEEFFFOOJvay*2B2OPPQQQVAY^.B-CDDDOOLF2J,<<=====r&   r,   )r   r   r  r  r  r  r  )r"   r   r8   r   r  r   s   `    @r#   test_respondWith100Continuez,HTTP2ServerTests.test_respondWith100Continue  s    
 "^^
$9
! (,H+II--j'2FF9
	> 	> 	> 	> 	> 	> 1!4@@JJJr&   c                     t                      }t          |_                             | j        g           \  }|j        d         }|j        j        }|j        d         }|	                                  
                    |j                    
                    |j        du             fd}|                    |          S )z
        Triggering the call to L{H2Stream._respondToBadRequestAndDisconnect}
        leads to a 400 error being sent automatically and the stream being torn
        down.
        r,   Nc                    t                                                    }                    t          |          d                               t          |d         t          j        j                                                 |d         j	        dg                               d|d         j
        v            d S )Nr
  r,   )r   s   400r   r   )r   r  r  ry   r  r   r/   r0   r1   r3   r4   r  s     r#   r  z6HTTP2ServerTests.test_respondWith400.<locals>.validate  s    $Y__%6%677FS[[!,,,OOJvay*2B2OPPQQQVAY^.B-CDDDOOLF2J,<<=====r&   )r   ro  r  r  r  r[  r\  r]  r  !_respondToBadRequestAndDisconnectr  rp  r   r  )r"   r   r   streamr_  rf  r  r   s   `      @r#   test_respondWith400z$HTTP2ServerTests.test_respondWith400  s     "^^
$=
!--j$:PRTUU9 #A&/*$<Q? 	00222 	-...4/000	> 	> 	> 	> 	> 	> **8444r&   c                 ^    t                      }t          |_                             | j        g           \  }|j        d         }|j        j        }g dD ]}|                    |           |	                                  fd}|j
        d                             |          S )z
        Calling L{Request.loseConnection} causes all data that has previously
        been sent to be flushed, and then the stream cleanly closed.
        r,   )   hello   world   here   are   some   writesc                    t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 d|d         j
        v            d |D             }                    |dgz              d S )Nrw   c              3   ,   K   | ]}|j         d k    V  dS r  r  r   s     r#   r   zQHTTP2ServerTests.test_loseH2StreamConnection.<locals>.validate.<locals>.<genexpr>  r	  r&   r,   r   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r   r/   r0   rB   r3   r   s     r#   r*  zRHTTP2ServerTests.test_loseH2StreamConnection.<locals>.validate.<locals>.<listcomp>  ?     " " "*Q
8H8R*S*S"" " "r&   r&   r   r  r  ry   r  r  r   r/   r0   r1   r4   )r9   r   receivedDataChunks
dataChunksr"   r   s      r#   r  z>HTTP2ServerTests.test_loseH2StreamConnection.<locals>.validate  s    $Y__%6%677F S[[!,,,OOCEE&*EEEEEFFFOOJvay*2B2OPPQQQOOLF2J,<<===" " &" " " "cU"    r&   )r   ro  r  r  r  r[  r\  r]  r   loseConnectionr  r  )	r"   r   r   r  r_  r   r  r  r   s	   `      @@r#   test_loseH2StreamConnectionz,HTTP2ServerTests.test_loseH2StreamConnection  s     "^^
$=
!--j$:PRTUU9 #A&/* ONN
 	! 	!EMM%     	   	 	 	 	 	 	 	$ 1!4@@JJJr&   c                     t                      }t          |_        |                     || j        g            |j        d         }|j        j        }|                     t          |j
        |d           dS )zK
        The L{H2Stream} object forbids registering two producers.
        r,   TN)r   ro  r  r  r  r[  r\  r]  r   
ValueErrorr   )r"   r   r  r_  s       r#   test_cannotRegisterTwoProducersz0HTTP2ServerTests.test_cannotRegisterTwoProducers#  sl     "^^
$=
!z4+A2FFF #A&/**f&=wMMMMMr&   c                 @    t                      }t          |_                             | j        g           \  }|j        d         }|j        j        j        j	        }|
                    fd            fd}|j        d         
                    |          S )z
        L{Request} objects that have registered pull producers get blocked and
        unblocked according to HTTP/2 flow control.
        r,   c                 ,                                     S r   )r   )r(  r_  s    r#   <lambda>z;HTTP2ServerTests.test_handlesPullProducer.<locals>.<lambda>?  s    w~~/?/? r&   c                     t                                                    }                    d|d         j        v            d |D             }                    |g d           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zOHTTP2ServerTests.test_handlesPullProducer.<locals>.validate.<locals>.<listcomp>I  ?       *Q
8H8R*S*S  r&   )   0r   r      3   4   5   6   7   8   9r&   r   r  r  r4   r  r9   r   r  r"   r   s      r#   r  z;HTTP2ServerTests.test_handlesPullProducer.<locals>.validateB  s    $Y__%6%677F OOLF2J,<<===  &  J QQQ    r&   )r   r   r  r  r  r[  r\  r]  _actualProducerresultr  r  )r"   r   r   r  producerCompleter  r_  r   s   `     @@r#   test_handlesPullProducerz)HTTP2ServerTests.test_handlesPullProducer1  s    
 "^^
$A
!--j$:PRTUU9 #A&/*"29$$%?%?%?%?@@@	 	 	 	 	 	 1!4@@JJJr&   c                 ,   t                      }t          |_        |                     || j        g            |j        d         j        j        }|                     |	                                           |j        d         
                                 dS )zJ
        L{Request} objects can correctly ask isSecure on HTTP/2.
        r,   N)r   r   r  r  r  r[  r\  r]  r^  isSecureabortConnection)r"   r   r_  s      r#   test_isSecureWorksProperlyz+HTTP2ServerTests.test_isSecureWorksProperlyS  s     "^^
$;
!z4+A2FFF$Q'09))++,,,1--/////r&   c                 &    t                      }t          |_                             | j        g           \  }|j        d         j        j        }t          j	        d|j
                    fd}|j        d                             |          S )zL
        L{H2Connection} correctly unblocks when a stream is ended.
        r,   {Gz?c                      t                                                    }                    t          |          d                               d|d         j        v            d S )Nr  r   r   rY  )r   r   r"   r   s     r#   validateCompletezCHTTP2ServerTests.test_lateCompletionWorks.<locals>.validateCompletel  s\    $Y__%6%677F S[[!,,,OOLF2J,<<=====r&   )r   r   r  r  r  r[  r\  r]  r   	callLaterr   r  r  )r"   r   r   r_  r  r   s   `    @r#   test_lateCompletionWorksz)HTTP2ServerTests.test_lateCompletionWorks_  s     "^^
$;
!--j$:PRTUU9 $Q'09$///	> 	> 	> 	> 	> 	> 1!4@@AQRRRr&   c                 z    t                      }t          |_                             | j        g           \  }|j        d         }|j        j        }|                    d           |	                    g d           |
                                 |j        d         } fd}|                    |          S )zW
        L{H2Stream} objects can send a series of frames via C{writeSequence}.
        r,   r   )   Hello   ,   world!c                     t                                                    }                    d|d         j        v            d |D             }                    |g d           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zTHTTP2ServerTests.test_writeSequenceForChannels.<locals>.validate.<locals>.<listcomp>  r  r&   )r  r  r  r&   r  r  s      r#   r  z@HTTP2ServerTests.test_writeSequenceForChannels.<locals>.validate  s}    $Y__%6%677F OOLF2J,<<===  &  J Z)I)I)IJJJJJr&   )r   r   r  r  r  r[  r\  r]  r   writeSequencer   r  r  )r"   r   r   r  r_  completionDeferredr  r   s   `      @r#   test_writeSequenceForChannelsz.HTTP2ServerTests.test_writeSequenceForChannelsu  s     "^^
$;
!--j$:PRTUU9#A&/*$$$888999'?B
	K 
	K 
	K 
	K 
	K 
	K "--h777r&   c                    	
 t                      
t                      t                      t          _        
                                }|
                    t          j        j	        j
        di                                          z  }|t           j        g 
          z  }                               t          |          D ]}                    |           j        d         }|j        j                            d           g d		fd}t+          j        t.          d|          }|                    
fd           	 fd}j        d                             |          S )	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.
        rE  r,      fiver)r  r  r  r  c                  d    D ]}                      |                                             d S r   )r   r   )r   r  r_  s    r#   write_chunksz7HTTP2ServerTests.test_delayWrites.<locals>.write_chunks  s=    # % %e$$$$NNr&   r  c                  |                                             dd                                                    S )Nr,   2   r9   rM   )r   rN   r   )r   rA  r;   s    r#   r  z3HTTP2ServerTests.test_delayWrites.<locals>.<lambda>  s7    !..((!r(BBLLNN  r&   c                     t                                                    }                    t          |          d                               t          d |dd          D                                                      t          |d         t          j        j	                                                 d|d         j
        v            d |D             }                    |dgz   dgz              d S )	Nrw   c              3   ,   K   | ]}|j         d k    V  dS r  r  r   s     r#   r   zFHTTP2ServerTests.test_delayWrites.<locals>.validate.<locals>.<genexpr>  r	  r&   r
  r   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zGHTTP2ServerTests.test_delayWrites.<locals>.validate.<locals>.<listcomp>  r  r&   r  r&   r  )r9   r   r  r8  r  r"   s      r#   r  z3HTTP2ServerTests.test_delayWrites.<locals>.validate  s   $QWWYY//F S[[!,,,OOCEE&*EEEEEFFFOOJvay*2B2OPPQQQOOLF2J,<<===" " &" " " "
Z'3%/    r&   )r   r   r   r   r  r+   rI   h2rG   SettingCodesINITIAL_WINDOW_SIZEr   r   r  r   r   r   r[  r\  r]  r   r   
deferLaterr   r  r  )r"   r   r   r  r  dr  rA  r8  r  r;   r_  s   `      @@@@@r#   test_delayWritesz!HTTP2ServerTests.test_delayWrites  s    NNNN20022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4     1/* 	h:::
	 	 	 	 	 	 OGT<88	    	
 	
 	
	 	 	 	 	 	 	$ (+77AAAr&   c                 6   t                      }t                      }t                      }t          |_        |                                }|t          | j        g |          z  }||                    d          	                                z  }|
                    |           |                    |           t          |                                          }|                     t          |          d           |                     d|j                   dS )zu
        A client that immediately resets after sending the body causes Twisted
        to send no response.
        r8   r3   r   r,   r   N)r   r   r   r   r  r+   r   r  rZ   r   r   r   r   r  r  ry   assertNotInr  )r"   r   r   rA  r   r   s         r#   test_resetAfterBodyz$HTTP2ServerTests.test_resetAfterBody  s   
 $~~#%%	NN0#;;==)*,
 
 
 	
 	88!8DDNNPPP	###	|$$$ !2!233Va(((A566666r&   c                     t          j                     G fddt                    }t                      t	          j                    }t          |          _        |_        t                      _
                              j        g             fd}                    |           j        d         }t          j        |g          S )z
        A custom L{Request} subclass that requires the site and factory in the
        constructor is able to get them.
        c                       e Zd Z fdZdS )THTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.SuperRequestc                     t          j        | g|R i |                     | j        j        | j        j        f           d S r   )r   r$   callbackr   sitefactory)r"   r   r   r  s      r#   r$   z]HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.SuperRequest.__init__  sK     )$@@@@@@@

DL-t|/CDEEEEEr&   N)ri   rj   rk   r$   )r  s   r#   SuperRequestr    s5        F F F F F F Fr&   r  c                 ~    | \  }}                     |j                                        |j                   d S r   )assertIsr  r  )r   r  r  r   r"   s      r#   validateFactoryAndSitez^HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor.<locals>.validateFactoryAndSite  s?     MD'MM$
000MM':#566666r&   r,   )r   Deferredr   r   r   HTTPFactoryr   r  r  objectr  r  r  r  r  gatherResults)r"   r  httpFactoryr  rf  r   r  s   `    @@r#   -test_RequestRequiringFactorySiteInConstructorz>HTTP2ServerTests.test_RequestRequiringFactorySiteInConstructor  s   
 N	F 	F 	F 	F 	F 	F 	F+ 	F 	F 	F
 "^^
&(($<\$J$J
! )
 ((
z4+A2FFF	7 	7 	7 	7 	7 	7
 	
,--- %<Q?"A#7888r&   c                 x    t                      }t          t                    |_                             | j        g           \  }}|j        j        }                     t          |          d            fd}|d         }|	                    |           |j
        d         }t          j        ||g          S )z
        A request sent to a HTTP/2 connection fires the
        L{http.Request.notifyFinish} callback with a L{None} value.
        r,   c                 2                         |            d S r   )assertIsNone)r  r"   s    r#   r  z?HTTP2ServerTests.test_notifyOnCompleteRequest.<locals>.validate  s    f%%%%%r&   r   )r   r   r   r  r  r  r   r  ry   r  r  r   r  )r"   r   r   r   	deferredsr  r  rf  s   `       r#   test_notifyOnCompleteRequestz-HTTP2ServerTests.test_notifyOnCompleteRequest  s    
 "^^
$;<L$M$M
!--j$:PRTUU9-5	Y+++	& 	& 	& 	& 	& aL	h %<Q?"A#7888r&   c                     t                      }t          t                    |_                             | j        g           \  }}|j        j        }                     t          |          d            fd} fd}|d         }|	                    ||           |
                    d                                          }|                    |           |S )zw
        A HTTP/2 reset stream fires the L{http.Request.notifyFinish} deferred
        with L{ConnectionLost}.
        r,   c                 2                         d           d S Nz#Didn't errback, called back insteadfailignr"   s    r#   r  z;HTTP2ServerTests.test_notifyOnResetStream.<locals>.callback6      II;<<<<<r&   c                                          | t          j                                       | j        t
          j                   d S r   assertIsInstancer   Failurer  typer   ConnectionLostreasonr"   s    r#   errbackz:HTTP2ServerTests.test_notifyOnResetStream.<locals>.errback9  9    !!&'/:::MM&+u';<<<4r&   r   r   )r   r   r   r  r  r  r   r  ry   addCallbacksrZ   r   r   )	r"   r   r   r   r  r  r  r  invalidDatas	   `        r#   test_notifyOnResetStreamz)HTTP2ServerTests.test_notifyOnResetStream&  s    
 "^^
$;<N$O$O
!"&"8"8.#
 #
i -5	Y+++	= 	= 	= 	= 	=	 	 	 	 	
 aL	x))) #666BBLLNN,,,r&   c                 6    t                      }t          t                    |_                             | j        g           \  }}t           j        g |d          }|                    |           |j        j        } 	                    t          |          d            fd} fd}|D ]}|                    ||           |                    dd                                          }	|                    |	           t          j        |          S )	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   r9   r
  c                 2                         d           d S r  r  r  s    r#   r  z=HTTP2ServerTests.test_failWithProtocolError.<locals>.callbacka  r  r&   c                                          | t          j                                        | j        t          j        j                   d S r   )r  r   r  r  r  
exceptionsProtocolErrorr  s    r#   r  z<HTTP2ServerTests.test_failWithProtocolError.<locals>.errbackd  s=    !!&'/:::!!&,0KLLL4r&      yo   r3   r9   )r   r   r   r  r  r  r   r   r   r  ry   r  rC   r   r   r  
r"   r   r   r   secondRequestr  r  r  r  r  s
   `         r#   test_failWithProtocolErrorz+HTTP2ServerTests.test_failWithProtocolErrorG  sI    "^^
$;<N$O$O
!"&"8"8.#
 #
i *"B\A
 
 
 	... -5	Y+++	= 	= 	= 	= 	=	 	 	 	 	
  	. 	.ANN8W---- #11ut1LLVVXX,,,"9---r&   c                 4    t                      }t          t                    |_                             | j        g           \  }}t           j        g |d          }|                    |           |j        j        } 	                    t          |          d            fd} fd}|D ]}|                    ||           |                    d                                          }	|                    |	           t          j        |          S )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  r  r
  c                 2                         d           d S r  r  r  s    r#   r  z4HTTP2ServerTests.test_failOnGoaway.<locals>.callback  r  r&   c                                          | t          j                                       | j        t
          j                   d S r   r  r  s    r#   r  z3HTTP2ServerTests.test_failOnGoaway.<locals>.errback  r  r&   rt  )r   r   r   r  r  r  r   r   r   r  ry   r  rW   r   r   r  r  s
   `         r#   test_failOnGoawayz"HTTP2ServerTests.test_failOnGoaways  sG    "^^
$;<N$O$O
!"&"8"8.#
 #
i *"B\A
 
 
 	... -5	Y+++	= 	= 	= 	= 	=	 	 	 	 	
  	. 	.ANN8W---- #333CCMMOO,,,"9---r&   c                     t                      }t          t                    |_                             | j        g           \  }}t           j        g |d          }|                    |           |j        j        } 	                    t          |          d            fd} fd}|D ]}|                    ||           |                                 t          j        |          S )z
        The transport telling the HTTP/2 connection to stop producing will
        fire all L{http.Request.notifyFinish} errbacks with L{error.}
        r  r  r
  c                 2                         d           d S r  r  r  s    r#   r  z;HTTP2ServerTests.test_failOnStopProducing.<locals>.callback  r  r&   c                                          | t          j                                       | j        t
          j                   d S r   r  r  s    r#   r  z:HTTP2ServerTests.test_failOnStopProducing.<locals>.errback  r  r&   )r   r   r   r  r  r  r   r   r   r  ry   r  r   r   r  )	r"   r   r   r   r  r  r  r  r  s	   `        r#   test_failOnStopProducingz)HTTP2ServerTests.test_failOnStopProducing  s#    "^^
$;<N$O$O
!"&"8"8.#
 #
i *"B\A
 
 
 	... -5	Y+++	= 	= 	= 	= 	=	 	 	 	 	
  	. 	.ANN8W---- 	  """"9---r&   c                     t                      }t          t                    |_                             | j        g           \  }}|j        j        }                     t          |          d            fd} fd}|d         }|	                    ||           |j
        d         }|                                 |S )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}.
        r,   c                 2                         d           d S r  r  r  s    r#   r  z7HTTP2ServerTests.test_notifyOnFast400.<locals>.callback  r  r&   c                                          | t          j                                       | j        t
          j                   d S r   r  r  s    r#   r  z6HTTP2ServerTests.test_notifyOnFast400.<locals>.errback  r  r&   r   )r   r   r   r  r  r  r   r  ry   r  r[  r~  )	r"   r   r   r   r  r  r  r  r  s	   `        r#   test_notifyOnFast400z%HTTP2ServerTests.test_notifyOnFast400  s     "^^
$;<N$O$O
!"&"8"8.#
 #
i -5	Y+++	= 	= 	= 	= 	=	 	 	 	 	
 aL	x))) #A&00222r&   c                    t                      }t          |          }|j        |_        t          |_        d}t                      }t                      }|                                }|                    |           |	                    |           |	                    t          | j        g ||                     |                                 d|_        |                    |           |                     |j                   dS )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,   r   r   N)r
   r   r  r   r  r   r   r+   r   r   r   r  r   _maxBufferedControlFrameBytesr~  r  disconnected)r"   memoryReactorr   r9   r   r   r+   s          r#   test_fast400WithCircuitBreakerz/HTTP2ServerTests.test_fast400WithCircuitBreaker  s    +,,!-00
,6
 %7
!#~~#%%	 #/"F"F"H"H!!),,, 7888&L8  	
 	
 	
 	!!###34
044X>>>	./////r&   c                    t                      }t          |_        t                      }t	                      }|                                }|                    |           |                    |           |                                 t          dd          D ]<}|                    |
                    i                                                      =t          |                                          }|                     t          |          d           |                                 t          |                                          }|                     t          |          d           dS )z
        If a the L{H2Connection} has been paused by the transport, it will
        not write automatic frame data triggered by writes.
        r   d   r,   e   N)r   r   r  r   r   r+   r   r   r   r   rI   r   r   r  r  ry   r   )r"   r   r   r   r+   r   r   s          r#    test_bufferingAutomaticFrameDataz1HTTP2ServerTests.test_bufferingAutomaticFrameData  sD    "^^
$9
!#~~#%%	"."F"F"H"H!!),,, 7888 	!!### q# 	U 	UA##L$C$CB$G$G$Q$Q$S$STTTT !2!233Va((( 	""$$$ !2!233Vc*****r&   c                    t                      }t          |_        t                      }t	                      }|                                }|                    |           |                    |           |                                 d|_	        | 
                    |j                   t          dd          D ]<}|                    |                    i                                                      =| 
                    |j                   |                    |                    i                                                      |                     |j                   dS )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.
        r  r      N)r   r   r  r   r   r+   r   r   r   r  r^  rT  r   rI   r   r  r  )r"   r   r   r   r+   r   s         r#   2test_bufferingAutomaticFrameDataWithCircuitBreakerzCHTTP2ServerTests.test_bufferingAutomaticFrameDataWithCircuitBreaker6  sG    "^^
$9
!#~~#%%	"."F"F"H"H!!),,, 7888 	!!### 47
0 	0111q" 	U 	UA##L$C$CB$G$G$Q$Q$S$STTTT0111 	 ? ? C C M M O OPPP	./////r&   c                 h    G d dt                     }t                      }t          |_        t	                      } |            }|                    |d           |                                }|                    |           |                    |           | 	                    |j
                   t          |                                          }|                     t          |          d           |                     |j        d           t!          dd          D ]<}|                    |                    i                                                      =t          |                                          }|                     t          |          d           |                     |j        d           |                                 t          |                                          }|                     t          |          d           |                     |j        d	           d
S )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                       e Zd Zd ZdS )eHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWrite.<locals>.AutoPausingStringTransportc                 b    t          j        | g|R i | | j                                         d S r   )r   r   producerr   r   s      r#   r   zkHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWrite.<locals>.AutoPausingStringTransport.write_  s=    %d<T<<<V<<<,,.....r&   N)ri   rj   rk   r   r*   r&   r#   AutoPausingStringTransportr!  ^  s#        / / / / /r&   r$  Tr,   r   r  c   r
  Z   N)r   r   r   r  r   r   r+   r   r   assertIsNotNone_consumerBlockedr   r  r  ry   _bufferedControlFrameBytesr   rI   r   r   )r"   r$  r   r   r   r+   r   r   s           r#   0test_bufferingContinuesIfProducerIsPausedOnWritezAHTTP2ServerTests.test_bufferingContinuesIfProducerIsPausedOnWriteX  s
   	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ "^^
$9
!#~~..00	"":t444"."F"F"H"H!!),,, 7888 	Z8999 !2!233Va(((>BBB q" 	U 	UA##L$C$CB$G$G$Q$Q$S$STTTT !2!233Va(((>GGG 	""$$$ !2!233Va(((>GGGGGr&   c                    t                      }t          |          }|j        |_        t                      }t	                      }|                                }|                    |           |                    |           |                                 d|_	        |
                    dd                                          }|                    |           |                     |j                   dS )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.
        r   r  r  r  N)r
   r   r  r   r   r+   r   r   r   r  rC   r   r  r  )r"   r  r   r   r   r+   r  s          r#   +test_circuitBreakerAbortsAfterProtocolErrorz<HTTP2ServerTests.test_circuitBreakerAbortsAfterProtocolError  s     +,,!-00
,6
#~~#%%	 #/"F"F"H"H!!),,, 7888 	!!###34
0 #11ut1LLVVXX 	,,,	./////r&   N)+ri   rj   rk   r  r#  r$  r  r  r!  r"  r  r  r%  r-  rB  rR  rU  r`  rg  rr  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r  r*  r,  r*   r&   r#   r   r     s            DCCO   *O   B' ' ':K K K8K K K8)K )K )KV>
 >
 >
@E
 E
 E
N%) %) %)N+K +K +KZ,5 ,5 ,5\35 35 35j25 25 25hK K K8%5 %5 %5N+K +K +KZN N N K  K  KD
0 
0 
0S S S,8 8 8>@B @B @BD7 7 7. 9  9  9D9 9 9.  B*. *. *.X(. (. (.T'. '. '.R% % %N(0 (0 (0T+ + +> 0  0  0D+H +H +HZ0 0 0 0 0r&   r   c                       e Zd ZdZg dZdZg dZg dZdZd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )H2FlowControlTestszT
    Tests that ensure that we handle HTTP/2 flow control limits appropriately.
    )r   r   r   r   r   r   r   r   r   c                    	 t                      }t                      	t                      }t          |_        |                                }||                    t          j        j	        j
        di                                          z  }|t           j        g |          z  }|                    	           t          |          D ]}|                    |           t#           j                  dz
  }t'          |          D ]@}|                    dd          }|                    |                                           A	 fd}|j        d                             |          S )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.
        rE  r,   r  c                    t                                                    }                    d|d         j        v            d                    d |D                       }                    j        |           d S )Nr   r   r&   c              3   b   K   | ]*}t          |t          j        j                  !|j        V  +d S r   r  r   s     r#   r   zMH2FlowControlTests.test_bufferExcessData.<locals>.validate.<locals>.<genexpr>  M       * **Q
8H8R*S*S** * * * * *r&   )r   r  r  r4   r   r  r  r9   r   actualResponseDatar8  r"   s      r#   r  z:H2FlowControlTests.test_bufferExcessData.<locals>.validate  s    $QWWYY//F OOLF2J,<<=== "% * * &* * * " " T13EFFFFFr&   )r   r   r   r   r  r+   rI   r  rG   r  r  r   r   r  r   r   r   ry   r  r   rN   r  r  )
r"   r;   rA  r   r   bonusFramesr   r0   r  r8  s
   `        @r#   test_bufferExcessDataz(H2FlowControlTests.test_bufferExcessData  sv    NNNN0 0022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4    
 $.//!3{## 	. 	.A,,a1,EEENN5??,,----
	G 
	G 
	G 
	G 
	G 
	G (+77AAAr&   c                     t                      }t                      t                      }t          |_        |                                }||                    t          j        j	        j
        di                                          z  }|t           j        g |          z  }|                               t          |          D ]}|                    |           |j        d         }|j        j        }                     |j                   |                    d                                |j                                        |j        j        dg           |                    |                    dd                                                                          |j                                        |j        j        dg           |                    |                    dd                                                                          |j                                        |j        j        dg           |                    |                    dd                                                                          |j                                        |j        j        ddg           |                    d                                |j                                        |j        j        g d           |                    |                    dd	                                                                          |j                                        |j        j        g d
           |                                 |                                  fd}|j        d                             |          S )z
        L{Request} objects that have registered producers get blocked and
        unblocked according to HTTP/2 flow control.
        rE  r,   
   helloworldpauser  r   resume)r9  r:  r9  r  )r9  r:  r9  r:  c                     t                                                    }                    d|d         j        v            d |D             }                    |g d           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zXH2FlowControlTests.test_producerBlockingUnblocking.<locals>.validate.<locals>.<listcomp>:  r  r&   )r8  r8  r&   r  r9   r   r  r8  r"   s      r#   r  zDH2FlowControlTests.test_producerBlockingUnblocking.<locals>.validate3  s{    $QWWYY//F OOLF2J,<<===  &  J Z)L)L)LMMMMMr&   ) r   r   r   ro  r  r+   rI   r  rG   r  r  r   r   r  r   r   r   r[  r\  r]  r  _producerProducingr   r^  r  r#  eventsrN   unregisterProducerr   r  r  	r"   r;   rA  r   r   r  r_  r  r8  s	   `       @r#   test_producerBlockingUnblockingz2H2FlowControlTests.test_producerBlockingUnblocking  s   
 NNNN4 0022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4     1/* 	1222 	m$$$ 	2333)07)<<< 	
q//a/HHRRTTUUU2333)07)<<< 	
q//a/HHRRTTUUU2333)07)<<< 	
q//a/HHRRTTUUU1222)07H2EFFF
 	m$$$2333)02N2N2NOOO 	
q//b/IISSUUVVV1222#%K%K%K	
 	
 	
 	""$$$
	N 
	N 
	N 
	N 
	N 
	N (+77AAAr&   c                    	
 t                      	t                      t                      t          _        	                                }|	                    t          j        j	        j
        di                                          z  }|t           j        g 	          z  }                               t          |          D ]}                    |           j        d         j        j        
                     j                   
                    d                                j                                        
j        j        dg           
                    d           	
 fd}t7          j        t:          d|          } fd}j        d                             |          }tA          j!        ||g          S )	zQ
        Exactly filling the flow control window still blocks producers.
        rE  r,   r8  r9     hc                  H                                             dd                                                                         j                                       j        j        ddg                                            	                                 d S )Nr,   r  r  r9  r:  )
r   rN   r   r  r>  r  r#  r?  r@  r   )rA  r;   r_  r"   r  s   r#   window_openz=H2FlowControlTests.test_flowControlExact.<locals>.window_openh  s    NN((!r(BBLLNN   OOF5666W-4w6IJJJ&&(((NNr&   r   c                     t                                                    }                    d|d         j        v            d |D             }                    |g d           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zNH2FlowControlTests.test_flowControlExact.<locals>.validate.<locals>.<listcomp>{  r  r&   )r  r  rD  r&   r  r=  s      r#   r  z:H2FlowControlTests.test_flowControlExact.<locals>.validatet  s{    $QWWYY//F OOLF2J,<<===  &  J Z)H)H)HIIIIIr&   )"r   r   r   ro  r  r+   rI   r  rG   r  r  r   r   r  r   r   r   r[  r\  r]  r  r>  r   r^  r  r#  r?  r   r  r   r  r  r   r>  )r"   r   r   rF  windowDeferr  validateDeferrA  r8  r;   r_  r  s   `      @@@@@r#   test_flowControlExactz(H2FlowControlTests.test_flowControlExactA  s    NNNN4 0022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4     1/* 	1222 	m$$$2333)07)<<< 	d	 	 	 	 	 	 	 	 	 ogq+>>
	J 
	J 
	J 
	J 
	J 
	J 1!4@@JJ!;">???r&   c                     t                      }t                      t                      }t          |_        |                                }||                    t          j        j	        j
        di                                          z  }|t           j        g |          z  }|                               t          |          D ]}|                    |           |j        d         }|j        j        }                     |j                   |                    d           |                                 |                                                      |j                   t5          j        d|j        |                    dd                                                      fd}|j        d                             |          S )z
        L{Request} objects that end a stream that is currently blocked behind
        flow control can still end the stream and get cleaned up.
        rE  r,   r8  r   r  r  c                     t                                                    }                    d|d         j        v            d |D             }                    |g d           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zQH2FlowControlTests.test_endingBlockedStream.<locals>.validate.<locals>.<listcomp>  r  r&   )r  r  r&   r  r=  s      r#   r  z=H2FlowControlTests.test_endingBlockedStream.<locals>.validate  s{    $QWWYY//F OOLF2J,<<===  &  J Z)B)B)BCCCCCr&   )r   r   r   ro  r  r+   rI   r  rG   r  r  r   r   r  r   r   r   r[  r\  r]  r  r>  r   r@  r   finishedr   r  rN   r  r  rA  s	   `       @r#   test_endingBlockedStreamz+H2FlowControlTests.test_endingBlockedStream  s   
 NNNN4 0022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4     1/* 	1222 	m$$$""$$$ 	())) 	N$$a2$>>HHJJ	
 	
 	

	D 
	D 
	D 
	D 
	D 
	D (+77AAAr&   c                 J   	 t                      }t                      	t                      }t          |_        |                                }|t           j        g |          z  }|                    	           t          |          D ]}|
                    |           |j        d         }|j        j        }|j        d         }|                                 |                                                      |j                   	 fd}|                    |          S )z<
        We safely handle responses without bodies.
        r,   c                    t                                                    }                    t          |          d                               d|d         j        v            d |D             }                    |dg           d S )Nr  r   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zQH2FlowControlTests.test_responseWithoutBody.<locals>.validate.<locals>.<listcomp>  r  r&   r&   rY  r=  s      r#   r  z=H2FlowControlTests.test_responseWithoutBody.<locals>.validate      $QWWYY//FS[[!,,, OOLF2J,<<===  &  J     r&   )r   r   r   ro  r  r+   r   r  r   r   r   r[  r\  r]  r  r@  r   r  rO  r  
r"   r;   rA  r   r   r  r_  rf  r  r8  s
   `        @r#   test_responseWithoutBodyz+H2FlowControlTests.test_responseWithoutBody  s-    NNNN 5 0022)$*@"aHHH	l++ 	! 	!DNN4     1/*3A6 	""$$$ 	()))	 	 	 	 	 	" **8444r&   c                    	 t                      }t                      	t                      }t          |_        |                                }|t           j        g |          z  }|                    	           t          |          D ]}|
                    |           |j        d         }|j        j        }|j        d         }|                                 |                                                      |j                   |
                    |                    dd                                                     	 fd}|                    |          S )zk
        WindowUpdate frames received after we've completed the stream are
        safely handled.
        r,   r  r  c                    t                                                    }                    t          |          d                               d|d         j        v            d |D             }                    |dg           d S )Nr  r   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  z[H2FlowControlTests.test_windowUpdateForCompleteStream.<locals>.validate.<locals>.<listcomp>"  r  r&   r&   rY  r=  s      r#   r  zGH2FlowControlTests.test_windowUpdateForCompleteStream.<locals>.validate  rT  r&   )r   r   r   ro  r  r+   r   r  r   r   r   r[  r\  r]  r  r@  r   r  rO  rN   r   r  rU  s
   `        @r#   "test_windowUpdateForCompleteStreamz5H2FlowControlTests.test_windowUpdateForCompleteStream  s`    NNNN 5 0022)$*@"aHHH	l++ 	! 	!DNN4     1/*3A6 	""$$$ 	())) 	
q//b/IISSUUVVV	 	 	 	 	 	" **8444r&   c                 P    t                      }t                      t                      }t          |_        |                                }||                    t          j        j	        j
        di                                          z  }|t           j        g |          z  }|                               t          |          D ]}|                    |           |j        d         }|j        j        }                     |j                   |                    d                                |j                                        |j        j        g            |                    |                    dd                                                                          |j                                        |j        j        g            |                                 |                                  fd}|j        d                             |          S )z
        L{Request} objects that have registered producers that are not blocked
        behind flow control do not have their producer notified.
        rE  r,      wordr  c                     t                                                    }                    d|d         j        v            d |D             }                    |ddg           d S )Nr   r   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   r  r   s     r#   r*  zOH2FlowControlTests.test_producerUnblocked.<locals>.validate.<locals>.<listcomp>a  r  r&   r\  r&   r  r=  s      r#   r  z;H2FlowControlTests.test_producerUnblocked.<locals>.validateZ  sx    $QWWYY//F OOLF2J,<<===  &  J Z'388888r&   )r   r   r   ro  r  r+   rI   r  rG   r  r  r   r   r  r   r   r   r[  r\  r]  r  r>  r   r  r#  r?  rN   r@  r   r  r  rA  s	   `       @r#   test_producerUnblockedz)H2FlowControlTests.test_producerUnblocked,  s   
 NNNN4 0022,,[%91=
 

)++	 	)$*@"aHHH	l++ 	! 	!DNN4     1/* 	1222 	g 	1222)0"555 	
q//a/HHRRTTUUU1222)0"555 	""$$$
	9 
	9 
	9 
	9 
	9 
	9 (+77AAAr&   c                 .    t                      }t                      t                      }t          |_        t           j         j        |          }|                    d|	                    dd                     |
                                }|d                    d |D                       z  }|                               t          |          D ]}|                    |            fd}|j        d                             |          S )z
        When a WindowUpdate frame is received for the whole connection but no
        data is currently waiting, nothing exciting happens.
        r,   r   rE  r  r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zBH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.<genexpr>v  rc  r&   c                    t                                                    }                    d|d         j        v            d                    d |D                       }                    j        |           d S )Nr   r   r&   c              3   b   K   | ]*}t          |t          j        j                  !|j        V  +d S r   r  r   s     r#   r   zTH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.validate.<locals>.<genexpr>  r2  r&   )r   r  r  r4   r   r  r"  r3  s      r#   r  zAH2FlowControlTests.test_unnecessaryWindowUpdate.<locals>.validate}  s    $QWWYY//F OOLF2J,<<=== "% * * &* * * " " T24FGGGGGr&   )r   r   r   r   r  r   r#  r$  rP  rN   r+   r   r   r   r   r  r  )r"   r;   rA  r   r   r   r  r8  s   `      @r#   test_unnecessaryWindowUpdatez/H2FlowControlTests.test_unnecessaryWindowUpdateh  s$   
 NNNN0 $D$;T=QSTUUa1111JJKKK0022 ? ? ? ? ????	l++ 	! 	!DNN4    
	H 
	H 
	H 
	H 
	H 
	H (+77AAAr&   c                    t                      }t                      }t                      }t          |_        g }|                    |                    | j        d                     |                    |                    dd                     |	                                }|d
                    d |D                       z  }|                    |           |                    |           |                     |           dS )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   rE  r  r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zKH2FlowControlTests.test_unnecessaryWindowUpdateForStream.<locals>.<genexpr>  s*      771777777r&   N)r   r   r   r   r  r   r?   r#  rN   r+   r   r   r   r   )r"   r;   r   connr   r3   s         r#   %test_unnecessaryWindowUpdateForStreamz8H2FlowControlTests.test_unnecessaryWindowUpdateForStream  s     NN#%%	~~3
 a))$2ITU)VVWWWa..Q.GGHHH((**77777777I&&&$$$T*****r&   c                    t                      }t                      }t                      }t          |_        t          | j        | j        |          }|                                }|d	                    d |D                       z  }|
                    |           t          |          D ]}|                    |           |j        d                                          |                    dd          }|                    |                                           t#          |                                          }|                     t)          |d         t*          j        j                             dS )zq
        When a WindowUpdate frame is received for a stream that has been
        aborted it is ignored.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zEH2FlowControlTests.test_windowUpdateAfterTerminate.<locals>.<genexpr>  rc  r&   r,   rE  r  r   N)r   r   r   r   r  r   r#  r$  r+   r   r   r   r   r[  r  rN   r   r   r  r  r   r/   r0   rY   )r"   r;   r8  rA  r   r   r   windowUpdateFrames           r#   test_windowUpdateAfterTerminatez2H2FlowControlTests.test_windowUpdateAfterTerminate  sR   
 NNNN0 $D$;T=QSTUU0022 ? ? ? ? ????	l++ 	! 	!DNN4     	
	!$$&&& 44a14MM	(2244555 !++ 	
6":z/?/NOOPPPPPr&   c                    	 t                      	t                      t                      t          _        t           j         j        	          }	                                }|d	                    d |D                       z  }
                               t          |          D ]}                    |           	fd} fd}j        d                             |          }|                    |          S )zs
        When a WindowUpdate frame is received for a stream that has been
        completed it is ignored.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zDH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.<genexpr>  rc  r&   c                                           dd          }                    |                                           d S )Nr,   rE  r  )rN   r   r   )r   rk  rA  r;   s     r#   update_windowzHH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.update_window  sA     ! 8 8!q 8 Q QNN,668899999r&   c                      t                                                    }                    d|d         j                   d S )Nr   r   )r   r  assertInr4   r   r   r8  r"   s     r#   r  zCH2FlowControlTests.test_windowUpdateAfterComplete.<locals>.validate  s;    $QWWYY//F MM,r
(899999r&   r,   )r   r   r   r   r  r   r#  r$  r+   r   r   r   r   r  r  )
r"   r   r   r   rp  r  r  rA  r8  r;   s
   `      @@@r#   test_windowUpdateAfterCompletez1H2FlowControlTests.test_windowUpdateAfterComplete  s(   
 NNNN0 $D$;T=QSTUU0022 ? ? ? ? ????	l++ 	! 	!DNN4    	: 	: 	: 	: 	: 	:
	: 	: 	: 	: 	: 	: %a(44]CC}}X&&&r&   c                 T   t                      }t                      }t                      }t          |_        ddz  gdz  }t          d |D                        }| j        dd         d|fgz   }t          |||          }|d= |                    |	                    d	t          j        j        j        
                     |                                }|d                    d |D                       z  }|                    |           |                    |           t%          |                                          }d |D             }	|                     dg|	           d |D             }
d |D             }|                     |
           |                     |           dS )z
        When a DATA frame is received at the same time as RST_STREAM,
        Twisted does not send WINDOW_UPDATE frames for the stream.
            i @  r  c              3   4   K   | ]}t          |          V  d S r   )ry   )r   r3   s     r#   r   z;H2FlowControlTests.test_dataAndRstStream.<locals>.<genexpr>  s(      <<$CII<<<<<<r&   Nr   zcontent-lengthr  r,   )r9   rU   r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   z;H2FlowControlTests.test_dataAndRstStream.<locals>.<genexpr>	  rc  r&   c                 Z    g | ](}t          |t          j        j                  !|j        )S r*   )r   r/   r0   rK   r  r   s     r#   r*  z<H2FlowControlTests.test_dataAndRstStream.<locals>.<listcomp>	  s@      
  
  
!Z-?@@ 
K 
  
  
r&   r   c                 P    g | ]#}t          |t          j        j                  !|$S r*   )r   r/   r0   r1   r   s     r#   r*  z<H2FlowControlTests.test_dataAndRstStream.<locals>.<listcomp>	  s=     
 
 
Az/?/L!M!M

 
 
r&   c                 P    g | ]#}t          |t          j        j                  !|$S r*   )r   r/   r0   rB   r   s     r#   r*  z<H2FlowControlTests.test_dataAndRstStream.<locals>.<listcomp>	  s-    UUUA:a9I9S+T+TUaUUUr&   )r   r   r   r   r  sumr#  r   r   rZ   r  errors
ErrorCodesINTERNAL_ERRORr+   r   r   r   r   r  r  r^  )r"   r   r   rA  	frameData
bodyLengthr8   r   r   windowUpdateFrameIDsheadersFrames
dataFramess               r#   test_dataAndRstStreamz(H2FlowControlTests.test_dataAndRstStream  s   
 $~~#%%	NN0
 &'!+	<<)<<<<<>
)#2#.3CZ2P1QQ#),
 
 
 2J,,bi&:&I -  	
 	
 	
 $;;== ? ? ? ? ????	### 	
|$$$ !!2!233 
  
 
  
  

 	!2333
 

 
 
 VUUUU
'''$$$$$r&   c                    t                      }t          |          }|j        |_        t          |_        t                      }t                      }|                                }|                    |           |	                    |           d}|
                    | j        |                                          }|	                    |           |                                 d|_        |                                 |                    |           |                     |                                           |                     |j                   dS )z
        Aborting a request associated with a paused connection that's
        reached its buffered control frame limit causes that
        connection to be aborted.
        r,   r   r   N)r
   r   r  r   r  r   r   r+   r   r   r?   r#  r   r   r  clearabortRequestr^  r  r  r  )r"   r  r   r   r   r+   r9   headersFrameDatas           r#   #test_abortRequestWithCircuitBreakerz6H2FlowControlTests.test_abortRequestWithCircuitBreaker	  sM    +,,!-00
,6
$9
!#~~#%%	 #/"F"F"H"H!!),,, 7888 '99+h : 
 

)++ 	 	 0111 	!!###34
0 	 	))) 	**+++ 		./////r&   N)ri   rj   rk   rl   r  r  r#  r$  r"  r6  rB  rK  rP  rV  rZ  r_  rd  rh  rl  rt  r  r  r*   r&   r#   r.  r.    sF           *O   DCCOA+B +B +BZQB QB QBf@@ @@ @@D8B 8B 8Bt25 25 25h95 95 95v:B :B :Bx!B !B !BF+ + +2Q Q Q@ '  '  'D5% 5% 5%n)0 )0 )0 )0 )0r&   r.  c                   .    e Zd Zg dZd Zd Zd Zd ZdS )HTTP2TransportCheckingr   c                     t                      }t                      }t          |_        |                    |d           |                     |j        |u            dS )zU
        L{H2Connection} can be registered with the transport as a producer.
        TN)r   r   r   r  r   r  r#  )r"   r8  rA  s      r#   "test_registerProducerWithTransportz9HTTP2TransportChecking.test_registerProducerWithTransportT	  sT     NN0	1d###
a(((((r&   c                 t   	
 t                      }t                      	t                      t          _        t           j        g |          }|                                }|d                    d |D                       z  }	                    	           	
                    d           t          |          D ]}                    |                                            j        d         
	
 fd}	 fd}t          j        t"          d|          }|                    |           |S )z|
        L{H2Connection} can be paused by its consumer. When paused it stops
        sending data to the transport.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zNHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.<genexpr>l	  rc  r&   Tr,   c                     t                                                    }                    t          |          d                               t          |d         t          j        j                             	                                 	                                 	                                 	                                 	                                 S )Nr
  r   )
r   r  r  ry   r^  r   r/   r0   rB   r   )r   r   rA  r8  rf  r"   s     r#   validateNotSentzTHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.validateNotSent	  s    $QWWYY//FS[[!,,,Zr
J4D4NOOPPP ""r&   c                      t                                                    }                    t          |          d                               d|d         j        v            d S rX  rY  rs  s     r#   r  zUHTTP2TransportChecking.test_pausingProducerPreventsDataSend.<locals>.validateComplete	  sZ    $QWWYY//F S[[!,,,OOLF2J,<<=====r&   r  )r   r   r   r   r  r   r  r+   r   r   r   r   r   r   r  r   r  r   r  )r"   r;   r   r   r   r  r  r  rA  r8  rf  s   `       @@@r#   $test_pausingProducerPreventsDataSendz;HTTP2TransportChecking.test_pausingProducerPreventsDataSend_	  sg   
 NNNN0 $D$:BBB0022 ? ? ? ? ????		1d### l++ 	! 	!DNN4    
 	
 3A6	# 	# 	# 	# 	# 	# 	# 	#	> 	> 	> 	> 	> 	> OGT?;;	&'''r&   c                    t                      }t                      }t                      }t          |_        t          | j        g |          }|                                }|d                    d |D                       z  }|	                    |           |
                    |d           t          |          D ]}|                    |           |                                 t          |                                          }|                     t#          |          d           |                     t'          |d         t(          j        j                             |                     |j                   dS )zo
        L{H2Connection} can be stopped by its producer. That causes it to lose
        its transport.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   z<HTTP2TransportChecking.test_stopProducing.<locals>.<genexpr>	  rc  r&   Tr
  r   N)r   r   r   r   r  r   r  r+   r   r   r   r   r   r   r   r  r  ry   r^  r   r/   r0   rB   rv  )r"   r;   r8  rA  r   r   r   s          r#   test_stopProducingz)HTTP2TransportChecking.test_stopProducing	  sU   
 NNNN0 $D$:BBB0022 ? ? ? ? ????		1d### l++ 	! 	!DNN4     	
 ++Va(((F2J
0@0JKKLLL*+++++r&   c                    	
 t          ddd          	t          ddd          
t                      }t          	
          }t                      }t          |_        |                    |           t           j        g |          }|	                                }|d
                    d |D                       z  }t          |          D ]}|                    |           |j        d	                                                              	                                                                
           |j        d	         }	
 fd
}|                    |          S )z{
        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   >   K   | ]}|                                 V  d S r   r   r2  s     r#   r   zEHTTP2TransportChecking.test_passthroughHostAndPeer.<locals>.<genexpr>	  r3  r&   r,   c                                                                                                                                                      d S r   )r  getHostgetPeer)r   r  r  r"   r  s    r#   r  zDHTTP2TransportChecking.test_passthroughHostAndPeer.<locals>.validate	  sI    V^^--{;;;V^^--{;;;;;r&   )r	   r   r   r   r   r  r   r   r  r+   r   r   r   r[  r  r  r  r  r  )r"   r   r   r   r   r   r   rf  r  r  r  r  s   `        @@@r#   test_passthroughHostAndPeerz2HTTP2TransportChecking.test_passthroughHostAndPeer	  s~   
 "%s;;!%>>#~~#UUU	!^^
$9
!!!),,,#D$:BMM#;;== G G G G GGGGl++ 	* 	*D##D)))) #A&));777));777 %<Q?	< 	< 	< 	< 	< 	< 	< 	< **8444r&   N)ri   rj   rk   r  r  r  r  r  r*   r&   r#   r  r  I	  sc          	) 	) 	)< < <|, , ,>!5 !5 !5 !5 !5r&   r  c                       e Zd ZdZd ZdS )HTTP2SchedulingTestsz
    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                    t          j                    }t          |          } |j                    }|                     t          |          d           |d         }|                     |                                           |                     |j        d           |                     |j	        |j
                   |                     |j        d           |                     |j        i            dS )z}
        When a H2Connection is established it schedules one call to be run as
        soon as the reactor has time.
        r,   r   r*   N)r   Clockr   getDelayedCallsr  ry   r  activetimefunc_sendPrioritisedDatar   kw)r"   r   rA  callscalls        r#   "test_initiallySchedulesOneDataCallz7HTTP2SchedulingTests.test_initiallySchedulesOneDataCall	  s    
 *,,!!''))UQ'''Qx 	&&&A&&&A$:;;;B'''"%%%%%r&   N)ri   rj   rk   rl   r  r*   r&   r#   r  r  	  s-         & & & & &r&   r  c                       e Zd ZdZg dZ e            Zd Zd Zd Z	efdZ
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )HTTP2TimeoutTestsz@
    The L{H2Connection} object times out idle connections.
    r   c                     |j         |_         dS )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_clockz*HTTP2TimeoutTests.patch_TimeoutMixin_clock
  s      '0
r&   c                 F   t          j                    }t          |          }d|_        |                     ||           t                      }t          |          |_        |                    |           t          |          D ]}|
                    |           |||fS )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  r   timeOutr  r   r   r  r   r   r   )r"   initialDatar  r   rg  r   r   s          r#   initiateH2Connectionz&HTTP2TimeoutTests.initiateH2Connection
  s     *,,G$$%%dG444#%%	6~FFI&&& k** 	$ 	$Dd####y))r&   c                 ^   t          |          }|                     t          |          |           |                     t	          |d         t
          j        j                             |                     |d         j        |           |                     |d         j	        |           dS )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.
        r   N)
r   r  ry   r  r   r/   r0   rP   rQ   rR   )r"   r3   
frameCountrU   rT   r   s         r#   assertTimedOutz HTTP2TimeoutTests.assertTimedOut9
  s     !&&Vj111
6":z/?/KLLMMM.	:::2LAAAAAr&   c                    || j         u rt          j        }t                      }|                                }|                     |t                    \  }}}||_         |j        d           |                     |	                                dt          j        j        j        d           |                     |j                   |                     |j                   |||fS )a  
        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   r  rU   rT   )_DEFAULTr   abortTimeoutr   r+   r  r   advancer  r  r  r}  r~  NO_ERRORr  rT  r^  r  )r"   r  r   r  r   rg  r   s          r#   prepareAbortTestz"HTTP2TimeoutTests.prepareAbortTestF
  s     4=(('4L#~~"::<<#'#<#<+ $= $
 $
 y ) 	OOi*3	 	 	
 	
 	
 		/000/000i''r&   c                 (   t                      }|                                }|                     |t                    \  }}}|                                } |j        d           |                     ||                                           |                     |j                    |j        d           | 	                    |                                dt          j        j        j        d           |                     |j                   dS )z
        When a L{H2Connection} does not receive any data for more than the
        time out interval, it closes the connection cleanly.
        r  r%  r
  r   r  N)r   r+   r  r   r  r  r  r^  rT  r  r  r}  r~  r  r  )r"   r   r  r   rg  r   preambles          r#   test_timeoutAfterInactivityz-HTTP2TimeoutTests.test_timeoutAfterInactivityl
  s   
 $~~"::<<#'#<#<+ $= $
 $
 y ??$$ 	 	9??#4#45550111 	OOi*3	 	 	
 	
 	
 		/00000r&   c                    t                      }d}|                     |t                    \  }}}t          |                                          D ]A}|                    |            |j        d           |                     |j                   B |j        d           | 	                    |
                                dt          j        j        j        d           |                     |j                   dS )zM
        When a L{H2Connection} receives data, the timeout is reset.
        r&   r  r%  r
  r   r  N)r   r  r   r   r+   r   r  r^  rT  r  r  r  r}  r~  r  r  )r"   r   r  r   rg  r   r   s          r#   test_timeoutResetByRequestDataz0HTTP2TimeoutTests.test_timeoutResetByRequestData
  s   
 $~~#'#<#<+ $= $
 $
 y lBBDDEE 	6 	6Dd### GOB Y45555 	OOi*3	 	 	
 	
 	
 		/00000r&   c                   	 t                      }d}g 	t          | j        g |          }|                                }|d                    d |D                       z  }	fd}|                     ||          \  }}}|                    |                                            |j        d           |                     t          	          d           t          d          D ]G}	d                             d	            |j        d           |                     |j                   H |j        d
           |                     |                                dt           j        j        j        d           dS )zJ
        When a L{H2Connection} sends data, the timeout is reset.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zDHTTP2TimeoutTests.test_timeoutResetByResponseData.<locals>.<genexpr>
  *      >>!>>>>>>r&   c                 T    t          | |          }                    |           |S )N)queued)r   r   )r  r  r   requestss      r#   saveRequestzFHTTP2TimeoutTests.test_timeoutResetByResponseData.<locals>.saveRequest
  s,    $VF;;;COOC   Jr&   r  r%  r,   
   r   s
   some bytesr
     r  N)r   r   r  r+   r   r  r   r  assertEqualsry   r   r   r^  rT  r  r  r  r}  r~  PROTOCOL_ERROR)
r"   r   r  r   r  r   rg  r   r(  r  s
            @r#   test_timeoutResetByResponseDataz1HTTP2TimeoutTests.test_timeoutResetByResponseData
  s   
 $~~#D$:BMM"::<<sxx>>v>>>>>>	 	 	 	 	
 $(#<#<& $= $
 $
 y
 	,>>@@AAA 	#h--+++r 	6 	6AQKm,,,GOBY45555 	OOi*9	 	 	
 	
 	
 	
 	
r&   c                    t                      }t          | j        g |          }|                                }|d                    d |D                       z  }|                     |t                    \  }}} |j        d           |                     |	                                dt          j        j        j        d           |                     |j                   dS )	z
        When a L{H2Connection} times out with active streams, the error code
        returned is L{h2.errors.ErrorCodes.PROTOCOL_ERROR}.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zOHTTP2TimeoutTests.test_timeoutWithProtocolErrorIfStreamsOpen.<locals>.<genexpr>
  r  r&   r  r  r
  r,   r  N)r   r   r  r+   r   r  r   r  r  r  r  r}  r~  r  r  rT  )r"   r   r   r  r   rg  r   s          r#   *test_timeoutWithProtocolErrorIfStreamsOpenz<HTTP2TimeoutTests.test_timeoutWithProtocolErrorIfStreamsOpen
  s    
 $~~#D$:BMM"::<<sxx>>v>>>>>>#'#<#</ $= $
 $
 y 	OOi*9	 	 	
 	
 	
 		/00000r&   c                 ^   t                      }t          | j        g |          }|                                }|d                    d |D                       z  }|                     |t                    \  }}}|                                }t           |j	                              }|
                    d           t           |j	                              }	|                     |dz
  |	            |j        d           |                     |                                |           dS )zU
        When a L{H2Connection} loses its connection it cancels its timeout.
        r&   c              3   >   K   | ]}|                                 V  d S r   r   r   s     r#   r   zCHTTP2TimeoutTests.test_noTimeoutIfConnectionLost.<locals>.<genexpr>
  r  r&   r  r  r,   r  N)r   r   r  r+   r   r  r   r  ry   r  connectionLostr  r  )
r"   r   r   r  r   rg  r   sentDataoldCallCountcurrentCallCounts
             r#   test_noTimeoutIfConnectionLostz0HTTP2TimeoutTests.test_noTimeoutIfConnectionLost
  s0    $~~#D$:BMM"::<<sxx>>v>>>>>>#'#<#</ $= $
 $
 y
 ??$$2724455 	H%%% 6w68899)+;<<< 	**H55555r&   c                 F   |                                  \  }}} |j        d           |                     |j                   |                     |j                    |j        d           |                     |j                   |                     |j                   dS )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.
           r,   Nr  r  r  rT  r^  r  r"   r   rg  r   s       r#   ,test_timeoutEventuallyForcesConnectionClosedz>HTTP2TimeoutTests.test_timeoutEventuallyForcesConnectionClosed  s    
 $(#8#8#:#: y 		/000/000	/000	./////r&   c                    |                                  \  }}} |j        d           |                    d            |j        d           |                     |j                   |                     |j                   dS )z
        When a L{H2Connection} has timed the connection out, getting
        C{connectionLost} called on it cancels the forcible connection close.
        r  Nr,   )r  r  r  r  rT  r^  r  r  s       r#   $test_losingConnectionCancelsTheAbortz6HTTP2TimeoutTests.test_losingConnectionCancelsTheAbort!  s    
 $(#8#8#:#: y 	D!!! 		/000/00000r&   c                     |                      d          \  }}} |j        d           |                     |j                   |                     |j                   dS )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)r  l        r  r  s       r#   'test_losingConnectionWithNoAbortTimeOutz9HTTP2TimeoutTests.test_losingConnectionWithNoAbortTimeOut1  sg    
 $(#8#8d#8#K#K y 		/000/00000r&   c                     |                                  \  }}} |j        d           |                     |j                   |                     |j                   |                    t          j                   dS )z}
        If a timed out transport doesn't close after 15 seconds, the
        L{HTTPChannel} will forcibly close it.
           N)r  r  r  rT  r  r  r   ConnectionDoner  s       r#   "test_connectionLostAfterForceClosez4HTTP2TimeoutTests.test_connectionLostAfterForceClose>  sy    
 $(#8#8#:#: y 		/000	.///
 	E011111r&   c                 *   t                      }t          |          }|j        |_        d|_        t	                      }t                      }|                                }|                    |           |                    |           t          |j        |j
        z             D ]Q}|                    |                    d                                                     |                    d           R|                     |j                   dS )zR
        A client that sends only invalid frames is eventually timed out.
        <   r,   N)r
   r   r  r  r   r   r+   r   r   r   r  rZ   r   r  r  r  )r"   r  r   r   r   r+   r   s          r#   ,test_timeOutClientThatSendsOnlyInvalidFramesz>HTTP2TimeoutTests.test_timeOutClientThatSendsOnlyInvalidFramesO  s    +,,!-00
,6

#~~#%%	"."F"F"H"H!!),,, 7888 z)J,CCDD 	% 	%A##L$D$DQ$G$G$Q$Q$S$STTT!!!$$$$ 		./////r&   N)ri   rj   rk   rl   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r*   r&   r#   r  r  	  s            vxxH1 1 1* * *8B B B -5 $( $( $( $(L 1  1  1D 1  1  1D*
 *
 *
X1 1 146 6 680 0 01 1 1 1 1 12 2 2"0 0 0 0 0r&   r  rh   )Drl   r:  zope.interfacer   r   twisted.internetr   r   r   r   twisted.internet.addressr	   twisted.internet.testingr
   r   twisted.pythonr   twisted.python.compatr   twisted.test.test_internetr   twisted.trialr   twisted.webr   twisted.web.test.test_httpr   r   r   r   r   r   r   r   r  	h2.errorsh2.exceptionsr/   r   hpack.hpackr   r   twisted.web._http2r   ImportErrorr   rn   r   r   r   r   r   rO  r   rZ  r   re  r   ro  r   NotifyingRequestFactoryProxyr   TestCaser   r.  r  r  r  r*   r&   r#   <module>r     s   
     7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0 0 0 H H H H H H H H " " " " " " + + + + + + 4 4 4 4 4 4 " " " " " "                        
* IIIOOO,,,,,,,,/////// * * *)FFF*
a a a a a a a aH' ' ' ' ' ' ' 'T   B3 3 3 3.  (       ( 323EFF     4<   D 545IJJ % % % % %#7 % % %  %=$< % % !
	5 	5 	5 	5 	54< 	5 	5 	5 545IJJ C C C C C C C C0  878OPP M M M M M M M M"K0 K0 K0 K0 K0x(*: K0 K0 K0\(a
0 a
0 a
0 a
0 a
0*,< a
0 a
0 a
0HT5 T5 T5 T5 T5X.0@ T5 T5 T5n& & & & &8,.> & & &8l0 l0 l0 l0 l0)+; l0 l0 l0 l0 l0s   "A? ?B	B	