a ¾þõj‡Þã@sfdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z gd¢Z dZdZdZdZd Zd Zeƒ ejj¡d d „ejj ¡DƒZd ZdZdZe d¡jZe d¡j Z!e d¡Z"e d¡Z#e d¡jZ$e d¡jZ%hd£Z&dBdd„Z'Gdd„dej(j)ƒZ*dd„Z+e*fdd„Z,Gd d!„d!ej-ƒZ.Gd"d#„d#ƒZ/z ddl0Z0Wne1�y`Yn0Gd$d%„d%e/ƒZ2e  3d%¡Gd&d'„d'e4ƒZ5Gd(d)„d)e5ƒZ6Gd*d+„d+e5ƒZ7Gd,d-„d-e5ƒZ8Gd.d/„d/e5ƒZ9Gd0d1„d1e5ƒZ:Gd2d3„d3e5ƒZ;Gd4d5„d5e5ƒZGd:d;„d;e<ƒZ?Gdd?„d?e5ƒZAGd@dA„dAeBe@ƒZCe5ZDdS)Ca¢ HTTP/1.1 client library HTTPConnection goes through a number of "states", which define when a client may legally make another request or fetch the response for a particular request. This diagram details these state transitions: (null) | | HTTPConnection() v Idle | | putrequest() v Request-started | | ( putheader() )* endheaders() v Request-sent |\_____________________________ | | getresponse() raises | response = getresponse() | ConnectionError v v Unread-response Idle [Response-headers-read] |\____________________ | | | response.read() | putrequest() v v Idle Req-started-unread-response ______/| / | response.read() | | ( putheader() )* endheaders() v v Request-started Req-sent-unread-response | | response.read() v Request-sent This diagram presents the following rules: -- a second request may not be started until {response-headers-read} -- a response [object] cannot be retrieved until {request-sent} -- there is no differentiation between an unread response body and a partially read response body Note: this enforcement is applied by the HTTPConnection class. The HTTPResponse class does not enforce this state machine, which implies sophisticated clients may accelerate the request/response pipeline. Caution should be taken, though: accelerating the states beyond the above pattern may imply knowledge of the server's connection-close behavior for certain requests. For example, it is impossible to tell whether the server will close the connection UNTIL the response headers have been read; this means that further requests cannot be placed into the pipeline until it is known that the server will NOT be closing the connection. Logical State __state __response ------------- ------- ---------- Idle _CS_IDLE None Request-started _CS_REQ_STARTED None Request-sent _CS_REQ_SENT None Unread-response _CS_IDLE Req-started-unread-response _CS_REQ_STARTED Req-sent-unread-response _CS_REQ_SENT éN)Úurlsplit)Ú HTTPResponseÚHTTPConnectionÚ HTTPExceptionÚ NotConnectedÚUnknownProtocolÚUnknownTransferEncodingÚUnimplementedFileModeÚIncompleteReadÚ InvalidURLÚImproperConnectionStateÚCannotSendRequestÚCannotSendHeaderÚResponseNotReadyÚ BadStatusLineÚ LineTooLongÚRemoteDisconnectedÚerrorÚ responseséPi»ZUNKNOWNZIdlezRequest-startedz Request-sentcCsi|] }||j“qS©)Úphrase)Ú.0Úvrrú#/usr/lib64/python3.9/http/client.pyÚ kóriiéds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]z[0-9]+s [0-9a-fA-F]+>ZPOSTÚPUTZPATCHÚdatac Csjz | d¡WStyd}z@t|j|j|j|jd| ¡||j|j…|fƒd‚WYd}~n d}~00dS)zd?„Z ‡Z!S)FrrNcCsR| d¡|_||_||_d|_|_t|_t|_t|_ t|_ t|_ t|_ t|_ dS)NÚrb)ÚmakefilerAÚ debuglevelÚ_methodrBÚmsgÚ_UNKNOWNÚversionÚstatusÚreasonÚchunkedÚ chunk_leftÚlengthÚ will_close)r3ÚsockrMÚmethodÚurlrrrÚ__init__ÿs  zHTTPResponse.__init__c Cst|j td¡dƒ}t|ƒtkr*tdƒ‚|jdkrBtdt|ƒƒ|sNt dƒ‚z|  dd¡\}}}WnBt y¦z|  dd¡\}}d}Wnt y d}Yn0Yn0|  d ¡sÂ|  ¡t|ƒ‚z$t|ƒ}|d ksÜ|d krät|ƒ‚Wnt �yt|ƒ‚Yn0|||fS) Nr-rDz status linerzreply:z-Remote end closed connection without responseéÚzHTTP/riç)ÚstrrAr>r?r/rrMÚprintÚreprrÚsplitÚ ValueErrorÚ startswithÚ _close_connrÚint)r3r5rQrRrSrrrÚ _read_statuss2      zHTTPResponse._read_statusc Cs¸|jdurdS| ¡\}}}|tkr&qHt|jƒ}|jdkrDtd|ƒ~q||_|_|  ¡|_ |dvrnd|_ n|  d¡r€d|_ nt |ƒ‚t|jƒ|_|_|jdkrÈ|j ¡D]\}}td|d|ƒq®|j d ¡}|rò| ¡d kròd |_d|_nd |_| ¡|_d|_|j d ¡}|du�r(|  d¡}|�rL|j�sLt|ƒ�rLt|ƒ|_nd|_|tk�sŒ|tk�sŒd|k�r~dk�sŒn|jdk�r’d|_|j�s´|j�s´|jdu�r´d |_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9é zHTTP/1.é úheader:r,útransfer-encodingrTTFúcontent-lengthz réÈÚHEAD)rBrfZCONTINUErCrArMr_ÚcoderRÚstriprSrQrcrrJrOÚitemsÚgetr.rTrUÚ _check_closerWrVÚ_is_legal_content_lengthreZ NO_CONTENTZ NOT_MODIFIEDrN) r3rQrRrSZskipped_headersÚhdrÚvalZtr_encrVrrrÚbegin>s^              ÿ ÿ þÿþzHTTPResponse.begincCsv|j d¡}|jdkr.|r*d| ¡vr*dSdS|j d¡r>dS|rRd| ¡vrRdS|j d¡}|rrd| ¡vrrdSdS)NÚ connectionrhÚcloseTFz keep-alivezproxy-connection)rBrqrQr.)r3ÚconnZpconnrrrrr„s    zHTTPResponse._check_closecCs|j}d|_| ¡dS©N)rArx)r3rArrrrd¡szHTTPResponse._close_conncs2ztƒ ¡W|jr.| ¡n|jr,| ¡0dSrz)ÚsuperrxrArd©r3©Ú __class__rrrx¦s   ÿzHTTPResponse.closecstƒ ¡|jr|j ¡dSrz)r{ÚflushrAr|r}rrr²s zHTTPResponse.flushcCsdS)zAlways returns TrueTrr|rrrÚreadable·szHTTPResponse.readablecCs |jduS)z!True if the connection is closed.N)rAr|rrrÚisclosed½szHTTPResponse.isclosedcCsº|jdurdS|jdkr$| ¡dS|durRt|ƒ}| |¡}t|ƒd|… ¡S|jr`| ¡S|j durv|j  ¡}n4z|  |j ¡}Wnt y¢| ¡‚Yn0d|_ | ¡|SdS)Nrrmr) rArNrdÚ bytearrayÚreadintoÚ memoryviewÚtobytesrTÚ_readall_chunkedrVÚreadÚ _safe_readr )r3ÚamtÚbr4Úsrrrr‡Çs*      zHTTPResponse.readcCs¦|jdurdS|jdkr$| ¡dS|jr4| |¡S|jdur^t|ƒ|jkr^t|ƒd|j…}|j |¡}|s||r|| ¡n&|jdur¢|j|8_|js¢| ¡|S)z^Read up to len(b) bytes into bytearray b and return the number of bytes read. Nrrm) rArNrdrTÚ_readinto_chunkedrVr/r„rƒ)r3rŠr4rrrrƒçs$       zHTTPResponse.readintocCsˆ|j td¡}t|ƒtkr$tdƒ‚| d¡}|dkrB|d|…}| ¡}zt|ƒs\tdƒ‚t |dƒWSty‚|  ¡‚Yn0dS)Nr-z chunk sizeó;rzinvalid chunk sizeé) rAr>r?r/rÚfindÚrstripÚ_is_legal_chunk_sizerbrerd)r3r5ÚirrrÚ_read_next_chunk_size s     z"HTTPResponse._read_next_chunk_sizecCs:|j td¡}t|ƒtkr$tdƒ‚|s*q6|dvrq6qdS)Nr-z trailer liner;)rAr>r?r/r©r3r5rrrÚ_read_and_discard_trailers z&HTTPResponse._read_and_discard_trailercCsj|j}|sf|dur| d¡z | ¡}WntyBtdƒ‚Yn0|dkr`| ¡| ¡d}||_|S)Nr\rr)rUrˆr“rbr r•rd)r3rUrrrÚ_get_chunk_left*s   zHTTPResponse._get_chunk_leftcCsn|jtksJ‚g}z6| ¡}|dur&q>| | |¡¡d|_qd |¡WStyhtd |¡ƒ‚Yn0dS©Nrr)rTrPr–r2rˆrUrFr )r3ÚvaluerUrrrr†Bs  zHTTPResponse._readall_chunkedcCs¼|jtksJ‚d}t|ƒ}zv| ¡}|dur2|WSt|ƒ|kr\| |¡}|||_||WS|d|…}| |¡}||d…}||7}d|_qWn&ty¶tt|d|…ƒƒ‚Yn0dS)Nr) rTrPr„r–r/Ú_safe_readintorUr Úbytes)r3rŠÚ total_bytesÚmvbrUr4Útemp_mvbrrrrŒPs$         zHTTPResponse._readinto_chunkedcCsTg}|dkrJ|j t|tƒ¡}|s2td |¡|ƒ‚| |¡|t|ƒ8}qd |¡S)aVRead the number of bytes requested, compensating for partial reads. Normally, we have a blocking socket, but a read() can be interrupted by a signal (resulting in a partial read). Note that we cannot distinguish between EOF and an interrupt when zero bytes have been read. IncompleteRead() will be raised in this situation. This function should be used when bytes "should" be present for reading. If the bytes are truly not available (due to EOF), then the IncompleteRead exception can be used to detect the problem. rr)rAr‡ÚminÚ MAXAMOUNTr rFr2r/)r3r‰r‹Úchunkrrrrˆhs zHTTPResponse._safe_readcCs‚d}t|ƒ}|t|ƒkr~tt|ƒkr>|dt…}|j |¡}n |j |¡}|shtt|d|…ƒt|ƒƒ‚||d…}||7}q |S)z2Same as _safe_read, but for reading into a buffer.rN)r„r/rŸrArƒr rš)r3rŠr›rœr�r4rrrr™s      zHTTPResponse._safe_readintoéÿÿÿÿcCsˆ|jdus|jdkrdS|jr(| |¡S|jdurJ|dksD||jkrJ|j}|j |¡}|sh|rh| ¡n|jdur„|jt|ƒ8_|S)zvRead with at most one underlying system call. If at least one byte is buffered, return that instead. Nrmrr)rArNrTÚ_read1_chunkedrVÚread1rdr/)r3r4Úresultrrrr£�s    zHTTPResponse.read1cCs4|jdus|jdkrdS|jr(| |¡S|j |¡S)Nrmr)rArNrTÚ _peek_chunkedÚpeek)r3r4rrrr¦ s  zHTTPResponse.peekcsŠ|jdus|jdkrdS|jr*tƒ |¡S|jdurL|dksF||jkrL|j}|j |¡}|sj|rj| ¡n|jdur†|jt|ƒ8_|S)Nrmrr)rArNrTr{r>rVrdr/)r3Úlimitr¤r}rrr>©s    zHTTPResponse.readlinecCsd| ¡}|dus|dkrdSd|kr0|ks6n|}|j |¡}|jt|ƒ8_|s`tdƒ‚|Sr—)r–rAr£rUr/r )r3r4rUr‡rrrr¢¸s zHTTPResponse._read1_chunkedcCsBz | ¡}Wnty YdS0|dur.dS|j |¡d|…S)Nr)r–r rAr¦)r3r4rUrrrr¥Æs  zHTTPResponse._peek_chunkedcCs |j ¡Srz)rAÚfilenor|rrrr¨ÓszHTTPResponse.filenocCsF|jdurtƒ‚|j |¡p|}t|tƒs4t|dƒs8|Sd |¡SdS)axReturns the value of the header matching *name*. If there are multiple matching headers, the values are combined into a single string separated by commas and spaces. If no matching header is found, returns *default* or None if the *default* is not specified. If the headers are unknown, raises http.client.ResponseNotReady. NÚ__iter__z, )rBrZget_allÚ isinstancer^ÚhasattrrF)r3r(ÚdefaultrBrrrÚ getheaderÖs zHTTPResponse.getheadercCs|jdurtƒ‚t|j ¡ƒS)z&Return list of (header, value) tuples.N)rBrÚlistrpr|rrrÚ getheadersês zHTTPResponse.getheaderscCs|Srzrr|rrrr©òszHTTPResponse.__iter__cCs|jS)ajReturns an instance of the class mimetools.Message containing meta-information associated with the URL. When the method is HTTP, these headers are those returned by the server at the head of the retrieved HTML page (including Content-Length and Content-Type). When the method is FTP, a Content-Length header will be present if (as is now usual) the server passed back a file length in response to the FTP retrieval request. A Content-Type header will be present if the MIME type can be guessed. When the method is local-file, returned headers will include a Date representing the file's last-modified time, a Content-Length giving file size, and a Content-Type containing a guess at the file's type. See also the description of the mimetools module. )rBr|rrrÚinfo÷szHTTPResponse.infocCs|jS)aZReturn the real URL of the page. In some cases, the HTTP server redirects a client to another URL. The urlopen() function handles this transparently, but in some cases the caller needs to know which URL the client was redirected to. The geturl() method can be used to get at this redirected URL. )rZr|rrrÚgeturls zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response, or None if the URL is not an HTTP URL. )rRr|rrrÚgetcodeszHTTPResponse.getcode)rNN)N)r¡)r¡)r¡)N)"r7r8r9r[rfrvrrrdrxrr€r�r‡rƒr“r•r–r†rŒrˆr™r£r¦r>r¢r¥r¨r­r¯r©r°r±r²Ú __classcell__rrr}rrös< !F  "     rc@s eZdZdZdZeZeZdZ dZ e dd„ƒZ e dd„ƒZ d ejd d fd d „Zd7d d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd8d d!„Zd9d"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Z d:dd.œd/d0„Z!d ifdd.œd1d2„Z"d3d4„Z#d5d6„Z$d S);rrhzHTTP/1.1r-rcCs t|tjƒS)zFTest whether a file-like object is a text or a binary stream. )rªÚioÚ TextIOBase)ÚstreamrrrÚ _is_textIO+szHTTPConnection._is_textIOcCsd|dur| ¡tvrdSdSt|dƒr*dSzt|ƒ}|jWStyLYn0t|tƒr`t|ƒSdS)aGet the content-length based on the body. If the body is None, we set Content-Length: 0 for methods that expect a body (RFC 7230, Section 3.3.2). We also set the Content-Length for any method if the body is a str or bytes-like object and not a file. Nrr‡) ÚupperÚ_METHODS_EXPECTING_BODYr«r„ÚnbytesÚ TypeErrorrªr^r/)ÚbodyrYÚmvrrrÚ_get_content_length1s    z"HTTPConnection._get_content_lengthNé cCsn||_||_||_d|_g|_d|_t|_d|_d|_ d|_ i|_ |  ||¡\|_ |_| |j ¡tj|_dSrz)ÚtimeoutÚsource_addressÚ blocksizerXÚ_bufferÚ_HTTPConnection__responseÚ_CS_IDLEÚ_HTTPConnection__staterNÚ _tunnel_hostÚ _tunnel_portÚ_tunnel_headersÚ _get_hostportÚhostÚportÚ_validate_hostÚsocketÚcreate_connectionÚ_create_connection)r3rËrÌrÀrÁrÂrrrr[Qs zHTTPConnection.__init__cCs<|jrtdƒ‚| ||¡\|_|_|r.||_n |j ¡dS)aDSet up host and port for HTTP CONNECT tunnelling. In a connection that uses HTTP CONNECT tunneling, the host passed to the constructor is used as a proxy server that relays all communication to the endpoint passed to `set_tunnel`. This done by sending an HTTP CONNECT request to the proxy server when the connection is established. This method must be called before the HTTP connection has been established. The headers argument should be a mapping of extra HTTP headers to send with the CONNECT request. z.Can't set up tunnel for established connectionN)rXÚ RuntimeErrorrÊrÇrÈrÉÚclear)r3rËrÌrBrrrÚ set_tunnelgs zHTTPConnection.set_tunnelcCsÈ|durÀ| d¡}| d¡}||kr’zt||dd…ƒ}WnFty‚||dd…dkrf|j}ntd||dd…ƒ‚Yn0|d|…}n|j}|rÀ|ddkrÀ|ddkrÀ|dd…}||fS) Nr,ú]r-r]znonnumeric port: '%s'rú[r¡)ÚrfindrerbÚ default_portr )r3rËrÌr’ÚjrrrrÊs    zHTTPConnection._get_hostportcCs ||_dSrz)rM)r3ÚlevelrrrÚset_debuglevel“szHTTPConnection.set_debuglevelc Cs d|j d¡|jf}|g}|j ¡D]$\}}| |›d|›d� d¡¡q&| d¡| d |¡¡~|j|j |j d�}|  ¡\}}}|t j jkr´| ¡td |›d | ¡›�ƒ‚|j td ¡} t| ƒtkrØtd ƒ‚| sà�q| d vrì�q|jdkr´td|  ¡ƒq´dS)NsCONNECT %s:%d HTTP/1.0 Úasciiz: ú r r<r©rYzTunnel connection failed: ú r-r:r;rri)rÇr!rÈrÉrpr2ÚsendrFÚresponse_classrXrNrfÚhttpÚ HTTPStatusZOKrxÚOSErrorrorAr>r?r/rrMr_rG) r3ÚconnectrBÚheaderr˜ÚresponserQrnÚmessager5rrrÚ_tunnel–s.ÿ    zHTTPConnection._tunnelc Csz| |j|jf|j|j¡|_z|j tjtj d¡Wn2t yf}z|j t j krR‚WYd}~n d}~00|j rv| ¡dS)z3Connect to the host and port specified in __init__.r-N)rÐrËrÌrÀrÁrXÚ setsockoptrÎÚ IPPROTO_TCPÚ TCP_NODELAYrãÚerrnoZ ENOPROTOOPTrÇrè©r3Úerrrrä¶sÿ zHTTPConnection.connectcCsZt|_z4|j}|r d|_| ¡W|j}|rVd|_| ¡n|j}|rTd|_| ¡0dS)z(Close the connection to the HTTP server.N)rÅrÆrXrxrÄ)r3rXrærrrrxÄs  ýzHTTPConnection.closecCs|jdur |jr| ¡ntƒ‚|jdkr8tdt|ƒƒt|dƒr¦|jdkrTtdƒ| |¡}|rt|jdkrttdƒ|  |j ¡}|s†q¢|r”|  d¡}|j  |¡qtdSz|j  |¡WnHt yþt|tjjƒrê|D]}|j  |¡qÖnt dt|ƒƒ‚Yn0dS) z¿Send `data' to the server. ``data`` can be a string object, a bytes object, an array object, a file-like object that supports a .read() method, or an iterable object. Nrzsend:r‡úsendIng a read()ableúencoding file using iso-8859-1rDz9data should be a bytes-like object or an iterable, got %r)rXÚ auto_openrärrMr_r`r«r·r‡rÂr!Úsendallr»rªÚ collectionsÚabcÚIterableÚtype)r3rr!Ú datablockÚdrrrrßÒs8         ÿzHTTPConnection.sendcCs|j |¡dS)zuAdd a line of output to the current request buffer. Assumes that the line does *not* end with \r\n. N)rÃr2)r3r‹rrrÚ_outputøszHTTPConnection._outputccs^|jdkrtdƒ| |¡}|r2|jdkr2tdƒ| |j¡}|sDqZ|rR| d¡}|Vq2dS)NrrïrðrD)rMr_r·r‡rÂr!)r3r€r!r÷rrrÚ_read_readableÿs    zHTTPConnection._read_readableFc Cs|j d¡d |j¡}|jdd…=| |¡|du�rt|dƒrN| |¡}nVz t|ƒWnBtyœz t|ƒ}Wn"ty–tdt |ƒƒ‚Yn0Yn0|f}|D]R}|sÄ|j dkr¨t dƒq¨|rð|j dkrðt |ƒd ›d � d ¡|d}| |¡q¨|�r|j dk�r| d ¡dS) z¸Send the currently buffered request and clear the buffer. Appends an extra \r\n to the buffer. A message_body may be specified, to be appended to the request. )rrr<Nr‡zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrhÚXrÜrÛs0 )rÃÚextendrFrßr«rúr„r»ÚiterrörMr_Ú _http_vsnr/r!)r3Ú message_bodyÚencode_chunkedrOÚchunksr rrrÚ _send_output s:           þ ÿ zHTTPConnection._send_outputc Csž|jr|j ¡rd|_|jtkr(t|_n t|jƒ‚| |¡||_|pHd}| |¡d|||j f}|  |  |¡¡|j dk�rš|�s†d}|  d¡r¦t|ƒ\}}}}}|räz| d¡}WntyÔ| d¡}Yn0| d |¡n¢|jrø|j} |j} n |j} |j} z|  d¡} Wnt�y0|  d¡} Yn0|  d ¡d k�rNd | d } | |jk�rh| d | ¡n|  d¡} | d d| | f¡|�sš| dd¡ndS)a`Send a request to the server. `method' specifies an HTTP request method, e.g. 'GET'. `url' specifies the object being requested, e.g. '/index.html'. `skip_host' if True does not add automatically a 'Host:' header `skip_accept_encoding' if True does not add automatically an 'Accept-Encoding:' header Nú/z%s %s %srhr]rárÛZidnaZHostr,ró[ó]z%s:%szAccept-EncodingÚidentity)rÄr�rÆrÅÚ_CS_REQ_STARTEDr Ú_validate_methodrNÚ_validate_pathÚ _http_vsn_strrùÚ_encode_requestrþrcrr!r"Ú putheaderrÇrÈrËrÌr�r×rG) r3rYrZÚ skip_hostÚskip_accept_encodingÚrequestÚnetlocÚnilZ netloc_encrËrÌZhost_encrrrÚ putrequestCsP             zHTTPConnection.putrequestcCs | d¡S)NrÛ)r!)r3rrrrr ÂszHTTPConnection._encode_requestcCs,t |¡}|r(td|›d| ¡›d�ƒ‚dS)z&Validate a method name for putrequest.z)method can't contain control characters. ú (found at least ú)N)Ú$_contains_disallowed_method_pchar_reÚsearchrbÚgroup)r3rYÚmatchrrrrÆs ÿÿzHTTPConnection._validate_methodcCs,t |¡}|r(td|›d| ¡›d�ƒ‚dS)zValidate a url for putrequest.ú&URL can't contain control characters. rrN©Ú!_contains_disallowed_url_pchar_rerr r)r3rZrrrrr Ïs   ÿzHTTPConnection._validate_pathcCs,t |¡}|r(td|›d| ¡›d�ƒ‚dS)z9Validate a host so it doesn't contain control characters.rrrNr)r3rËrrrrrÍ×s   ÿzHTTPConnection._validate_hostcGsÌ|jtkrtƒ‚t|dƒr$| d¡}t|ƒs:td|fƒ‚t|ƒ}t|ƒD]\\}}t|dƒrl| d¡||<nt |t ƒrˆt |ƒ d¡||<t ||ƒrJtd||fƒ‚qJd  |¡}|d|}| |¡dS) zkSend a request header line to the server. For example: h.putheader('Accept', 'text/html') r!rÛzInvalid header name %rr zInvalid header value %rs s: N)rÆrrr«r!Ú_is_legal_header_namerbr®Ú enumeraterªrer^Ú_is_illegal_header_valuerFrù)r3råÚvaluesr’Z one_valuer˜rrrr ßs"        zHTTPConnection.putheader©rcCs*|jtkrt|_ntƒ‚|j||d�dS)zòIndicate that the last header line has been sent to the server. This method sends the request to the server. The optional message_body argument can be used to pass a message body associated with the request. r N)rÆrÚ _CS_REQ_SENTrr)r3rÿrrrrÚ endheadersûs zHTTPConnection.endheaderscCs| |||||¡dS)z&Send a complete request to the server.N)Ú _send_request)r3rYrZr¼rBrrrrrszHTTPConnection.requestc Csütdd„|Dƒƒ}i}d|vr&d|d<d|vr6d|d<|j||fi|¤Žd|vr´d |vr¸d }| ||¡}|dur¢|dur²|jd kr�td |ƒd }| dd¡q¸| dt|ƒ¡nd }| ¡D]\} } | | | ¡qÀt|tƒrêt |dƒ}|j ||d�dS)Ncss|]}| ¡VqdSrz)r.)rÚkrrrÚ rz/HTTPConnection._send_request..rËr-r zaccept-encodingrrkrjFrzUnable to determine size of %rTzTransfer-EncodingrTzContent-Lengthr¼r ) Ú frozensetrr¾rMr_r r^rprªr*r") r3rYrZr¼rBrZ header_namesZskipsZcontent_lengthrtr˜rrrr# s0      zHTTPConnection._send_requestcCsÚ|jr|j ¡rd|_|jtks&|jr0t|jƒ‚|jdkrR|j|j|j|jd�}n|j|j|jd�}zZz |  ¡Wnt yŽ|  ¡‚Yn0|j t ksžJ‚t|_|j r´|  ¡n||_|WS|  ¡‚Yn0dS)a)Get the response from the server. If the HTTPConnection is in the correct state, returns an instance of HTTPResponse or of whatever object is returned by the response_class variable. If a request has not been sent or if a previous response has not be handled, ResponseNotReady is raised. If the HTTP response indicates that the connection should be closed, then it will be closed before the response is returned. When the connection is closed, the underlying socket is closed. NrrÝ)rÄr�rÆr!rrMràrXrNrvÚConnectionErrorrxrWrPrÅ)r3rærrrÚ getresponse;s0   ÿ   zHTTPConnection.getresponse)NN)NF)FF)N)%r7r8r9rþr rràÚ HTTP_PORTr×rñrMÚ staticmethodr·r¾rÎÚ_GLOBAL_DEFAULT_TIMEOUTr[rÓrÊrÚrèrärxrßrùrúrrr rr rÍr r"rr#r(rrrrr!sJ  ÿ   & 6ÿ   ÿ .rcsHeZdZdZeZdddejdfddddœ‡fdd„ Z‡fdd„Z ‡Z S) ÚHTTPSConnectionz(This class allows communication via SSL.Nr¿)ÚcontextÚcheck_hostnamerÂc sÜtt|ƒj||||| d�|dus2|dus2|durHddl} |  dtd¡||_||_|durtt  ¡}|j durtd|_ |j tj k} |durŽ|j }|rž| sžtdƒ‚|s¦|rÂ| ||¡|j durÂd|_ ||_|durØ||j_ dS)N)rÂrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.r\TzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)r{r,r[ÚwarningsÚwarnÚDeprecationWarningÚkey_fileÚ cert_fileÚsslZ_create_default_https_contextZpost_handshake_authZ verify_modeZ CERT_NONEr.rbZload_cert_chainÚ_context) r3rËrÌr2r3rÀrÁr-r.rÂr/Z will_verifyr}rrr[†s:þÿþ    zHTTPSConnection.__init__cs6tƒ ¡|jr|j}n|j}|jj|j|d�|_dS)z(Connect to a host on a given (SSL) port.)Úserver_hostnameN)r{rärÇrËr5Z wrap_socketrX)r3r6r}rrräªs  ÿzHTTPSConnection.connect) r7r8r9Ú__doc__Ú HTTPS_PORTr×rÎr+r[rär³rrr}rr,sþý$r,c@s eZdZdS)rN©r7r8r9rrrrr¹src@s eZdZdS)rNr9rrrrr¾src@s eZdZdS)r Nr9rrrrr Ásr c@seZdZdd„ZdS)rcCs|f|_||_dSrz)ÚargsrQ)r3rQrrrr[ÅszUnknownProtocol.__init__N©r7r8r9r[rrrrrÄsrc@s eZdZdS)rNr9rrrrrÉsrc@s eZdZdS)r Nr9rrrrr Ìsr c@s$eZdZddd„Zdd„ZejZdS)r NcCs|f|_||_||_dSrz)r:ÚpartialÚexpected)r3r<r=rrrr[ÐszIncompleteRead.__init__cCs2|jdurd|j}nd}d|jjt|jƒ|fS)Nz, %i more expectedr]z%s(%i bytes read%s))r=r~r7r/r<rírrrÚ__repr__Ôs    ÿzIncompleteRead.__repr__)N)r7r8r9r[r>r$Ú__str__rrrrr Ïs r c@s eZdZdS)r Nr9rrrrr Ýsr c@s eZdZdS)r Nr9rrrrr àsr c@s eZdZdS)rNr9rrrrrãsrc@s eZdZdS)rNr9rrrrræsrc@seZdZdd„ZdS)rcCs|s t|ƒ}|f|_||_dSrz)r`r:r5r”rrrr[êszBadStatusLine.__init__Nr;rrrrrésrc@seZdZdd„ZdS)rcCst |dt|f¡dS)Nz&got more than %d bytes when reading %s)rr[r?)r3Z line_typerrrr[ñsÿzLineTooLong.__init__Nr;rrrrrðsrc@seZdZdd„ZdS)rcOs(t |d¡tj|g|¢Ri|¤ŽdS)Nr])rr[ÚConnectionResetError)r3ÚposÚkwrrrr[ös zRemoteDisconnected.__init__Nr;rrrrrõsr)r)Er7Z email.parserrHZ email.messagerìrár´ÚrerÎÚcollections.abcróÚ urllib.parserÚ__all__r)r8rPrÅrr!ÚglobalsÚupdaterâÚ __members__rrrŸr?r@ÚcompileÚ fullmatchrrrrrrsr‘r¹r*rçZMessager+rCrJÚBufferedIOBaserrr4Ú ImportErrorr,r2Ú Exceptionrrr rrr r r r rrrrr@rrrrrrÚs~F         /] 8