Ϫf4dZddlmZddlmZddlmZddlmZm Z m Z m Z ddl m Z mZddlmZmZddlmZdd lmZmZmZmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mm?Z?ddl@mAZAddlBmCZCmDZDddlEmFZFmGZGGddeHZIGddeHZJeAddgiZKdZLdZMdZNdZOdZPGdd e ZQGd!d"ZRGd#d$eRe ZSGd%d&eRe ZTGd'd(e ZUGd)d*ZVGd+d,ZWGd-d.e ZXeeCGd/d0ZYGd1d2e ZZGd3d4e Z[Gd5d6e Z\Gd7d8e Z]Gd9d:e Z^y;).cbFailednsl [9 LFD KK       3;;-y Q 7  r@) assertFailure addCallback)rRdeferredmainTyperQrSds` ` rAassertWrapperExceptionTypesrYUs-2 8X.AMM( Hr@c&t||t|S)zo A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType} of L{ResponseFailed}. )rYr0rRrVrQs rAassertResponseFailedr\}s 'tX~{ SSr@c&t||t|S)zx A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType} of L{RequestGenerationFailed}. )rYr,r[s rAassertRequestGenerationFailedr^s ' h/ r@c&t||t|S)zz A simple helper to invoke L{assertWrapperExceptionTypes} with a C{mainType} of L{RequestTransmissionFailed}. )rYr-r[s rAassertRequestTransmissionFailedr`s ' h1; r@c(tdddt|S)z Helper function for creating a Response which uses the given transport. All of the other parameters to L{Response.__init__} are filled with arbitrary values. Only use this method if you don't care about any of them. sHTTPrcOK)r._boringHeaders) transports rAjustTransportResponserhs OS% KKr@ceZdZdZdZy)MakeStatefulDispatcherTestsz. Tests for L{makeStatefulDispatcher}. cGdd}|}|j|jdd|_|j|jdd|_|jt|jy)z A method defined with L{makeStatefulDispatcher} invokes a second method based on the current state of the object. c4eZdZdZdZedeZdZdZy)CMakeStatefulDispatcherTests.test_functionCalledByState..FooAcyNr?rRs rAbarzGMakeStatefulDispatcherTests.test_functionCalledByState..Foo.barsr@quuxcy)Nar?rqs rA_quux_AzKMakeStatefulDispatcherTests.test_functionCalledByState..Foo._quux_Ar@cy)Nbr?rqs rA_quux_BzKMakeStatefulDispatcherTests.test_functionCalledByState..Foo._quux_Brwr@N)r;r<r=_staterrr(rvrzr?r@rAFoorms$F )5C  r@r|ruBryCN)rLrrr{ assertRaises RuntimeError)rRr|statefuls rAtest_functionCalledByStatez6MakeStatefulDispatcherTests.test_functionCalledByStatesc  5 - - , 5r@N)r;r<r=r>rr?r@rArjrjs 6r@rjcbeZdZUdZdZeeed<dZdZ dZ dZ dZ d Z d Zd Zd Zd Zy)_HTTPParserTestszt Base test class for L{HTTPParser} which is responsible for the bulk of the task of parsing HTTP bytes. NsepcRg}t}|j|_|jt |j |j t|jd|jz|j |dg|j |j ty)zj L{HTTPParser} calls its C{statusReceived} method when it receives a status line. HTTP/1.1 200 OKN) r"appendstatusReceivedmakeConnectionrrLstater dataReceivedrr)rRstatusprotocols rAtest_statusCallbackz$_HTTPParserTests.test_statusCallbacks <"(-- 12 00488;< "4!56 0r@ci}t}|j|_|jt |j d|j z||fS)Nr)r" __setitem__headerReceivedrrrrrRheaderrs rA_headerTestSetupz!_HTTPParserTests._headerTestSetupsP<"("4"4 120488;<xr@c|j\}}|jd|jz|j|j|j|ddi|j|jt y)ze L{HTTPParser} calls its C{headerReceived} method when it receives a header. s X-Foo:barX-FoobarNrrrrLrrrs rAtest_headerCallbackz$_HTTPParserTests.test_headerCallbacksk  002lTXX56 dhh' (F!34 .r@c||j\}}|jd|jz|jd|jz|jd|jz|j|j|j|ddi|j|jt y)z If a header is split over multiple lines, L{HTTPParser} calls C{headerReceived} with the entire value once it is received. X-Foo: bars bazs quuxrs bar baz quuxNrrs rAtest_continuedHeaderCallbackz-_HTTPParserTests.test_continuedHeaderCallbacks  002mdhh67g01i$((23dhh' (, .r@c|j\}}|jjgd}|jd|z|jd|z|j|j|j |dddy)z Leading and trailing linear whitespace is stripped from the header value passed to the C{headerReceived} callback. )s s bar s r@sX-Bar:sX-Foo:r)rsX-BarN)rrjoinrrL)rRrrvalues rAtest_fieldContentWhitespacez,_HTTPParserTests.test_fieldContentWhitespacesw  002 @Ai%/0i%/0dhh' Ff!EFr@cg|j\}fd}|_j|j|j t g|j j ty)zg After the last header is received, L{HTTPParser} calls C{allHeadersReceived}. cRjjt_yrp)rrr)calledrsrAallHeadersReceivedzD_HTTPParserTests.test_allHeadersCallback..allHeadersReceiveds MM(.. )#HNr@N)rrrrrLrrr)rRrrrrs @@rAtest_allHeadersCallbackz(_HTTPParserTests.test_allHeadersCallbacksd 002 $'9#dhh' &* 0r@c|j\}}|j|j|j|i|j|jt y)zp If there are no headers in the message, L{HTTPParser} does not call C{headerReceived}. Nrrs rAtest_noHeaderCallbackz&_HTTPParserTests.test_noHeaderCallbacksM  002dhh' $ .r@ct}|jt|jd|jz|jd|jz|jd|jz|j|jdddgfg}|j |t |jjy)zc All headers received by L{HTTPParser} are added to L{HTTPParser.headers}. rr X-Foo: bazrrbazN) r"rrrrrLlistheadersgetAllRawHeaders)rRrexpecteds rAtest_headersSavedOnResponsez,_HTTPParserTests.test_headersSavedOnResponse#s < 120488;<mdhh67mdhh67dhh'/01 4(8(8(I(I(K#LMr@ct}gd}|D]'}|j|j|d|d)|j|jddy)z L{HTTPParser.isConnectionControlHeader} returns C{True} for headers which are always connection control headers (similar to "hop-by-hop" headers from RFC 2616 section 13.5.1) and C{False} for other headers. )content-length connections keep-alivestestrailersstransfer-encodingsupgradesproxy-connectionz Expecting z. to be a connection control header, but wasn'tsdatez`Expecting the arbitrarily selected 'date' header to not be a connection control header, but was.N)r" assertTrueisConnectionControlHeader assertFalse)rRrconnHeaderNamesrs rAtest_connectionControlHeadersz._HTTPParserTests.test_connectionControlHeaders1sh <  & F OO226:"%     . .w 7 4 r@ct}|jt|jt |j t |jt y)zi L{HTTPParser.switchToBodyMode} raises L{RuntimeError} if called more than once. N)r"rrswitchToBodyModeobjectrrrRrs rAtest_switchToBodyModez&_HTTPParserTests.test_switchToBodyModeOsF < 12!!&(+ ,(A(A68Lr@)r;r<r=r>rrbytes__annotations__rrrrrrrrrrr?r@rArrsL  C% 1  / / G1"/ N <Mr@rceZdZdZdZy)$HTTPParserRFCComplaintDelimeterTestsz< L{_HTTPParserTests} using standard CR LF newlines.  Nr;r<r=r>rr?r@rArrZs Cr@rceZdZdZdZy)'HTTPParserNonRFCComplaintDelimeterTestsz5 L{_HTTPParserTests} using bare LF newlines.  Nrr?r@rArrbs Cr@rceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ y) HTTPClientParserTestszd Tests for L{HTTPClientParser} which is responsible for parsing HTTP response messages. c^tdd}|j|jddy)zj L{HTTPClientParser.parseVersion} parses a status line into its three components. Ns CANDY/7.2)sCANDY)r!rL parseVersionrs rAtest_parseVersionz'HTTPClientParserTests.test_parseVersionps, $D$/ ..|<>NOr@ctdd}t|jfd}|d|d|d|d|d|dy) zr L{HTTPClientParser.parseVersion} raises L{ValueError} when passed an unparsable version. Ncdj|}j|j|yrp)rrLdata)sexcefrRs rA checkParsingz@HTTPClientParserTests.test_parseBadVersion..checkParsings+##Aq!,C   SXXq )r@foos foo/bar/bazsfoo/sfoo/..sfoo/a.bs foo/-1.-1)r!rr)rRrrrrs` @@rAtest_parseBadVersionz*HTTPClientParserTests.test_parseBadVersionxsX $D$/   ! ! * V^$WYZ \"r@cxtddtd}t|d}|jt |j d|j |jjd|j |jjd|j |jjdy)z L{HTTPClientParser.statusReceived} parses the version, code, and phrase from the status line and stores them on the response object. GET/NHTTP/1.1 200 OK rbrdre r+rfr!rrrrLresponseversioncodephraserRrequestrs rAtest_responseStatusParsingz0HTTPClientParserTests.test_responseStatusParsings &$=#GT2 1245 **22OD **//5 **1159r@cxtddtd}t|d}|jt |j d|j |jjd|j |jjd|j |jjdy)z L{HTTPClientParser.statusReceived} can parse a status line without a phrase (though such lines are a violation of RFC 7230, section 3.1.2; nevertheless some broken servers omit the phrase). rrNsHTTP/1.1 200 rbrdr@rrs rA test_responseStatusWithoutPhrasez6HTTPClientParserTests.test_responseStatusWithoutPhrases &$=#GT2 1212 **22OD **//5 **1137r@cLtddfd}|d|dy)z L{HTTPClientParser.statusReceived} raises L{ParseError} if it is called with a status line which cannot be parsed. Ncjtj|}j|j|yrp)rr$rrLr)rrrrRs rArzBHTTPClientParserTests.test_badResponseStatus..checkParsings1##J0G0GKC   SXXq )r@rsHTTP/1.1 bar OK)r!)rRrrs` @rAtest_badResponseStatusz,HTTPClientParserTests.test_badResponseStatuss+ $D$/ * V '(r@cr i}g}g}g t||j}|j|_t }|j ||j ||j|j_ fd|j_ |j ||j|jd|j|jt|j|g|j|dg|j dg|j|jjd|S)a0 Assert that L{HTTPClientParser} parses the given C{response} to C{request}, resulting in a response with no body and no extra bytes and leaving the transport in the producing state. @param request: A L{Request} instance which might have caused a server to return the given response. @param status: A string giving the status line of the response to be parsed. @param response: A string giving the response to be parsed. @return: A C{dict} of headers from the response. c&jdSNTr)bodyDataFinishedsrAz3HTTPClientParserTests._noBodyTest..s6F6M6Md6Sr@ producingr@Tr)r!rrrrrrr_bodyDataReceived_bodyDataFinishedrL producerStaterrlength) rRrrrrfinishedbodyrrgrs @rA _noBodyTestz!HTTPClientParserTests._noBodyTests #GX__="("4"4#%  * f%.2kk+.S+h' 00+> . r" C5) )D62 **1115 r@c~tddtd}d}d}|j|||}|j|ddiy)z If the response is to a HEAD request, no body is expected, the body callback is not invoked, and the I{Content-Length} header is passed to the header callback. HEADrNrsContent-Length: 10 sContent-Lengths10)r+rfrrL)rRrrrrs rAtest_headResponsez'HTTPClientParserTests.test_headResponsesH '4>'4!!'68< "3U!;.r@rs X-Foo: bar rx-foorr!r+rfrrrrL connHeadersr3rrassertIdenticalrrrs rAtest_responseHeadersz*HTTPClientParserTests.test_responseHeaderss $ FD.$ 79J   1245/0g& --wr{; **22GXx.rr@rsX-Multiline: a s b rs x-multilinesa brrs rAtest_responseHeadersMultilinez3HTTPClientParserTests.test_responseHeadersMultilines $ FD.$ 79J   124534l+g& --wr{;     % %w /L'M  X..55~Fr@cttddtdd}|jt |j d|j d|j d|j d|j |jjti|j |jtd gd gd |j |jjd y) zv The connection control headers are added to the parser's C{connHeaders} L{Headers} instance. rrNcyrpr?rs rArz>HTTPClientParserTests.test_connectionHeaders..)rr@rContent-Length: 123 sConnection: close r123sclose)rr{ r!r+rfrrrrLrrr3rrrs rAtest_connectionHeadersz,HTTPClientParserTests.test_connectionHeaders#s $ FD.$ 79J   12458967g& **22GBK@   (L M  **1137r@cttddtdd}|jt |j d|j d|j d|j |jjtdd gi|j |jti|j |jjd y) z If a HEAD request is made, the I{Content-Length} header in the response is added to the response headers, not the connection control headers. rrNcyrpr?rs rArzRHTTPClientParserTests.test_headResponseContentLengthEntityHeader..=rr@rrrrrrrrs rA*test_headResponseContentLengthEntityHeaderz@HTTPClientParserTests.test_headResponseContentLengthEntityHeader7s $ GT>4 8:K   124589g&     % %w0AF8/L'M  --wr{; **1115r@cg}ttddtd|j}t }|j ||j dg}|j|j_|j d|j d|j|jd|j|jt|j d|j|dg|j|jt|j d |j|dd g|j|jt|j|d gy) z If a response includes a body with a length given by the I{Content-Length} header, the bytes which make up the body are passed to the C{_bodyDataReceived} callback on the L{HTTPParser}. rrNrsContent-Length: 10 rpausedsxxxxxxsyyyyr@)r!r+rfrrrrrrrLrrrrrRrrrgrs rAtest_contentLengthz(HTTPClientParserTests.test_contentLengthIs+ # FD.$ 7 $%  *45.2kk+78g& 00(; .h' z* .h' (34 . C5)r@cg}ttddtd|j}|j t |j dg}|j|j_|j d|j d|j|jt|j|g|j|dg|j|jjdy) z If a response includes a I{Content-Length} header indicating zero bytes in the response, L{Response.length} is set accordingly and no data is delivered to L{Response._bodyDataReceived}. rrNrContent-Length: 0 rr@r) r!r+rfrrrrrrrLrrrrRrrrs rAtest_zeroContentLengthz,HTTPClientParserTests.test_zeroContentLengthhs # FD.$ 7   1245.2kk+67g& . r" C5) **1115r@cttddtdd}|jt |j t |jdy)z If a response includes multiple I{Content-Length} headers, L{HTTPClientParser.dataReceived} raises L{ValueError} to indicate that the response is invalid and the transport is now unusable. rrNs9HTTP/1.1 200 OK Content-Length: 1 Content-Length: 2 )r!r+rfrrr ValueErrorrrs rA!test_multipleContentLengthHeadersz7HTTPClientParserTests.test_multipleContentLengthHeaderssL $GFD.$$OQUV 12    ! !  r@cRg}ttddtd|j}|j t |j d|j d|j d|j|jt|j|dgy)zy If extra bytes are received past the end of a response, they are passed to the finish callback. rrNrr Here is another thing!Here is another thing! r!r+rfrrrrrLrrrRrrs rAtest_extraBytesPassedBackz/HTTPClientParserTests.test_extraBytesPassedBacks # FD.$ 7   124567;< . $=#>?r@cRg}ttddtd|j}|j t |j d|j d|j d|j|jt|j|dgy)z If extra bytes are received past the end of the headers of a response to a HEAD request, they are passed to the finish callback. rrNrsContent-Length: 12 r#r$r%r&s rAtest_extraBytesPassedBackHEADz3HTTPClientParserTests.test_extraBytesPassedBackHEADs # GT>4 8(//   124578;< . $=#>?r@cxg}ttddtd|j}|j t |j dg}|j|j_|j d|j d|j|g|j|jjt|j d|j|dg|j d |j|dd g|j d |j|d gy) z If the response headers indicate the response body is encoded with the I{chunked} transfer encoding, the body is decoded according to that transfer encoding before being passed to L{Response._bodyDataReceived}. rrNrsTransfer-Encoding: chunked rs3 aasbc sbcs 0 extrasextra) r!r+rfrrrrrrrLrrrrs rAtest_chunkedResponseBodyz.HTTPClientParserTests.test_chunkedResponseBodys # FD.$ 7   1245.2kk+?@g& r" X..55~F i( v&i( e}- /0 H:.r@cg}ttddtd|j}t }|j ||j dg}|j|j_|j d|j d|j d|j|ddg|jtd|j|d gy) z If a response does not include a I{Transfer-Encoding} or a I{Content-Length}, the end of response body is indicated by the connection being closed. rrNrrrrzsimulated end of connectionr@) r!r+rfrrrrrrrLconnectionLostr rs rAtest_unknownContentLengthz/HTTPClientParserTests.test_unknownContentLengths # FD.$ 7 $%  *45.2kk+g&f%f% /0/L MN C5)r@cTg}ttddtd|j}t }|j ||j dg}|j|j_|j d|j|dg|j|dgy)z According to RFC 2616, section 4.4, point 3, if I{Content-Length} and I{Transfer-Encoding: chunked} are present, I{Content-Length} MUST be ignored rrNrs@Content-Length: 102 Transfer-Encoding: chunked 3 abc 0 abcr@) r!r+rfrrrrrrrLrs rA%test_contentLengthAndTransferEncodingz;HTTPClientParserTests.test_contentLengthAndTransferEncodings # FD.$ 7 $%  *45.2kk+   x( C5)r@ct}ttddtdd}|j ||j }|j ttt||tgS)z If L{HTTPClientParser.connectionLost} is called before the headers are finished, the C{_responseDeferred} is fired with the L{Failure} passed to C{connectionLost}. rrN) rr!r+rfr_responseDeferredr.rr9r\)rRrgrresponseDeferreds rAtest_connectionLostBeforeBodyz3HTTPClientParserTests.test_connectionLostBeforeBodysi $% #GFD.$$OQUV *#55(:(< =>#D*:=O.fakeBodyDataFinished0s $& &r@rc log_failurerp)rcreateWithCleanuprrr!r+rfrr4rUrrrr. assertEqualsrMassertIsInstancerr9flushLoggedErrors)rR logObserverrgrrr;eventrs rAtest_connectionLostWithErrorz2HTTPClientParserTests.test_connectionLostWithErrors +<.Brr@) r!r+rfr4rrr.r rTr1rRrrXs rAtest_noResponseAtAllz*HTTPClientParserTests.test_noResponseAtAll<sb $ GT>4 8:J   & & 12 01!!!%:;;r@cBttddtdd}|j}|j t |j d|jt|j|tj|jtS)z If a partial response was received and the connection is lost, the resulting error is L{ResponseFailed}, but not L{ResponseNeverReceived}. rrNcyrpr?rFs rArzBHTTPClientParserTests.test_someResponseButNotAll..Qrr@2) r!r+rfr4rrrr.r rTr0rUr?rHs rAtest_someResponseButNotAllz0HTTPClientParserTests.test_someResponseButNotAllJs $ GT>4 8:J   & & 12d# 01!!!^4@@  ! !>  r@c8d}ttddtdd}|jt |j ||j t|dddu|j|jt|jtt|jjd|jtt|jjd|j |j y)zy If a response in the 1XX range is received it just gets swallowed and the parser resets itself. HTTP/1.1 103 Early Hints Server: socketserver/1.0.0 Link: ; rel=preload; as=style Link: ; rel=preload; as=script rrNcyrpr?rFs rArzCHTTPClientParserTests.test_1XXResponseIsSwallowed..jrr@rr)r!r+rfrrrrgetattrrLrrrMrrrr_everReceivedData)rRsample103Responsers rAtest_1XXResponseIsSwallowedz1HTTPClientParserTests.test_1XXResponseIsSwallowed\s   $ FD.$ 79I   12/0 *d;tCD 0 T("2"2"C"C"EFGK T("6"6"G"G"IJKQO 223r@cd}d}ttddtdd}|jt |j ||z|j |jjd|j |jjti|j |jtdd gi|j |jjd y) z When a 1XX response is swallowed, the final response that follows it is the only one that gets sent to the application. rO(HTTP/1.1 200 OK Content-Length: 123 rrNcyrpr?rFs rArzUHTTPClientParserTests.test_1XXFollowedByFinalResponseOnlyEmitsFinal..rr@rdrrr r!r+rfrrrrLrrrr3rrrRrSfollowing200Responsers rA-test_1XXFollowedByFinalResponseOnlyEmitsFinalzCHTTPClientParserTests.test_1XXFollowedByFinalResponseOnlyEmitsFinalvs    Y# FD.$ 79I   12/2FFG **//5 **22GBK@ --w8IF87T/UV **1137r@cd}d}ttddtdd}|jt |j ||z|z|z|j |jjd|j |jjti|j |jtdd gi|j |jjd y) zp It is acceptable for multiple 1XX responses to come through, all of which get ignored. rOrVrrNcyrpr?rFs rArzKHTTPClientParserTests.test_multiple1XXResponsesAreIgnored..rr@rdrrrrXrYs rA#test_multiple1XXResponsesAreIgnoredz9HTTPClientParserTests.test_multiple1XXResponsesAreIgnoreds    Y# FD.$ 79I   12   # #  **//5 **22GBK@ --w8IF87T/UV **1137r@c^tj|t}d}tt ddt dd}|j t|j||jdt||d}|j|dd |j|d d y) zF When a 1XX response is ignored, Twisted emits a log. rOrrNcyrpr?rFs rArzHHTTPClientParserTests.test_ignored1XXResponseCausesLog..rr@rcr log_formatz#Ignoring unexpected {code} responserg) rr=rr!r+rfrrrr>rM)rRrArSrrBs rA test_ignored1XXResponseCausesLogz6HTTPClientParserTests.test_ignored1XXResponseCausesLogs+<rrrrrrrrrr r rrrrr!r'r)r,r/r2r6rCrIrMrTr[r^rcr?r@rArrjs P#, : 8)&"H =44G G&8(6$*>62 $@"@"#/J*0*< R3: < $44828<.r@rc(eZdZdZdZdZdZdZdZy) SlowRequesta L{SlowRequest} is a fake implementation of L{Request} which is easily controlled externally (for example, by code in a test method). @ivar stopped: A flag indicating whether C{stopWriting} has been called. @ivar finished: After C{writeTo} is called, a L{Deferred} which was returned by that method. L{SlowRequest} will never fire this L{Deferred}. rFc8t|_|jSrp)rrrRrgs rAwriteTozSlowRequest.writeTos  }}r@cd|_yrstoppedrqs rA stopWritingzSlowRequest.stopWriting  r@N) r;r<r=r>methodrk persistentrhrlr?r@rAreres" FGJr@receZdZdZdZdZy) SimpleRequesta L{SimpleRequest} is a fake implementation of L{Request} which writes a short, fixed string to the transport passed to its C{writeTo} method and returns a succeeded L{Deferred}. This vaguely emulates the behavior of a L{Request} with no body producer. Fc:|jdtdS)N SOME BYTES)writer rgs rArhzSimpleRequest.writeTos &t}r@N)r;r<r=r>rorhr?r@rArqrqsJr@rqceZdZdZdZdZdZdZdZdZ d&d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ d Z!d!Z"d"Z#d#Z$d$Z%d%Z&y)'HTTP11ClientProtocolTestsz] Tests for the HTTP 1.1 client protocol implementation, L{HTTP11ClientProtocol}. ct|_t|_|jj |jy)zR Create an L{HTTP11ClientProtocol} connected to a fake transport. N)rrgr)rrrqs rAsetUpzHTTP11ClientProtocolTests.setUps.)*,.  $$T^^4r@c|jjt|j|jj dy)z L{HTTP11ClientProtocol.request} accepts a L{Request} and calls its C{writeTo} method with its own transport. rsN)rrrqrLrgrrqs rA test_requestz&HTTP11ClientProtocolTests.test_requests5 mo. --/?r@cjjtfd}jjjt t }|j ||S)z The second time L{HTTP11ClientProtocol.request} is called, it returns a L{Deferred} which immediately fires with a L{Failure} wrapping a L{RequestNotSent} exception. cZjjjdyNr@rLrgrignoredrRs rA cbNotSentz?HTTP11ClientProtocolTests.test_secondRequest..cbNotSent    T^^113S 9r@)rrrerTrqr%rUrRrrXs` rAtest_secondRequestz,HTTP11ClientProtocolTests.test_secondRequestsT km, :   t}}44]_E~ V i r@cjjttdfd}j jj t t}|j||S)z L{HTTP11ClientProtocol.request} returns a L{Deferred} which immediately fires with a L{Failure} wrapping a L{RequestNotSent} if called after the protocol has been disconnected. z sad transportcZjjjdyr}r~rs rArzLHTTP11ClientProtocolTests.test_requestAfterConnectionLost..cbNotSentrr@) rr.rr rTrrqr%rUrs` rAtest_requestAfterConnectionLostz9HTTP11ClientProtocolTests.test_requestAfterConnectionLosts\ $$W^O-L%MN :   t}}44]_E~ V i r@cGdd}jj|}fd}t|tg}|j ||S)a% If the L{Deferred} returned by L{Request.writeTo} fires with a L{Failure}, L{HTTP11ClientProtocol.request} disconnects its transport and returns a L{Deferred} which fires with a L{Failure} of L{RequestGenerationFailed} wrapping the underlying failure. ceZdZdZdZy)CHTTP11ClientProtocolTests.test_failedWriteTo..BrokenRequestFc(ttSrp)rr9rgs rArhzKHTTP11ClientProtocolTests.test_failedWriteTo..BrokenRequest.writeTo,s.011r@Nr;r<r=rorhr?r@rA BrokenRequestr)s J 2r@rcjjjjj t t dy)Nzyou asked for it)rrg disconnectingrr.rr rs rArSz>HTTP11ClientProtocolTests.test_failedWriteTo..cbFailed1s8 OODNN88 9 MM ( (@R1S)T Ur@)rrr^r9rU)rRrrXrSs` rAtest_failedWriteToz,HTTP11ClientProtocolTests.test_failedWriteTo!sP 2 2 MM ! !-/ 2 V *$4F3G H hr@czGdd}|jj|}t||tgS)z If L{Request.writeTo} raises an exception, L{HTTP11ClientProtocol.request} returns a L{Deferred} which fires with a L{Failure} of L{RequestGenerationFailed} wrapping that exception. ceZdZdZdZy)MHTTP11ClientProtocolTests.test_synchronousWriteToError..BrokenRequestFctrpr:rgs rArhzUHTTP11ClientProtocolTests.test_synchronousWriteToError..BrokenRequest.writeToEs (**r@Nrr?r@rArrBs J +r@r)rrr^r9)rRrrXs rAtest_synchronousWriteToErrorz6HTTP11ClientProtocolTests.test_synchronousWriteToError;s7 + + MM ! !-/ 2,T17I6JKKr@NcDt}|jj|}t||tg}|j |j |jjtt |j|j |dk(r|jjd|S|dk(r^|jjtt|jt}|jt!|d|S |S)a2 If L{HTTP11ClientProtocol}'s transport is disconnected before the L{Deferred} returned by L{Request.writeTo} fires, the L{Deferred} returned by L{HTTP11ClientProtocol.request} fires with a L{Failure} of L{RequestTransmissionFailed} wrapping the underlying failure. callbackNerrbackrc)rerrr`r9rrkr.rrrrrrCr@rLrM)rRmoderrXerrorss rA*test_connectionLostDuringRequestGenerationzDHTTP11ClientProtocolTests.test_connectionLostDuringRequestGenerationKs- MM ! !' * +D!6H5I J ) $$W-?-A%BC ( :     % %d +Y     $ $W-F-H%I J++,EFF   S[! , r@c$|jdS)z If the request passed to L{HTTP11ClientProtocol} finishes generation successfully after the L{HTTP11ClientProtocol}'s connection has been lost, nothing happens. rrrqs rA+test_connectionLostBeforeGenerationFinishedzEHTTP11ClientProtocolTests.test_connectionLostBeforeGenerationFinishedks >>zJJr@c$|jdS)z If the request passed to L{HTTP11ClientProtocol} finished generation with an error after the L{HTTP11ClientProtocol}'s connection has been lost, nothing happens. rrrqs rA)test_connectionLostBeforeGenerationFailedzCHTTP11ClientProtocolTests.test_connectionLostBeforeGenerationFailedss >>yIIr@ctjtfd}jdj |S)a  If the request passed to L{HTTP11ClientProtocol} finished generation with an error after the L{HTTP11ClientProtocol}'s connection has been lost, an error is logged that gives a non-confusing hint to user on what went wrong. cjdtd}jd|j|ddj|ddy)Nrcrr<razJError writing request, but not in valid state to finalize request: {state}rCONNECTION_LOST)r>rMassertInrL)ignorerBrArRs rAcheckznHTTP11ClientProtocolTests.test_errorMessageOnConnectionLostBeforeGenerationFailedDoesNotConfuse..checksa   a[!1 2NE MM- /   l#/    U7^-> ?r@r)rr=rrrU)rRrrAs` @rAEtest_errorMessageOnConnectionLostBeforeGenerationFailedDoesNotConfusez_HTTP11ClientProtocolTests.test_errorMessageOnConnectionLostBeforeGenerationFailedDoesNotConfuse{sA+<>yIUU   r@cjjtddtd}fd}|j |jj d|S)z When a response is delivered to L{HTTP11ClientProtocol}, the L{Deferred} previously returned by the C{request} method is called back with a L{Response} instance and the connection is closed. rrNcj|jdj|jtj j j jjjdy)Nrd QUIESCENT) rLrrr3rrgrrr)rrRs rA cbRequestzIHTTP11ClientProtocolTests.test_receiveSimplestResponse..cbRequests_   X]]C 0   X--wy 9 OODNN88 9   T]]00+ >r@s9HTTP/1.1 200 OK Content-Length: 0 Connection: close rrr+rfrUrrRrXrs` rAtest_receiveSimplestResponsez6HTTP11ClientProtocolTests.test_receiveSimplestResponsesU MM ! !'&$"M N ? i  ""  r@cjjtddtd}fd}|j |jj d|S)z The headers included in a response delivered to L{HTTP11ClientProtocol} are included on the L{Response} instance passed to the callback returned by the C{request} method. rrNc\tdddgi}j|j|y)Nrrr)r3rLr)rrrRs rArzHHTTP11ClientProtocolTests.test_receiveResponseHeaders..cbRequests-66*:;.cbResponse..1668Jr@) rrclosedDeferred deliverBodyrLrrrrU)r whenFinishedrrquiescentResultrRrgs` @rA cbResponsez]HTTP11ClientProtocolTests.test_receiveResponseBeforeRequestGenerationDone..cbResponsesq$&A.6j 8L1+   #   X^^-T U OOI33 4   _b 1++,JK Kr@cb|\}}j|jdj|jdj|jdj|jt ddgij|dj jdy)Nrbrdrerrfoobar)rLrrrrr3rr)resultrrrrRs rA cbAllResponsez`HTTP11ClientProtocolTests.test_receiveResponseBeforeRequestGenerationDone..cbAllResponses#NHd   X-- ?   X]]C 0   X__e 4   X--w6(7K/L M   T9 -    % %d +r@)rr)rrrerrrU)rRrXrrrrrrgs` @@@@rA/test_receiveResponseBeforeRequestGenerationDonezIHTTP11ClientProtocolTests.test_receiveResponseBeforeRequestGenerationDones#% '(>(>? *-   W %   L j! , m$r@ct}t}||_|j|dtj z}|j tddtd}|jd|zdzt||tgS)zy The connection is closed when the server respond with a header which is above the maximum line. r+rrNsHTTP/1.1 200 OK X-Foo: s X-Ignored: ignored ) rr)rrr MAX_LENGTHrr+rfrr\r )rRrgrlongLinerXs rA"test_receiveResponseHeadersTooLongz4H I ! "%  $D!n-=>>r@ctjj}jjdd}|j |fd}|j ||S)z If response bytes are delivered to L{HTTP11ClientProtocol} before the request completes, calling C{connectionLost} on the protocol will result in protocol being moved to C{'CONNECTION_LOST'} state. s8HTTP/1.1 400 BAD REQUEST Content-Length: 9 tisk tiskcttx}_j|j fdS)Nc jfSrprrs rArzHTTP11ClientProtocolTests.test_connectionLostAfterReceivingResponseBeforeRequestGenerationDone..cbResponse..rr@)rrrrrU)rrrs` @rArzrHTTP11ClientProtocolTests.test_connectionLostAfterReceivingResponseBeforeRequestGenerationDone..cbResponses:$&A.6j 8L1+   #++,JK Kr@cjjdjjt t j jjdy)Nr)rrrr.rr9rLr{)rrrRs rArzuHTTP11ClientProtocolTests.test_connectionLostAfterReceivingResponseBeforeRequestGenerationDone..cbAllResponsesM    % %d + MM ( (1C1E)F G   T]]113D Er@)rerrrrU)rRrXrrrs` @rADtest_connectionLostAfterReceivingResponseBeforeRequestGenerationDonez^HTTP11ClientProtocolTests.test_connectionLostAfterReceivingResponseBeforeRequestGenerationDonesd - MM ! !' * ""   L j! F m$r@c&ttx}_jj t ddt d}jjdg}|j|jj|gjjd|d}|jjjdjjdfd }|j||S) z The C{deliverBody} method of the response object with which the L{Deferred} returned by L{HTTP11ClientProtocol.request} fires can be used to get the body of the response. rrNs%HTTP/1.1 200 OK Content-Length: 6 rrrrc|jjdjjty)Nr)rLr closedReasonrKr/)rrrRs rArzIHTTP11ClientProtocolTests.test_receiveResponseBody..cbAllResponseJs+   X]]I 6  ! ! & &| 4r@) rrrrrr+rfrrUrrLr)rRrrequestDeferredrrrrs` @rAtest_receiveResponseBodyz2HTTP11ClientProtocolTests.test_receiveResponseBody(s ()19; x.--// FD.$ 7  "" A ##FMM2 $ ""5)!9X& ""6* ""6* 5   /r@cF|jjtddtd}|jj dg}|j |j |d}t}|j||jj d|jj d|j|jd|jjttd |jjt y) z If the length of the response body is unknown, the protocol passed to the response's C{deliverBody} method has its C{connectionLost} method called with a L{Failure} wrapping a L{PotentialDataLoss} exception. rrNsHTTP/1.1 200 OK rrrrz low-level transport disconnected)rrr+rfrrUrrrrLrr.rr rrKr*rRrrrrs rAEtest_responseBodyFinishedWhenConnectionLostWhenContentLengthIsUnknownz_HTTP11ClientProtocolTests.test_responseBodyFinishedWhenConnectionLostWhenContentLengthIsUnknownQs--// FD.$ 7  ""#AB##FMM2!9')X& ""6* ""6*  2 $$ N#EF G  ""#45r@cX|jjtddtd}|jj dg}|j |j |d}t}|j||jj d|jj d|j|jd|jjttt|t|j tt"gS) a If the final chunk has not been received when the connection is lost (for any reason), the protocol passed to C{deliverBody} has its C{connectionLost} method called with a L{Failure} wrapping the exception for that reason. rrNs/HTTP/1.1 200 OK Transfer-Encoding: chunked r3 foo s3 bar r)rrr+rfrrUrrrrLrr.rr9r\rrr2rs rA4test_chunkedResponseBodyUnfinishedWhenConnectionLostzNHTTP11ClientProtocolTests.test_chunkedResponseBodyUnfinishedWhenConnectionLostns--// FD.$ 7  "" L ##FMM2!9')X& ""?3 ""?3  2 $$W-?-A%BC# $x,,-0BI/N  r@cjjtddtd}jj dt |t g}fd}|j||S)a! If the parser L{HTTP11ClientProtocol} delivers bytes to in C{dataReceived} raises an exception, the exception is wrapped in a L{Failure} and passed to the parser's C{connectionLost} and then the L{HTTP11ClientProtocol}'s transport is disconnected. rrNsunparseable garbage goes here cjjjj|jdj j djjttdy)Nrsunparseable garbage goes herez it is done) rrgrrLrJrrrr.rr )rrRs rArSzLHTTP11ClientProtocolTests.test_parserDataReceivedException..cbFaileds_ OODNN88 9    A$$))+K  MM ( ( 1M)N Or@)rrr+rfrr\r$rU)rRrrXrSs` rA test_parserDataReceivedExceptionz:HTTP11ClientProtocolTests.test_parserDataReceivedExceptionse--// FD.$ 7  ""#GH  E P hr@c|jjtddtd}|jjj }|j |j|j |jjttd|j |jdt||tgS)z When the HTTP response parser is disconnected, the L{TransportProxyProducer} which was connected to it as a transport is stopped. rrNzconnection done) rrr+rf_parserrgr _producer_disconnectParserrr r\)rRrrgs rAtest_proxyStoppedz+HTTP11ClientProtocolTests.test_proxyStoppeds --// FD.$ 7 MM))33  Y00$..A ''?P0Q(RS Y00$7#D/N;KLLr@ct}t}|j|g}g}|jj |j |jj |j |j ||fggf|j|j|jtt|j |dg|j |dgy)z L{HTTP11ClientProtocol.abort} will tell the transport to close its connection when it is invoked, and returns a C{Deferred} that fires when the connection is lost. N) rr)rabortrUrrLrrr.rr )rRrgrr1r2s rAtest_abortClosesConnectionz4HTTP11ClientProtocolTests.test_abortClosesConnections $% ') *  $$RYY/$$RYY/ "bB8,  //0 (8 9: dV$ dV$r@cFt}t}|j||jt t g}|j j|j|j|dg|j|jdy)z L{HTTP11ClientProtocol.abort} called after the connection is lost returns a C{Deferred} that fires immediately. Nr) rr)rr.rr rrUrrLr{rRrgrrs rAtest_abortAfterConnectionLostz7HTTP11ClientProtocolTests.test_abortAfterConnectionLosts} $% ') *(8 9:$$V]]3 $( *;.BodyDestinationzl A body response protocol which immediately aborts the HTTP connection. c&jy)z< Abort the HTTP connection. N)rrs rAconnectionMadez`HTTP11ClientProtocolTests.test_abortAfterResponseHeaders..BodyDestination.connectionMades r@c(j|y)z Make the reason for the losing of the connection available to the unit test via C{testResult}. N)r)rRrO testResults rAr.z`HTTP11ClientProtocolTests.test_abortAfterResponseHeaders..BodyDestination.connectionLost s ""6*r@N)r;r<r=r>rr.)rrsrABodyDestinationrs   !  +r@rc|jjjjt t y)z Connect the L{BodyDestination} response body protocol to the response, and then simulate connection loss after ensuring that the HTTP connection has been aborted. N)rrrr.rr )rrrrRrgs rArzMHTTP11ClientProtocolTests.test_abortAfterResponseHeaders..deliverBodys>  !2 3 OOI33 4  # #GN,<$= >r@cFj|jtyrp)r?rr.)errorrRs rA checkErrorzLHTTP11ClientProtocolTests.test_abortAfterResponseHeaders..checkErrors  ! !%..( ;r@) rr)rrr+rfrrrrUr\rr2) rRrrrrVrrrrgs ` @@@@rAtest_abortAfterResponseHeadersz8HTTP11ClientProtocolTests.test_abortAfterResponseHeaderss$D1 ') *!!'&$"MNUVZ  +h +& ? < ;'' *0)< ##J//r@c hgfd}t}t|j|jt ddt dd}j djgg}|j|j|d}t}t|_ |jjfd |j|j d |jjt jd gjj"djj$djj&djj(djj*dy) a If after a response is done the {HTTP11ClientProtocol} stays open and returns to QUIESCENT state, all per-request state is reset and the C{quiescentCallback} is called with the protocol instance. This is useful for implementing a persistent connection pool. The C{quiescentCallback} is called *before* the response-receiving protocol's C{connectionLost}, so that new requests triggered by end of first request can re-use a persistent connection. cj|j|jdj|yNrrLrrrrrrRs rArzHHTTP11ClientProtocolTests.test_quiescentCallbackCalled..callback55   Q )   QWWk 2  " "1 %r@rrNTros&HTTP/1.1 200 OK Content-length: 3 rc&jdS)N response doner)rGrs rArzHHTTP11ClientProtocolTests.test_quiescentCallbackCalled..Os..?r@r1r)rr)rrr+rfrrLrUrrrrrrrKr/r_finishedRequest_currentRequest_transportProxyr4) rRrrgrrr bodyProtocolrrs ` @@rAtest_quiescentCallbackCalledz6HTTP11ClientProtocolTests.test_quiescentCallbackCalled'sx & $% '1 *"** FD.$4 H  UV "-##FMM2!9,- &.j ###// ?  \*f%!!&&|4 8_*EF ))40 22D9 1148 1148 33T:r@c gfd}t}t|j|jt ddt dd}j dj|}j|jdjtd j|jd y) a The C{quiescentCallback} passed to L{HTTP11ClientProtocol} will only be invoked once that protocol is in a state similar to its initial state. One of the aspects of this initial state is the producer-state of its transport; an L{HTTP11ClientProtocol} begins with a transport that is producing, i.e. not C{pauseProducing}'d. Therefore, when C{quiescentCallback} is invoked the protocol will still be producing. cj|j|jdj|yrrrs rArz]HTTP11ClientProtocolTests.test_transportProducingWhenQuiescentAfterFullBody..callbackmrr@rrNTrs)HTTP/1.1 200 OK Content-length: 3 BBBDEFERRED_CLOSErcr) rr)rrr+rfrsuccessResultOfrLr{rMr)rRrrgrrrrs` @@rA1test_transportProducingWhenQuiescentAfterFullBodyzKHTTP11ClientProtocolTests.test_transportProducingWhenQuiescentAfterFullBody`s & $% '1 *"** FD.$4 H    ''8 *:; _-q1 00+>r@c gfd}t}t|j|jt ddt dd}|j jjdjtdjd jd ty) z The quiescentCallback is called before the request C{Deferred} fires, in cases where the response has no body. cj|j|jdj|yrrrs rArzUHTTP11ClientProtocolTests.test_quiescentCallbackCalledEmptyResponse..callbackrr@rrNTr&HTTP/1.1 200 OK Content-length: 0 rrrc)rr)rrr+rfrUrrrLrMrr?r.)rRrrgrrrs` @@rA)test_quiescentCallbackCalledEmptyResponsezCHTTP11ClientProtocolTests.test_quiescentCallbackCalledEmptyResponses  & $% '1 *"** FD.$4 H  ##O$:$:;UV _-q1 _Q/: oa0(;r@c g}t}t|j}|j||j t ddt dd}|jdg}|j|j|d}t}|j||jjt|j|g|j|j y)z If after a response is done the {HTTP11ClientProtocol} returns a C{Connection: close} header in the response, the C{quiescentCallback} is not called and the connection is lost. rrNTrs9HTTP/1.1 200 OK Content-length: 0 Connection: close rrr)rrrr+rfrrUrrrrKr/rLrrrRrrgrrrrrs rAtest_quiescentCallbackNotCalledz9HTTP11ClientProtocolTests.test_quiescentCallbackNotCalleds #% '(>(>? *"** FD.$4 H    ##FMM2!9+- \*!!&&|4 "-  //0r@c g}t}t|j}|j||j t ddt dd}|jdg}|j|j|d}t}|j||jjt|j|g|j|j y)z If the request was non-persistent (i.e. sent C{Connection: close}), the C{quiescentCallback} is not called and the connection is lost. rrNFrr rrrs rA1test_quiescentCallbackNotCalledNonPersistentQueryzKHTTP11ClientProtocolTests.test_quiescentCallbackNotCalledNonPersistentQuerys #% '(>(>? *"** FD.$5 I  UV##FMM2!9+- \*!!&&|4 "-  //0r@c d}tj|t}t}t |}|j ||j tddtdd}|jdg}|j|j|d}t}|j||jjt |j#d t%||d} | d } |j'| j(t*|j-t*|j/|j0y) zx If C{quiescentCallback} throws an exception, the error is logged and protocol is disconnected. ctrp)ZeroDivisionError)rs rArzHHTTP11ClientProtocolTests.test_quiescentCallbackThrows..callbacks #% %r@rrNTrr rrcr<)rr=rrr)rrr+rfrrUrrrrrKr/r>rMr?rrr@rr) rRrrArgrrrrrrBrs rAtest_quiescentCallbackThrowsz6HTTP11ClientProtocolTests.test_quiescentCallbackThrowss  &+<2BCCr@ct}t}|j|t|ddifdfd}|_|j t ddt}jjd|j|j|j|jdt||tgS)a The L{Deferred} returned by L{HTTP11ClientProtocol.request} will fire with a L{RequestGenerationFailed} failure containing a L{CancelledError} exception if the request was cancelled before a C{bodyProducer} has finished producing. cancelledFcdd<y)NTr r?)rGnonLocals rArzJHTTP11ClientProtocolTests.assertCancelDuringBodyProduction..cancel2s $(H[ !r@cJ|_t_jSrpconsumerrr)r%rproducers rAstartProducingzRHTTP11ClientProtocolTests.assertCancelDuringBodyProduction..startProducing5s$ (H  ( 0H $$ $r@POST/barsxxxxx)rr)rStringProducerr'rr+rfr%rtrrrr^r) rRproducerLengthrgrr'rrr"r&s @@@rA assertCancelDuringBodyProductionz:HTTP11ClientProtocolTests.assertCancelDuringBodyProduction$s$% ') *!.1' ) % #1!!''7NH"UV)   ../ -.,T6N;KLLr@c$|jdS)a( The L{Deferred} returned by L{HTTP11ClientProtocol.request} will fire with a L{RequestGenerationFailed} failure containing a L{CancelledError} exception if the request was cancelled before a C{bodyProducer} with an explicit length has finished producing. )r,rqs rAtest_cancelDuringBodyProductionz9HTTP11ClientProtocolTests.test_cancelDuringBodyProductionCs44R88r@c,|jtS)a' The L{Deferred} returned by L{HTTP11ClientProtocol.request} will fire with a L{RequestGenerationFailed} failure containing a L{CancelledError} exception if the request was cancelled before a C{bodyProducer} with C{UNKNOWN_LENGTH} has finished producing. )r,rrqs rA&test_cancelDuringChunkedBodyProductionz@HTTP11ClientProtocolTests.test_cancelDuringChunkedBodyProductionLs44^DDr@rp)'r;r<r=r>rxrzrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrr,r/r1r?r@rArvrvs 5@  4L @KJ 0.$0d?4@'R6: @8 M%* =G 80t7;r,?\<41>12!1F "D M>9Er@rvc2eZdZdZdZdZdZdZdZdZ y) r*a L{StringProducer} is a dummy body producer. @ivar stopped: A flag which indicates whether or not C{stopProducing} has been called. @ivar consumer: After C{startProducing} is called, the value of the C{consumer} argument to that method. @ivar finished: After C{startProducing} is called, a L{Deferred} which was returned by that method. L{StringProducer} will never fire this L{Deferred}. Fc||_yrp)r)rRrs rA__init__zStringProducer.__init__fs  r@cF||_t|_|jSrpr$)rRr%s rAr'zStringProducer.startProducingis    }}r@cd|_yrrjrqs rA stopProducingzStringProducer.stopProducingnrmr@cyrpr?rqs rApauseProducingzStringProducer.pauseProducingq r@cyrpr?rqs rAresumeProducingzStringProducer.resumeProducingur:r@N) r;r<r=r>rkr4r'r7r9r<r?r@rAr*r*Vs' G   r@r*ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZddZdZdZdZdZdZy) RequestTestsz Tests for L{Request}. c"t|_yrp)rrgrqs rArxzRequestTests.setUps (*r@ctddtdj|j|j |jj dy)zk L{Request.writeTo} formats the request data and writes it to the given transport. rrNs8GET / HTTP/1.1 Connection: close Host: example.com r+rfrhrgrLrrqs rAtest_sendSimplestRequestz%RequestTests.test_sendSimplestRequestsD nd3;;DNNK  NN "  r@ctddtdd}|j|j|j |jj dy)zO A pesistent request does not send 'Connection: close' header. rrNTrs%GET / HTTP/1.1 Host: example.com rA)rRreqs rA"test_sendSimplestPersistentRequestz/RequestTests.test_sendSimplestPersistentRequestsGfdNDTJ DNN#  NN " B r@cvtddgdgd}tdd|dj|j|jj j d}|j |d d |j |d dd d g|d =|d d=|j|j |gd y)zf L{Request.writeTo} formats header data and writes it to the given transport. rrrE)rrDr/fooNrrGET /foo HTTP/1.1r@)Connection: closesHost: example.comrr)r3r+rhrgrsplitrLsort)rRrliness rAtest_sendRequestHeadersz$RequestTests.test_sendRequestHeaderss ff%5@PQR$/77G$$&,,W5 q#78 rsc3Z0 !HeBCj    V r@ctD]}t||gddgi}t}tdd|dj ||j j d}|j|dd|j|d dd d g|d=|d d=|jd |jd d jttg}|j||gy)z_ Linear whitespace in request headers is replaced with a single space. rDsexample.invalidrrGNrrrHrIr@rJsHost: example.invalids: ) r6r3rr+rhrrKrLremoverr7)rR componentrrgrMsanitizedHeaderLines rA-test_sanitizeLinearWhitespaceInRequestHeadersz:RequestTests.test_sanitizeLinearWhitespaceInRequestHeaderss 9 ;Iy9+wAS@TUVG')I FGWd 3 ; ;I FOO%++G4E   U1X'; <   U23Z#s 4a%* LL- . LL1 2"'**nn-M"N    U%8$9 : ;r@ctt}tddt|}|j |j |j |jd|j|j j||j|j j|j|j jd|j j|jjd|jjd|j j#d|j|j jd|j|j jdy)z L{Request.writeTo} uses chunked encoding to write data from the request body producer to the given transport. It registers the request body producer with the transport. r(r)NsXPOST /bar HTTP/1.1 Connection: close Transfer-Encoding: chunked Host: example.com sxxxsyyyyyyyyyyyyyyys!3 xxx f yyyyyyyyyyyyyyy 0 )r*rr+rfrhrgassertNotIdenticalr%rr&r streamingrLrclearrtrrrRr&rs rAtest_sendChunkedRequestBodyz(RequestTests.test_sendChunkedRequestBodys  ".1'7NHE'  1 148 T^^44h? 001  NN "   ) *""4( T^^44d;  NN " P r@cRtt}tddt|}|j j }j j |jjtfd}j|t}|j||S)a If L{Request} is created with a C{bodyProducer} without a known length and the L{Deferred} returned from its C{startProducing} method fires with a L{Failure}, the L{Deferred} returned by L{Request.writeTo} fires with that L{Failure} and the body producer is unregistered from the transport. The final zero-length chunk is not written to the transport. r(r)cjjjdjjjdyr})rLrgrrr&rs rArSzCRequestTests.test_sendChunkedRequestBodyWithError..cbFaileds:   T^^113S 9  !8!8$ ?r@) r*rr+rfrhrgrWrrr9rTrU)rRr&r writeDeferredrSrXs` rA$test_sendChunkedRequestBodyWithErrorz1RequestTests.test_sendChunkedRequestBodyWithErrors".1'7NHE7  !!"4"67 @   }.@ A hr@ctd}tddt|}|j|j|j |j d|j|jj||j|jj|j|jjd|jj|j jd|jj!d|j|jjd|j|jjdy)z If L{Request} is created with a C{bodyProducer} with a known length, that length is sent as the value for the I{Content-Length} header and chunked encoding is not used. r(r)NsOPOST /bar HTTP/1.1 Connection: close Content-Length: 3 Host: example.com r1)r*r+rfrhrgrUr%rr&rrVrLrrWrtrrrXs rAtest_sendRequestBodyWithLengthz+RequestTests.test_sendRequestBodyWithLengths "!$'7NHE'  1 148 T^^44h? 001  NN "   '""4( T^^44d; --/8r@ct|dtd}|j|j|j |jj |dzy)a" Verify that the message generated by a L{Request} initialized with the given method and C{None} as the C{bodyProducer} includes I{Content-Length: 0} in the header. @param method: The HTTP method issue in the request. @type method: L{bytes} rGNsK /foo HTTP/1.1 Connection: close Content-Length: 0 Host: example.com rA)rRrnrs rA_sendRequestEmptyBodyWithLengthz,RequestTests._sendRequestEmptyBodyWithLengthsO&'>4@'  NN "   r@c&|jdy)z If I{PUT} L{Request} is created without a C{bodyProducer}, I{Content-Length: 0} is included in the header and chunked encoding is not used. sPUTNrbrqs rAtest_sendPUTRequestEmptyBodyz)RequestTests.test_sendPUTRequestEmptyBody(s ,,V4r@c&|jdy)z If I{POST} L{Request} is created without a C{bodyProducer}, I{Content-Length: 0} is included in the header and chunked encoding is not used. r(Nrdrqs rAtest_sendPOSTRequestEmptyBodyz*RequestTests.test_sendPOSTRequestEmptyBody0s ,,W5r@cVtd}tddt|}|j|j}|j j d|jjd|j|jjd|j|tS)a If L{Request} is created with a C{bodyProducer} with a known length and the producer does not produce that many bytes, the L{Deferred} returned by L{Request.writeTo} fires with a L{Failure} wrapping a L{WrongBodyLength} exception. r_r(r)abN) r*r+rfrhrgr%rtrrrr&rTr'rRr&rr\s rA#test_sendRequestBodyWithTooFewBytesz0RequestTests.test_sendRequestBodyWithTooFewBytes8s"!$'7NHE7 &""4( T^^44d;!!-AAr@ctdtddt}|jj}j j djjj j djjjjjdfd}j|t}|j||S)a7 Verify that when too many bytes have been written by a body producer and then the body producer's C{startProducing} L{Deferred} fires that the producer is unregistered from the transport and that the L{Deferred} returned from L{Request.writeTo} is fired with a L{Failure} wrapping a L{WrongBodyLength}. @param finisher: A callable which will be invoked with the body producer after too many bytes have been written to the transport. It should fire the startProducing Deferred somehow. r_r(r)ricdNcHjjjdjjj t j jdjjjdy)NsQPOST /bar HTTP/1.1 Connection: close Content-Length: 3 Host: example.com absefr@)rLrgrrWrr r%rt)rfinisherr&rRs rArSzCRequestTests._sendRequestBodyWithTooManyBytesTest..cbFailedgs   $$&  NN "   k8+<+<+B+BE J X    T^^113S 9r@)r*r+rfrhrgr%rtrrkrrr&rTr'rU)rRrorr\rSrXr&s`` @rA$_sendRequestBodyWithTooManyBytesTestz1RequestTests._sendRequestBodyWithTooManyBytesTestGs"!$'7NHE7 & ))*& (() T^^44d; ::   }o > hr@c*d}|j|S) If L{Request} is created with a C{bodyProducer} with a known length and the producer tries to produce more than than many bytes, the L{Deferred} returned by L{Request.writeTo} fires with a L{Failure} wrapping a L{WrongBodyLength} exception. c:|jjdyrprrr&s rArozCRequestTests.test_sendRequestBodyWithTooManyBytes..finisher    & &t ,r@)rprRros rA$test_sendRequestBodyWithTooManyBytesz1RequestTests.test_sendRequestBodyWithTooManyBytess -88BBr@chtjtfd}j|S)rrc$|jjtd}jd||d}j |j tj t}jt|dy)Nrr<rc) rrr9rr?rr@rLrM)r&rBrrrArRs rArozHRequestTests.test_sendRequestBodyErrorWithTooManyBytes..finishersv    % %&8&: ;NE MM- /m$A  ! !!''+= >++,>?F   S[! ,r@)rr=rrp)rRrorAs` @rA)test_sendRequestBodyErrorWithTooManyBytesz6RequestTests.test_sendRequestBodyErrorWithTooManyBytess0+<'>F --/5r@cRd}|j|j|tS)a- If the request body producer indicates it is done by firing the L{Deferred} returned from its C{startProducing} method but then goes on to write too many bytes, the L{Deferred} returned by {Request.writeTo} fires with a L{Failure} wrapping L{WrongBodyLength}. c:|jjdyrprtrus rArozPRequestTests.test_sendRequestBodyFinishedEarlyThenTooManyBytes..finisherrvr@)rTrr'rws rA1test_sendRequestBodyFinishedEarlyThenTooManyBytesz>RequestTests.test_sendRequestBodyFinishedEarlyThenTooManyBytess- -!!  > >x H   r@cRd}|j|j|tS)a3 If the request body producer indicates an error by firing the L{Deferred} returned from its C{startProducing} method but then goes on to write too many bytes, the L{Deferred} returned by {Request.writeTo} fires with that L{Failure} and L{WrongBodyLength} is logged. cJ|jjtyrp)rrr9rus rArozORequestTests.test_sendRequestBodyErroredEarlyThenTooManyBytes..finishers    % %&8&: ;r@)rTrr9rws rA0test_sendRequestBodyErroredEarlyThenTooManyBytesz=RequestTests.test_sendRequestBodyErroredEarlyThenTooManyBytess- <!!  > >x H   r@Nctt}tddt|}|j |j }|j j||j j|jt|jjd|j|j jd|S)a If the request body producer with an unknown length tries to write after firing the L{Deferred} returned by its C{startProducing} method, the C{write} call raises an exception and does not write anything to the underlying transport. r(r)rr@)r*rr+rfrhrgrrrWrr r%rtrLr)rR_withr&rr\s rA0test_sendChunkedRequestBodyFinishedThenWriteMorez=RequestTests.test_sendChunkedRequestBodyFinishedThenWriteMores".1'7NHE7 ""5)  +x'8'8'>'>G --/5r@cr|jtt}|j|tS)a$ If the request body producer with an unknown length tries to write after firing the L{Deferred} returned by its C{startProducing} method with a L{Failure}, the C{write} call raises an exception and does not write anything to the underlying transport. )rrr9rT)rRrXs rA9test_sendChunkedRequestBodyFinishedWithErrorThenWriteMorezFRequestTests.test_sendChunkedRequestBodyFinishedWithErrorThenWriteMore s6  A A &( ) !!!%788r@ctd}tddt|}|j|j}|j |jj ||j|jj|jjd|j|jjd|j|jj|jj!t#t%|j|jj|j |jj d|j'|t$S)z If the L{Deferred} returned from the C{startProducing} method of the L{IBodyProducer} passed to L{Request} fires with a L{Failure}, the L{Deferred} returned from L{Request.writeTo} fails with that L{Failure}. r(r)risQPOST /bar HTTP/1.1 Connection: close Content-Length: 5 Host: example.com abN)r*r+rfrhrgrr&rrVr%rtrLrrrrrrr9rTrjs rAtest_sendRequestBodyWithErrorz*RequestTests.test_sendRequestBodyWithError s"!$'7NHE7  T^^44h? 001&  NN "   556!!'*<*>"?@ 556 T^^44d;!!-1CDDr@c tddtid}|jt|j|j |j |j jdtddtdddgid}|jt|j|j |j |j jdy)z L{Request.writeTo} raises L{BadHeaders} if there is not exactly one I{Host} header and writes nothing to the given transport. rrNr@sHostrEs example.org)r+r3rrrhrgrLr)rRrs rAtest_hostHeaderRequiredz$RequestTests.test_hostHeaderRequired; s &$ T: *goot~~F --/5 D'7^^,L"MNPT  *goot~~F --/5r@ctd}tddt|}|j|j|j |j |j|j|j y)zc L{Request.stopWriting} calls its body producer's C{stopProducing} method. r_rrN) r*r+rfrhrgrrkrlrrXs rAtest_stopWritingzRequestTests.test_stopWritingJ s` "!$&$A' ))* (()r@ctj|t}td}d}||_t ddt |}|j|j|j|jt|jtd|jdt||d}|jd||d}|j!|j"ty) z If the body producer's C{stopProducing} method raises an exception, L{Request.stopWriting} logs it and does not re-raise it. r_ctdNzstopProducing is bustedr:r?r@rAbrokenStopProducingzBRequestTests.test_brokenStopProducing..brokenStopProducing^ s$%>? ?r@rrrcrr<N)rr=rr*r7r+rfrhrgrlrLrMr@r9r>rr?r)rRrAr&rrrBrs rAtest_brokenStopProducingz%RequestTests.test_brokenStopProducingV s +<rxrBrErNrSrYr]r`rbrergrkrprxr{rrrrrrrrrrr?r@rAr>r>zs+     ";$ B.9: *56 B?B CC(M6&  " 9%EN 6 *;r@r>cBeZdZdZdZdZdZd dZdZdZ dZ d Z y ) LengthEnforcingConsumerTestsz/ Tests for L{LengthEnforcingConsumer}. ct|_td|_t |_t |j|j |j|_y)Nr.)rrr*r&rrgr#enforcerrqs rArxz"LengthEnforcingConsumerTests.setUps s@j &r* (*/ MM4>>4;;  r@cL|jjd|j|jj d|jj |jjd|j|jj dy)z L{LengthEnforcingConsumer.write} calls the wrapped consumer's C{write} method with the bytes it is passed as long as there are fewer of them than the C{length} attribute indicates remain to be received. r1sdefN)rrtrLrgrrWrqs rA test_writez'LengthEnforcingConsumerTests.test_write{ sr F# --/8  F# --/8r@c|jjd|jt|jjy)z L{LengthEnforcingConsumer._noMoreWritesExpected} raises L{WrongBodyLength} if it is called before the indicated number of bytes have been written. s xxxxxxxxxN)rrtrr'_noMoreWritesExpectedrqs rAtest_finishedEarlyz/LengthEnforcingConsumerTests.test_finishedEarly s0 H% /4==+N+NOr@cz|jjd|j|jj|jjd|j |jj|r|jj |j|jtS)aN If it is called with a total number of bytes exceeding the indicated limit passed to L{LengthEnforcingConsumer.__init__}, L{LengthEnforcingConsumer.write} fires the L{Deferred} with a L{Failure} wrapping a L{WrongBodyLength} and also calls the C{stopProducing} method of the producer. xxxxxxxxxxx) rrtrr&rkrrrTrr')rR_unregisterAfters rAtest_writeTooManyz.LengthEnforcingConsumerTests.test_writeTooMany s I& ../ D!  --.  MM / / 1!!$++??r@cX|jjd|jj|j|jj |j t|jjd|j|jj y)z If L{LengthEnforcingConsumer.write} is called after L{LengthEnforcingConsumer._noMoreWritesExpected}, it calls the producer's C{stopProducing} method and raises L{ExcessWrite}. rrN) rrtrrr&rkrr rrqs rAtest_writeAfterNoMoreExpectedz:LengthEnforcingConsumerTests.test_writeAfterNoMoreExpected sp I& ++- ../ +t}}':':DA  --.r@c$|jdS)z L{LengthEnforcingConsumer._noMoreWritesExpected} does nothing (in particular, it does not raise any exception) if called after too many bytes have been passed to C{write}. T)rrqs rAtest_finishedLatez.LengthEnforcingConsumerTests.test_finishedLate s %%d++r@c|jjd|j|jjdy)z If L{LengthEnforcingConsumer._noMoreWritesExpected} is called after the correct number of bytes have been written it returns L{None}. rN)rrtrrrqs rA test_finishedz*LengthEnforcingConsumerTests.test_finished s3 I& T]]@@BDIr@cfd}|j_fd}j}|j||S)a8 If L{LengthEnforcingConsumer.write} calls the producer's C{stopProducing} because too many bytes were written and the C{stopProducing} method raises an exception, the exception is logged and the L{LengthEnforcingConsumer} still errbacks the finished L{Deferred}. cXtjjtdr)r*r7r&r9rqsrArzRLengthEnforcingConsumerTests.test_stopProducingRaises..brokenStopProducing s!  ( ( 7$%>? ?r@cbjtjtdy)Nrc)rLrMr@r9rs rA cbFinishedzILengthEnforcingConsumerTests.test_stopProducingRaises..cbFinished s$   S!7!78J!KLa Pr@)r&r7rrU)rRrrrXs` rAtest_stopProducingRaisesz5LengthEnforcingConsumerTests.test_stopProducingRaises s> @': # Q  " " $ j!r@N)F) r;r<r=r>rxrrrrrrrr?r@rArrn s2  9P@ /,Jr@rc"eZdZdZdZdZdZy)RequestBodyConsumerTestsz Tests for L{ChunkedEncoder} which sits between an L{ITransport} and a request/response body producer and chunked encodes everything written to it. c d|jtttt y)zC L{ChunkedEncoder} instances provide L{IConsumer}. N)rrr rrrqs rAtest_interfacez'RequestBodyConsumerTests.test_interface s  Y?P0QRSr@ct}t|}|jd|j|j d|j |jd|j|j dy)z} L{ChunkedEncoder.write} writes to the transport the chunked encoded form of the bytes passed to it. rrsxxxxxxxxxxxxxxxxs10 xxxxxxxxxxxxxxxx N)rrrtrLrrW)rRrgencoders rArz#RequestBodyConsumerTests.test_write sg $%  + f *O< i  *,KLr@clt}t}t|}|j|d|j |j ||j |j|j|j |j d|j|jdy)a L{ChunkedEncoder.registerProducer} registers the given streaming producer with its transport and L{ChunkedEncoder.unregisterProducer} writes a zero-length chunk to its transport and unregisters the transport's producer. TNs0 ) rrrregisterProducerrr&rrVunregisterProducerrLr)rRrgr&rs rAtest_producerRegistrationz2RequestBodyConsumerTests.test_producerRegistration s$% 8 +  40 Y//:  ++,""$ Y//6 *L9r@N)r;r<r=r>rrrr?r@rArr s T M:r@rc:eZdZdZdZdZdZdZdZdZ dZ y ) TransportProxyProducerTestszn Tests for L{TransportProxyProducer} which proxies the L{IPushProducer} interface of a transport. cT|jtttdy)zO L{TransportProxyProducer} instances provide L{IPushProducer}. N)rrr r&rqs rArz*TransportProxyProducerTests.test_interface s  ]4J44PQRr@ct}t|}|j|j||j |j|jdy)z~ L{TransportProxyProducer.stopProxying} drops the reference to the wrapped L{IPushProducer} provider. N)rr&rr stopProxyingrRrgproxys rA%test_stopProxyingUnreferencesProducerzATransportProxyProducerTests.test_stopProxyingUnreferencesProducer sJ $% &y1 U__i8  U__d3r@cvt}|jt|}|j|jd|j |j|jd|j|j |j |j|jdy)z L{TransportProxyProducer.resumeProducing} calls the wrapped transport's C{resumeProducing} method unless told to stop proxying. rrN)rr9r&rLrr<rrs rAtest_resumeProducingz0TransportProxyProducerTests.test_resumeProducing s $%   "&y1 00(;  00+>  "   00(;r@cVt}t|}|j|jd|j |j|jd|j |j |j |j|jdy)z L{TransportProxyProducer.pauseProducing} calls the wrapped transport's C{pauseProducing} method unless told to stop proxying. rrN)rr&rLrr9r<rrs rAtest_pauseProducingz/TransportProxyProducerTests.test_pauseProducing, s $% &y1 00+>  00(;!!#   00+>r@c`t}t|}|j|jd|j |j|jdt}t|}|j |j |j|jdy)z L{TransportProxyProducer.stopProducing} calls the wrapped transport's C{stopProducing} method unless told to stop proxying. rrkN)rr&rLrr7rrs rAtest_stopProducingz.TransportProxyProducerTests.test_stopProducingA s $% &y1 00+>  00)<#% &y1   00+>r@cnt}t}|j|||_t |}|j |j |j|jd|j|j|jd|j|j y)zs L{TransportProxyProducer.loseConnection} calls the wrapped transport's C{loseConnection}. rN) rrrrr&r connectedrLrloseConnectionrrRrgrrs rA test_loseConnectionWhileProxyingz  00+> ,,-r@ct}t}|j|||_t |}|j |j |j|j|j |jy)zm L{TransportProxyProducer.loseConnection} does nothing when the proxy is not active. N) rrrrr&rrrrrs rAtest_loseConnectionNotProxyingz:TransportProxyProducerTests.test_loseConnectionNotProxyingj sr 56 ') *% &y1   ++,   ++,r@N) r;r<r=r>rrrrrrrr?r@rArr s+ S 4<,?*?(.*-r@rcjeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZy) ResponseTestsz Tests for L{Response}. chtt}|jtt|y)z= L{Response} instances provide L{IResponse}. N)rhrrrr5rRrs rAtest_verifyInterfacez"ResponseTests.test_verifyInterface s$)):;  Y9:r@c>gt}Gfddt}|}t|}|j|\}|j |j |j d|j|j |j dy)z The L{IProtocol} provider passed to L{Response.deliverBody} has its C{makeConnection} method called with an L{IPushProducer} provider hooked up to the response as an argument. ceZdZfdZy)7ResponseTests.test_makeConnection..SomeProtocolc(j|yrpr)rRr& producerss rArzFResponseTests.test_makeConnection..SomeProtocol.makeConnection s  *r@Nr;r<r=r)rsrA SomeProtocolr s +r@rrrN)rrrhrr9rLrr<)rRrgrr%r theProducerrs @rAtest_makeConnectionz!ResponseTests.test_makeConnection s  #%  +8 + >(3X&! ""$ 00(;##% 00+>r@cgGfddt}|}tt}|j||j d|j dgy)z The L{IProtocol} provider passed to L{Response.deliverBody} has its C{dataReceived} method called with bytes received as part of the response body. ceZdZfdZy)5ResponseTests.test_dataReceived..ListConsumerc(j|yrprrRrrs rArzBResponseTests.test_dataReceived..ListConsumer.dataReceived  T"r@Nr;r<r=rrsrA ListConsumerr  #r@rrN)rrhrrrrL)rRrr%rrs @rAtest_dataReceivedzResponseTests.test_dataReceived sZ  #8 # >():;X&""6* )r@c@gGfddt}|}tt}|j||j dj t |jtd|j|jdy)z The L{IProtocol} provider passed to L{Response.deliverBody} has its C{connectionLost} method called with a L{Failure} wrapping L{ResponseDone} when the response's C{_bodyDataFinished} method is called. ceZdZfdZy)7ResponseTests.test_connectionLost..ListConsumerc(j|yrpr)rRrOlosts rAr.zFResponseTests.test_connectionLost..ListConsumer.connectionLost s F#r@N)r;r<r=r.)rsrArr s $r@rrrcN) rrhrrrrKr/rLrMr _bodyProtocol)rRrr%rrs @rAtest_connectionLostz!ResponseTests.test_connectionLost s $8 $ >():;X&""$ Q \" TA& X33T:r@cHgGfddt}|}tt}|jd|jd|j ||jd|j gd|j |jdy)z If data is delivered to the L{Response} before a protocol is registered with C{deliverBody}, that data is buffered until the protocol is registered and then is delivered. ceZdZfdZy)8ResponseTests.test_bufferEarlyData..ListConsumerc(j|yrprrs rArzEResponseTests.test_bufferEarlyData..ListConsumer.dataReceived rr@NrrsrArr rr@rrrr)rrrN)rrhrrrrLr _bodyBuffer)rRrrrrs @rAtest_bufferEarlyDataz"ResponseTests.test_bufferEarlyData s  #8 # >():;""6*""6*X&""6*  89 X1148r@ctt}|jt|j t |jty)zb L{Response.deliverBody} raises L{RuntimeError} if called more than once. N)rhrrrrrrs rA test_multipleStartProducingFailsz.ResponseTests.test_multipleStartProducingFails s; )):;XZ( ,(<(.ListConsumerc<j|jyrp)rr)rRrgtransportStates rArzHResponseTests.test_transportResumed..ListConsumer.makeConnection# s%%i&=&=>r@Nr)rsrArr" s ?r@rrrN)rrr9rhrLrr)rRrrgrrrs @rAtest_transportResumedz#ResponseTests.test_transportResumed s  ?8 ?$%   ">(3 00(;X& (4 00+>r@c>t}t|}|jd|jd|jt }|j ||j |jd|jjty)z If the entire body is delivered to the L{Response} before the response's C{deliverBody} method is called, the protocol passed to C{deliverBody} is immediately given the body data and then disconnected. rrrN) rrhrrrrrLrrrKr/rRrgrrs rA)test_bodyDataFinishedBeforeStartProducingz7ResponseTests.test_bodyDataFinishedBeforeStartProducing/ s|$% (3""6*""6*""$')X&  2""<0r@ct}t|}t}|j||j |j d|j tt|jjty)a  The L{Failure} passed to L{Response._bodyDataFinished} when the response is in the I{connected} state is passed to the C{connectionLost} method of the L{IProtocol} provider passed to the L{Response}'s C{deliverBody} method. CONNECTEDN) rrhrrrLr{rrr9rrKr s rA#test_finishedWithErrorWhenConnectedz1ResponseTests.test_finishedWithErrorWhenConnectedA sn$% (3')X& +6""7+=+?#@A""#56r@ct}t|}|j|jd|j t t t}|j||jjt y)a The L{Failure} passed to L{Response._bodyDataFinished} when the response is in the I{initial} state is passed to the C{connectionLost} method of the L{IProtocol} provider passed to the L{Response}'s C{deliverBody} method. INITIALN) rrhrLr{rrr9rrrrKr s rA!test_finishedWithErrorWhenInitialz/ResponseTests.test_finishedWithErrorWhenInitialT sn$% (3 )4""7+=+?#@A')X&""#56r@N)r;r<r=r>rrrrrrrrrrrrr rrr?r@rArr} sX;?,*&;29.JJLLDD?(1$7&7r@rN)_r>typingrzope.interfacerzope.interface.verifyrtwisted.internet.deferrrrr twisted.internet.errorr r twisted.internet.interfacesr r twisted.internet.protocolrtwisted.internet.testingrrrrtwisted.loggerrtwisted.protocols.basicrtwisted.python.failurertwisted.trial.unittestrtwisted.web._newclientrrrrrrrrrr r!r"r#r$r%r&r'r(twisted.web.clientr)r*r+r,r-r.r/r0r1twisted.web.httpr2twisted.web.http_headersr3twisted.web.iwebr4r5twisted.web.test.requesthelperr6r7 Exceptionr9rCrfrYr\r^r`rhrjrrrrrerqrvr*r>rrrrr?r@rAr%s&.JJA@. .0*+(   ',5  'N#345% PTL6(6BSMSMl+;X.>Y .HY .x0  f Ef ER ]     Fq;8q;hb8bJ):x):X{-({-|h7Hh7r@