wce! ddlZddlmZddlmZmZmZddlmZddl m Z m Z m Z m Z ddlmZmZddlmZmZdd lmZmZmZGd d eeeeefZy) N)suppress)AnyOptionalTuple) BaseProtocol) ClientOSErrorClientPayloadErrorServerDisconnectedErrorServerTimeoutError)BaseTimerContextstatus_code_must_be_empty_body)HttpResponseParserRawResponseMessage) EMPTY_PAYLOAD DataQueue StreamReadercheZdZdZdej ddfdZedefdZ edefdZ d*dZ d*d Z defd Z d eeddffd Zd*d Zd*fd Zd*fd Zd eddffd ZdededdfdZdddddddddd deededededeeded ed!ed"eddfd#Zd*d$Zd*d%Zd*d&Zd*d'Zd(eddfd)Z xZ!S)+ResponseHandlerz8Helper class to adapt between Protocol and StreamReader.loopreturnNctj||tj||d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ y)N)rF)r__init__r _should_close_payload _skip_payload_payload_parser_timer_tail _upgraded_parser _read_timeout_read_timeout_handle_timeout_ceil_threshold)selfrs 6/usr/lib/python3/dist-packages/aiohttp/client_proto.pyrzResponseHandler.__init__sud.4&"04 "#  59 .2CG!89$rc|jSN)r"r's r(upgradedzResponseHandler.upgraded)s ~~rc2|j|jjr |jry|jxsW|jxsI|j duxs5|j duxs%t |dkDxst|jSNTr) ris_eofr"r exceptionrlenboolr!r+s r( should_closezResponseHandler.should_close-s == $T]]-A-A-Ct~~    ~~ ~~t+ ##4/ 4y1}  DJJ  rcd|_yNT)rr+s r( force_closezResponseHandler.force_close;s !rc~|j}|/|jd|_d|_|jyyr*) transportcloser _drop_timeout)r'r8s r(r9zResponseHandler.close>s:NN  OO !DN DM    !rcX|jduxr|jj Sr*)r8 is_closingr+s r( is_connectedzResponseHandler.is_connectedFs&~~T)M$..2K2K2M.MMrexcc|j|j2tt5|jj dddd}|j  |j j }|js@t|trt|j}| t|}|j|d|_d|_d|_d|_d|_t"|I|y#1swYxYw#t$r3|j $|j jtdYwxYw)Nz!Response payload is not completedTF)r:rr Exceptionfeed_eofr#r set_exceptionr r/ isinstanceOSErrorr argsr r_reading_pausedsuperconnection_lost)r'r> uncompleted __class__s r(rHzResponseHandler.connection_lostIs     +)$ 0$$--/ 0 << # "ll335 {{}#w'#SXX.{-k:   s #!  #$ $9 0 0 ==,MM//*+NO sC<D<D9EEc$|jyr*)r:r+s r( eof_receivedzResponseHandler.eof_receivedks rcBt||jyr*)rG pause_readingr:r'rJs r(rNzResponseHandler.pause_readingos  rcBt||jyr*)rGresume_reading_reschedule_timeoutrOs r(rQzResponseHandler.resume_readingss     "rcRd|_|jt| |yr5)rr:rGrB)r'r>rJs r(rBzResponseHandler.set_exceptionws$!  c"rparserpayloadc||_||_|j|jr&|jdc}|_|j |yy)Nr)rrr:r! data_received)r'rTrUdatas r( set_parserzResponseHandler.set_parser|sK   %  ::#zz3 D$*   t $ rFTiri) timer skip_payloadread_until_eofauto_decompress read_timeout read_bufsizetimeout_ceil_threshold max_line_sizemax_field_sizerZr[r\r]r^r_r`rarbc ||_||_||_t||j||t | ||||  |_|jr&|jdc} |_|j| yy)N)rZpayload_exceptionresponse_with_bodyr\r]rarbr) rr$r&r_loopr r#r!rW) r'rZr[r\r]r^r_r`rarbrXs r(set_response_paramsz#ResponseHandler.set_response_paramss{*)'=$)  JJ 0#//)+')    ::#zz3 D$*   t $ rc`|j"|jjd|_yyr*)r%cancelr+s r(r:zResponseHandler._drop_timeouts-  $ $ 0  % % , , .(,D % 1rc|j}|j|jj|r,|jj ||j |_yd|_yr*)r$r%rirf call_later_on_read_timeout)r'timeouts r(rRz#ResponseHandler._reschedule_timeoutsZ$$  $ $ 0  % % , , . (, (=(=..)D %)-D %rc$|jyr*)rRr+s r( start_timeoutzResponseHandler.start_timeouts   "rctd}|j||j|jj|yy)Nz#Timeout on reading data from socket)r rBr)r'r>s r(rlz ResponseHandler._on_read_timeouts< !FG 3 == $ MM ' ' , %rrXc|j|sy|jB|jj|\}}|r!d|_d|_|r|j |y|j s |j |xj|z c_y |j j|\}}}||_d}|D]m\}}|jrd|_ ||_|jst|j r|j|t"fdZ|j||fdo|4|t"ur|j%|j&n|j'|r|r|j |y||_yy#t$rA}|j|jj|j|Yd}~yd}~wwxYwr.)rRr feed_datarrWr"r#r! BaseExceptionr8r9rBr3rrrcoderon_eofr:) r'rXeoftailmessagesr,r>rUmessages r(rWzResponseHandler.data_receiveds   "     +,,66t$GW++-1*$+DM))-K .'?C'91= >& m3t'9'9:**,**40%) G%~~1,,.&&s+sF G  7GG )rN)"__name__ __module__ __qualname____doc__asyncioAbstractEventLooprpropertyr2r,r3r6r9r=rrsrHrLrNrQrBrrYr floatintrgr:rRrorlbytesrW __classcell__)rJs@r(rrszB:W66:4:*$  d    "!NdN %8M#: %t %D###4# % %s %t %$-1"$ $(,!()!""%()"% "%  "%  "%uo"%"%!&"%"%"% "%H- -#- ?*%?*D?*rr)r~ contextlibrtypingrrr base_protocolrclient_exceptionsr r r r helpersr rhttprrstreamsrrrrrr(rsM''' F8;;w*lIe4F 4T.U$Vw*r