ϪfhUdZddlZddlmZddlmZddlmZddlZ ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZddlmZdd lmZmZmZmZmZdd lmZdd lmZdd lm Z dd l!m"Z"ddl#m$Z$gZ%ee&e'd<e(Z)eeeGddee Z*eeeeGddZ+dZ,y)a HTTP2 Implementation This is the basic server-side protocol implementation used by the Twisted Web server for HTTP2. This functionality is intended to be combined with the HTTP/1.1 and HTTP/1.0 functionality in twisted.web.http to provide complete protocol support for HTTP-type protocols. This API is currently considered private because it's in early draft form. When it has stabilised, it'll be made public. N)deque)List) implementer) _PullToPush)Deferred)ConnectionLost) IConsumer IProtocol IPushProducer ISSLTransport ITransport)Protocol)Logger) TimeoutMixin)Failure)ExcessiveBufferingError__all__ceZdZdZdZdZdZeZdZ d#dZ dZ dZ dZ dZd$d Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%d Z&d!Z'd"Z(y)% H2Connectiona A class representing a single HTTP/2 connection. This implementation of L{IProtocol} works hand in hand with L{H2Stream}. This is because we have the requirement to register multiple producers for a single HTTP/2 connection, one for each stream. The standard Twisted interfaces don't really allow for this, so instead there's a custom interface between the two objects that allows them to work hand-in-hand here. @ivar conn: The HTTP/2 connection state machine. @type conn: L{h2.connection.H2Connection} @ivar streams: A mapping of stream IDs to L{H2Stream} objects, used to call specific methods on streams when events occur. @type streams: L{dict}, mapping L{int} stream IDs to L{H2Stream} objects. @ivar priority: A HTTP/2 priority tree used to ensure that responses are prioritised appropriately. @type priority: L{priority.PriorityTree} @ivar _consumerBlocked: A flag tracking whether or not the L{IConsumer} that is consuming this data has asked us to stop producing. @type _consumerBlocked: L{bool} @ivar _sendingDeferred: A L{Deferred} used to restart the data-sending loop when more response data has been produced. Will not be present if there is outstanding data still to send. @type _consumerBlocked: A L{twisted.internet.defer.Deferred}, or L{None} @ivar _outboundStreamQueues: A map of stream IDs to queues, used to store data blocks that are yet to be sent on the connection. These are used both to handle producers that do not respect L{IConsumer} but also to allow priority to multiplex data appropriately. @type _outboundStreamQueues: A L{dict} mapping L{int} stream IDs to L{collections.deque} queues, which contain either L{bytes} objects or C{_END_STREAM_SENTINEL}. @ivar _sender: A handle to the data-sending loop, allowing it to be terminated if needed. @type _sender: L{twisted.internet.task.LoopingCall} @ivar abortTimeout: The number of seconds to wait after we attempt to shut the transport down cleanly to give up and forcibly terminate it. This is only used when we time a connection out, to prevent errors causing the FD to get leaked. If this is L{None}, we will wait forever. @type abortTimeout: L{int} @ivar _abortingCall: The L{twisted.internet.base.DelayedCall} that will be used to forcibly close the transport if it doesn't close cleanly. @type _abortingCall: L{twisted.internet.base.DelayedCall} Nctjjdd}tjj ||_i|_tj|_d|_ d|_ i|_ i|_ d|_ d|_t|_d|_|ddlm}||_|j(j+d|j,y)NF) client_sideheader_encoding)configTiDr)reactor)h2rH2Configuration connectionrconnstreamspriority PriorityTree_consumerBlocked_sendingDeferred_outboundStreamQueues_streamCleanupCallbacks_stillProducing_maxBufferedControlFrameBytesr_bufferedControlFrames_bufferedControlFrameBytestwisted.internetr_reactor callLater_sendPrioritisedData)selfrrs 4/usr/lib/python3/dist-packages/twisted/web/_http2.py__init__zH2Connection.__init__ss**ud*SMM..f.=   --/ $ $%'"')$#.7*&+g#*+' ? 0  4#<#<=c|j|j|jj|jj |jj y)z Called by the reactor when a connection is received. May also be called by the L{twisted.web.http._GenericHTTPChannelProtocol} during upgrade to HTTP/2. N) setTimeouttimeOutrinitiate_connection transportwrite data_to_sendr/s r0connectionMadezH2Connection.connectionMadesC  % %%' TYY3356r2c |jj|}|j|D]}t|tjjr|j|:t|tjjr|j!|pt|tjj"r|j%|t|tjj&r|j)|t|tjj*r|j-|t|tjj.r|j1|Jt|tjj2sp|j j|jtt5dd|j y#tjj$rJ|j }|r5|j j|jtdYywxYw)z Called whenever a chunk of data is received from the transport. @param data: The data received from the transport. @type data: L{bytes} F)_cancelTimeoutsNzRemote peer sent GOAWAY)r receive_datar exceptions ProtocolError_tryToWriteControlDatar7loseConnectionconnectionLostr resetTimeout isinstanceeventsRequestReceived_requestReceived DataReceived_requestDataReceived StreamEnded _requestEnded StreamReset_requestAborted WindowUpdated_handleWindowUpdatePriorityUpdated_handlePriorityUpdateConnectionTerminatedr)r/datarF stillActiveevents r0 dataReceivedzH2Connection.dataReceiveds YY++D1F  E%!:!:;%%e,E299#9#9:))%0E299#8#89""5)E299#8#89$$U+E299#:#:;((/E299#<#<=**51E299#A#AB--/##N+DEF$)$ ( ##%?}}** 557K--/##GIu#E   sG22A$IIc|jjd|jj|jj dkDs|jj dkDr%tjjj}n$tjjj}|jj||jj|jj|j+|j!|j|j"|_|jj'y)a- Called when the connection has been inactive for L{self.timeOut} seconds. Cleanly tears the connection down, attempting to notify the peer if needed. We override this method to add two extra bits of functionality: - We want to log the timeout. - We want to send a GOAWAY frame indicating that the connection is being terminated, and whether it was clean or not. We have to do this before the connection is torn down. zTiming out client {client}clientr) error_codeN)_loginfor7getPeerropen_outbound_streamsopen_inbound_streamsrerrors ErrorCodesPROTOCOL_ERRORNO_ERRORclose_connectionr8r9 abortTimeoutr-forceAbortClient _abortingCallrB)r/r[s r0timeoutConnectionzH2Connection.timeoutConnections 3DNN>;Q;Q;S  " &&(r2cld|_|r|jd|jjD]}|j |t |jj D]}|j||r/|j"|jjd|_yyy)a Called when the transport connection is lost. Informs all outstanding response handlers that the connection has been lost, and cleans up all internal state. @param reason: See L{IProtocol.connectionLost} @param _cancelTimeouts: Propagate the C{reason} to this connection's streams but don't cancel any timers, so that peers who never read the data we've written are eventually timed out. FN) r'r4r valuesrClistkeys _requestDonerhcancel)r/reasonr=streamstreamIDs r0rCzH2Connection.connectionLosts %  OOD !ll))+ *F  ! !& ) *T\\..01 (H   h ' ( t11=    % % '!%D  >?r2cJ|jttdy)z Stop producing data. This tells the L{H2Connection} that its consumer has died, so it must stop producing data for good. zProducing stoppedN)rCrrr:s r0 stopProducingzH2Connection.stopProducingAs GN3F$GHIr2clt|_|jj|jy)z Pause producing data. Tells the L{H2Connection} that it has produced too much data to process for the time being, and to stop until resumeProducing() is called. N)rr# addCallback_flushBufferedControlDatar:s r0pauseProducingzH2Connection.pauseProducingJs(!)  ))$*H*HIr2cf|j%|j}d|_|jdyy)z Resume producing data. This tells the L{H2Connection} to re-add itself to the main loop and produce more data for the consumer. N)r#callback)r/ds r0resumeProducingzH2Connection.resumeProducingUs4  ,%%A$(D ! JJt  -r2c"|jsyd}| t|j}||j&|jj |jy|j|jj|}|j|j}t|jj|}|t ur`|jj#||j$j'|jj)|j+|nt-||kDr(||d}|d|}|j|j/||rO|jj1|||j$j'|jj)|j|s|jj3||j5|dkr|j6|j9|j:j=d|jy#tj$rE|jJt |_|jj |jYywxYw)a The data sending loop. This function repeatedly calls itself, either from L{Deferred}s or from L{reactor.callLater} This function sends data on streams according to the rules of HTTP/2 priority. It ensures that the data from each stream is interleved according to the priority signalled by the client, making sure that the connection is used with maximal efficiency. This function will execute if data is available: if all data is exhausted, the function will place a deferred onto the L{H2Connection} object and wait until it is called to resume executing. Nr)r'nextr! DeadlockErrorr$rrxr.r#rDrlocal_flow_control_windowr%popleftminmax_outbound_frame_size_END_STREAM_SENTINEL end_streamr7r8r9rplen appendleft send_datablockremainingOutboundWindowr flowControlBlockedr,r-)r/argsrsremainingWindow frameData maxFrameSize excessDatas r0r.z!H2Connection._sendPrioritisedDataas* ## n dmm,n  ,  ! ! - -d.G.G H  ))==fE..v6>>@ 499<--f5 ##F+++F3q8 V$779 4#<#<=i)) ,,444(0 %%%11$2K2KL  sH66AJ Jct|j||j|j|j|j }||j |j<t|j|j<t|j|j< |jj|j|jj|jy#tj$rYywxYw)z Internal handler for when a request has been received. @param event: The Hyper-h2 event that encodes information about the received request. @type event: L{h2.events.RequestReceived} N)H2Stream stream_idheadersrequestFactorysitefactoryr rr&rr%r! insert_streamrDuplicateStreamErrorr/rVrss r0rHzH2Connection._requestReceiveds OO  MM    II LL  )/ U__%8@ $$U__56;g""5??3 1 MM ' ' 8 MM   0 ,,    s%C**D?Dc|j|j}|j|j|jy)z Internal handler for when a chunk of data is received for a given request. @param event: The Hyper-h2 event that encodes information about the received data. @type event: L{h2.events.DataReceived} N)r rreceiveDataChunkrTflow_controlled_lengthrs r0rJz!H2Connection._requestDataReceiveds0eoo. E,H,HIr2cV|j|j}|jy)a Internal handler for when a request is complete, and we expect no further data for that request. @param event: The Hyper-h2 event that encodes information about the completed stream. @type event: L{h2.events.StreamEnded} N)r rrequestCompleters r0rLzH2Connection._requestEndeds"eoo. r2c|j|j}|jtt d|j z|j |jy)z Internal handler for when a request is aborted by a remote peer. @param event: The Hyper-h2 event that encodes information about the reset stream. @type event: L{h2.events.StreamReset} zStream reset with code %sN)r rrCrrr[rprs r0rNzH2Connection._requestAbortedsQeoo. N#>AQAQ#QR S  %//*r2c |jj|j|jxsd|j|j y#tj $rs|jj|j|jxsd|j|j |jj|jYywxYw)z Internal handler for when a stream priority is updated. @param event: The Hyper-h2 event that encodes information about the stream reprioritization. @type event: L{h2.events.PriorityUpdated} N)r depends_onweight exclusive) r! reprioritizerrrrMissingStreamErrorrr)r/rVs r0rRz"H2Connection._handlePriorityUpdates 1 MM & &// ++3t||// '  ** 1 MM ' '// ++3t||// (  MM   0 1sA ABCCc|jdd|f |jj|||jy#tj j $rYywxYw)a{ Called by L{twisted.web.http.Request} objects to write a complete set of HTTP headers to a stream. @param version: The HTTP version in use. Unused in HTTP/2. @type version: L{bytes} @param code: The HTTP status code to write. @type code: L{bytes} @param reason: The HTTP reason phrase to write. Unused in HTTP/2. @type reason: L{bytes} @param headers: The headers to write to the stream. @type headers: L{twisted.web.http_headers.Headers} @param streamID: The ID of the stream to write the headers to. @type streamID: L{int} r:statusN)insertr send_headersrArr?StreamClosedError)r/versioncoderrrrts r0 writeHeaderszH2Connection.writeHeaderss^( q:t,- * II " "8W 5  ' ' ) }}..    sAA#"A#cv|j|j||jj|dkDrK|jj ||j $|j }d|_|j||j|dkr|j|jyy)aB May be called by L{H2Stream} objects to write response data to a given stream. Writes a single data frame. @param streamID: The ID of the stream to write the data to. @type streamID: L{int} @param data: The data chunk to write to the stream. @type data: L{bytes} rN) r%appendrrr!unblockr$r|rr r)r/rtrTr}s r0writeDataToStreamzH2Connection.writeDataToStream0s ""8,33D9 99 . .x 81 < MM ! !( +$$0))(,% 8$  ' ' 1Q 6 LL " 5 5 7 7r2c|j|jt|jj ||j %|j }d|_|j |yy)z Called by L{H2Stream} objects to signal completion of a response. @param streamID: The ID of the stream to write the data to. @type streamID: L{int} N)r%rrr!rr$r|)r/rtr}s r0 endRequestzH2Connection.endRequestJs` ""8,334HI h'  ,%%A$(D ! JJx  -r2c|jj||j}|r|j|yy)a Called by L{H2Stream} objects to request early termination of a stream. This emits a RstStream frame and then removes all stream state. @param streamID: The ID of the stream to write the data to. @type streamID: L{int} N)r reset_streamrArp)r/rtrUs r0 abortRequestzH2Connection.abortRequestXs: x(113    h ' r2c|j|=|jj||j|=|jj |}|j |y)a Called internally by the data sending loop to clean up state that was being used for the stream. Called when the stream is complete. @param streamID: The ID of the stream to clean up state for. @type streamID: L{int} N)r%r! remove_streamr r&popr|)r/rtcleanupCallbacks r0rpzH2Connection._requestDoneesT  & &x 0 ##H- LL "66::8D  *r2c|jj|}|j|}td|D}||z S)a Called to determine how much room is left in the send window for a given stream. Allows us to handle blocking and unblocking producers. @param streamID: The ID of the stream whose flow control window we'll check. @type streamID: L{int} @return: The amount of room remaining in the send window for the given stream, including the data queued to be sent. @rtype: L{int} c3DK|]}|tus t|ywN)rr).0chunks r0 z7H2Connection.remainingOutboundWindow..s!  >R1RCJ s  )rrr%sum)r/rt windowSize sendQueuealreadyConsumeds r0rz$H2Connection.remainingOutboundWindowssLYY88B ..x8  $-  O++r2c|j}|rf|j|sy|jj|r|jj ||j |jy|j jD]]}|j|jj|js9|jj |j_y)a Manage flow control windows. Streams that are blocked on flow control will register themselves with the connection. This will fire deferreds that wake those streams up and allow them to continue processing. @param event: The Hyper-h2 event that encodes information about the flow control window change. @type event: L{h2.events.WindowUpdated} N) r_streamIsActiver%getr!rr windowUpdatedrmrt)r/rVrtrss r0rPz H2Connection._handleWindowUpdates?? ''1 ))--h7 %%h/ LL " 0 0 2,,--/ ;$$&--11&//BMM))&//:  ;r2c6|jjS)ah Get the remote address of this connection. Treat this method with caution. It is the unfortunate result of the CGI and Jabber standards, but should not be considered reliable for the usual host of reasons; port forwarding, proxying, firewalls, IP masquerading, etc. @return: An L{IAddress} provider. )r7r^r:s r0r^zH2Connection.getPeers~~%%''r2c6|jjS)z Similar to getPeer, but returns an address describing this side of the connection. @return: An L{IAddress} provider. )r7getHostr:s r0rzH2Connection.getHosts~~%%''r2c\|jj|||jy)a+ Open the stream window by a given increment. @param streamID: The ID of the stream whose window needs to be opened. @type streamID: L{int} @param increment: The amount by which the stream window must be incremented. @type increment: L{int} N)racknowledge_received_datarA)r/rt increments r0openStreamWindowzH2Connection.openStreamWindows$ ++Ix@ ##%r2c2t|jdduS) Returns L{True} if this channel is using a secure transport. @returns: L{True} if this channel is secure. @rtype: L{bool} N)r r7r:s r0 _isSecurezH2Connection._isSecuresT^^T2$>>r2cddg}|jj|||jy)z Sends a 100 Continue response, used to signal to clients that further processing will be performed. @param streamID: The ID of the stream that needs the 100 Continue response @type streamID: L{int} )rs100)rrN)rrrA)r/rtrs r0_send100ContinuezH2Connection._send100Continues/(( w(C ##%r2cdg}|jj||d|j}|rD|j|}|j t t d|j|yy)af This is a quick and dirty way of responding to bad requests. As described by HTTP standard we should be patient and accept the whole request from the client before sending a polite bad request response, even in the case when clients send tons of data. Unlike in the HTTP/1.1 case, this does not actually disconnect the underlying transport: there's no need. This instead just sends a 400 response and terminates the stream. @param streamID: The ID of the stream that needs the 100 Continue response @type streamID: L{int} )rs400T)rrrzInvalid requestN)rrrAr rCrrrp)r/rtrrUrss r0!_respondToBadRequestAndDisconnectz.H2Connection._respondToBadRequestAndDisconnectsp (( w(tT113 \\(+F  ! !'.9J*K"L M   h ' r2c||jvS)a? Checks whether Twisted has still got state for a given stream and so can process events for that stream. @param streamID: The ID of the stream that needs processing. @type streamID: L{int} @return: Whether the stream still has state allocated. @rtype: L{bool} )r )r/rts r0rzH2Connection._streamIsActives4<<''r2c^|jj}|sy|j(|js|jj |y|jj ||xjt|z c_|j|jk\r|j}|jjd|j||jj|jj|jtt!yy)aE Checks whether the connection is blocked on flow control and, if it isn't, writes any buffered control data. @return: L{True} if the connection is still active and L{False} if it was aborted because too many bytes have been written but not consumed by the other end. TzMaximum number of control frame bytes buffered: {bufferedControlFrameBytes} > = {maxBufferedControlFrameBytes}. Aborting connection to client: {client} )bufferedControlFrameBytesmaxBufferedControlFrameBytesrZF)rr9r#r)r7r8rr*rr(r\errorr^rkrCrr)r/ bufferedBytesmaxBuffCtrlFrameBytess r0rAz#H2Connection._tryToWriteControlDatas ..0   (1L1L NN  /  ' ' . .} =  + +s=/A A +..$2T2TT(,(J(J% ?/3.M.M1F>>113 ..0##G,C,E$FGr2c|j{|jrn|jj}|xjt |zc_|j j ||j|jrlyyyy)z Called when the connection is marked writable again after being marked unwritable. Attempts to flush buffered control data if there is any. N)r#r)rr*rr7r8)r/r nextWrites r0ryz&H2Connection._flushBufferedControlData;sr##+0K0K33;;=I  + +s9~ = + NN  +##+0K0K+0K+r2r)T))__name__ __module__ __qualname____doc__rrrfrr\rhr1r;rWrirgrCrvrzr~r.rHrJrLrNrRrrrrrprrPr^rrrrrrrAryr2r0rr6s2hG DL 8DM>47(&T%(N )&TJ J L>^1> J ! +16*@84 ! ( +,.";H (( &? &(0 (+Z ,r2rceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZy)ra A class representing a single HTTP/2 stream. This class works hand-in-hand with L{H2Connection}. It acts to provide an implementation of L{ITransport}, L{IConsumer}, and L{IProducer} that work for a single HTTP/2 connection, while tightly cleaving to the interface provided by those interfaces. It does this by having a tight coupling to L{H2Connection}, which allows associating many of the functions of L{ITransport}, L{IConsumer}, and L{IProducer} to objects on a stream-specific level. @ivar streamID: The numerical stream ID that this object corresponds to. @type streamID: L{int} @ivar producing: Whether this stream is currently allowed to produce data to its consumer. @type producing: L{bool} @ivar command: The HTTP verb used on the request. @type command: L{unicode} @ivar path: The HTTP path used on the request. @type path: L{unicode} @ivar producer: The object producing the response, if any. @type producer: L{IProducer} @ivar site: The L{twisted.web.server.Site} object this stream belongs to, if any. @type site: L{twisted.web.server.Site} @ivar factory: The L{twisted.web.http.HTTPFactory} object that constructed this stream's parent connection. @type factory: L{twisted.web.http.HTTPFactory} @ivar _producerProducing: Whether the producer stored in producer is currently producing data. @type _producerProducing: L{bool} @ivar _inboundDataBuffer: Any data that has been received from the network but has not yet been received by the consumer. @type _inboundDataBuffer: A L{collections.deque} containing L{bytes} @ivar _conn: A reference to the connection this stream belongs to. @type _conn: L{H2Connection} @ivar _request: A request object that this stream corresponds to. @type _request: L{twisted.web.iweb.IRequest} @ivar _buffer: A buffer containing data produced by the producer that could not be sent on the network at this time. @type _buffer: L{io.BytesIO} Nc ||_||_||_d|_d|_d|_d|_d|_d|_t|_ ||_ ||d|_ tj|_|j!|y)a Initialize this HTTP/2 stream. @param streamID: The numerical stream ID that this object corresponds to. @type streamID: L{int} @param connection: The HTTP/2 connection this stream belongs to. @type connection: L{H2Connection} @param headers: The HTTP/2 request headers. @type headers: A L{list} of L{tuple}s of header name and header value, both as L{bytes}. @param requestFactory: A function that builds appropriate request request objects. @type requestFactory: A callable that returns a L{twisted.web.iweb.IRequest}. @param site: The L{twisted.web.server.Site} object this stream belongs to, if any. @type site: L{twisted.web.server.Site} @param factory: The L{twisted.web.http.HTTPFactory} object that constructed this stream's parent connection. @type factory: L{twisted.web.http.HTTPFactory} TNF)queued)rtrr producingcommandpathproducer_producerProducing_hasStreamingProducerr_inboundDataBuffer_conn_requestioBytesIO_buffer_convertHeaders)r/rtrrrrrs r0r1zH2Stream.__init__s:!      "'%)""'' &tE: zz|  W%r2chd}|D]{}|djdst|j|xs|}2|ddk(r |d|_E|ddk(r |d|_X|ddk(sat|jd|df}|sE|jd vr|jj dn|jj d |jj |jjjd }|r(|djd k(r|jy y y ) aZ This method converts the HTTP/2 header set into something that looks like HTTP/1.1. In particular, it strips the 'special' headers and adds a Host: header. @param headers: The HTTP/2 header set. @type headers: A L{list} of L{tuple}s of header name and header value, both as L{bytes}. Fr:s:methods:paths :authorityshost)sGETsHEADNsexpects 100-continue) startswith_addHeaderToRequestrrr gotLength parseCookiesrequestHeaders getRawHeaderslowerr)r/rrheaderexpectContinues r0rzH2Stream._convertHeaderss  IF!9''-/ vFS) j(%ay h&"1I m+#DMMGVAY3GH I||00 ''* ''- ""$55CCIN nQ/557?J  ! ! #K>r2c|js|jj||fy|jj ||j j |j|y)av Called when the connection has received a chunk of data from the underlying transport. If the stream has been registered with a consumer, and is currently able to push data, immediately passes it through. Otherwise, buffers the chunk until we can start producing. @param data: The chunk of data that was received. @type data: L{bytes} @param flowControlledLength: The total flow controlled length of this chunk, which is used when we want to re-open the window. May be different to C{len(data)}. @type flowControlledLength: L{int} N)rrrrhandleContentChunkrrrt)r/rTflowControlledLengths r0rzH2Stream.receiveDataChunksP~~  # # * *D2F+G H MM , ,T 2 JJ ' ' 7K Lr2c|jr2|jj|j|jdy|j j tdfy)z Called by the L{H2Connection} when the all data for a request has been received. Currently, with the legacy L{twisted.web.http.Request} object, just calls requestReceived unless the producer wants us to be quiet. sHTTP/2N)rrrequestReceivedrrrrrr:s r0rzH2Stream.requestCompletesC >> MM ) )$,, 9 M  # # * *,@$+G Hr2c:|jj|y)z Called by the L{H2Connection} when a connection is lost or a stream is reset. @param reason: The reason the connection was lost. @type reason: L{str} N)rrC)r/rrs r0rCzH2Stream.connectionLosts $$V,r2c|jsy|jry|jj|j}|dkDsyd|_|jj y)zo Called by the L{H2Connection} when this stream's flow control window has been opened. NrT)rrrrrtr~)r/rs r0rzH2Stream.windowUpdateds[ }}   " "  **<Br2)rrrrr7r1rrrrCrrrrrrr8rrBrkr^rrr#r&rvrzr~rr2r0rrHs4pI+&Z $FM, I-(2 ,O&-3 D- / $ $ &)'V ) Cr2rc|j}|\}}|j|}||j|n|j||g|dk(r|j t |yy)a Add a header tuple to a request header object. @param request: The request to add the header tuple to. @type request: L{twisted.web.http.Request} @param header: The header tuple to add to the request. @type header: A L{tuple} with two elements, the header name and header value, both as L{bytes}. @return: If the header being added was the C{Content-Length} header. @rtype: L{bool} scontent-lengthTF)rrr setRawHeadersrint)rrrnamevaluerms r0rrsm++NKD%  ) )$ /F  e$$TE73   #e*% r2)-rr collectionsrtypingrzope.interfacer h2.configr h2.connection h2.errors h2.events h2.exceptionsr!"twisted.internet._producer_helpersrtwisted.internet.deferrtwisted.internet.errorrtwisted.internet.interfacesr r r r r twisted.internet.protocolrtwisted.loggerrtwisted.protocols.policiesrtwisted.python.failurertwisted.web.errorrrstr__annotations__objectrrrrrr2r0rDs  &:+1/!3*5cx Y &N ,8\N ,'N ,b ZM2\C\C3\C~ r2