/usr/lib64/python3.9/http/__pycache__
NameSizeModeActions
client.cpython-39.opt-1.pyc354660644editdlrm
client.cpython-39.opt-2.pyc259380644editdlrm
client.cpython-39.pyc355390644editdlrm
cookiejar.cpython-39.opt-1.pyc533480644editdlrm
cookiejar.cpython-39.opt-2.pyc377110644editdlrm
cookiejar.cpython-39.pyc535050644editdlrm
cookies.cpython-39.opt-1.pyc150290644editdlrm
cookies.cpython-39.opt-2.pyc106320644editdlrm
cookies.cpython-39.pyc150610644editdlrm
server.cpython-39.opt-1.pyc350320644editdlrm
server.cpython-39.opt-2.pyc229860644editdlrm
server.cpython-39.pyc350320644editdlrm
__init__.cpython-39.opt-1.pyc64130644editdlrm
__init__.cpython-39.opt-2.pyc55540644editdlrm
__init__.cpython-39.pyc64130644editdlrm
Edit: /usr/lib64/python3.9/http/__pycache__/client.cpython-39.opt-1.pyc (35466B)
a ´iåÜã@sNdZddlZddlZddlZddlZddlZddlZddlZddl 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#hd£Z$d@dd„Z%Gdd„dej&j'ƒZ(dd„Z)e(fdd„Z*Gdd„dej+ƒZ,Gd d!„d!ƒZ-z ddl.Z.Wne/�yHYn0Gd"d#„d#e-ƒZ0e  1d#¡Gd$d%„d%e2ƒZ3Gd&d'„d'e3ƒZ4Gd(d)„d)e3ƒZ5Gd*d+„d+e3ƒZ6Gd,d-„d-e3ƒZ7Gd.d/„d/e3ƒZ8Gd0d1„d1e3ƒZ9Gd2d3„d3e3ƒZ:Gd4d5„d5e:ƒZ;Gd6d7„d7e:ƒZGdd?„d?e@e>ƒZAe3ZBdS)Aa¢ 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[-]>ÚPUTZPOSTZPATCHÚ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 ¡}|�r`|j�s`zt|ƒ|_Wnt�yJd|_Yn0|jdk�rfd|_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-lengthréÈÚHEAD)rBrfZCONTINUErCrArMr_ÚcoderRÚstriprSrQrcrrJrOÚitemsÚgetr.rTrUÚ _check_closerWrVrerbZ NO_CONTENTZ NOT_MODIFIEDrN) r3rQrRrSZskipped_headersÚhdrÚvalZtr_encrVrrrÚbegin9sd             ÿ ÿ þÿþ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)rArw)r3rArrrrdžszHTTPResponse._close_conncs2ztƒ ¡W|jr.| ¡n|jr,| ¡0dSry)ÚsuperrwrArd©r3©Ú __class__rrrw£s   ÿzHTTPResponse.closecstƒ ¡|jr|j ¡dSry)rzÚ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.readintocCsp|j td¡}t|ƒtkr$tdƒ‚| d¡}|dkrB|d|…}z t|dƒWStyj| ¡‚Yn0dS)Nr-z chunk sizeó;ré) rAr>r?r/rÚfindrerbrd)r3r5ÚirrrÚ_read_next_chunk_sizes     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_leftcCs`g}z6| ¡}|durq0| | |¡¡d|_qd |¡WStyZtd |¡ƒ‚Yn0dS©Nrr)r“r2r‡rUrFr )r3ÚvaluerUrrrr…<s  zHTTPResponse._readall_chunkedcCs®d}t|ƒ}zv| ¡}|dur$|WSt|ƒ|krN| |¡}|||_||WS|d|…}| |¡}||d…}||7}d|_qWn&ty¨tt|d|…ƒƒ‚Yn0dS)Nr)rƒr“r/Ú_safe_readintorUr Úbytes)r3r‰Ú total_bytesÚmvbrUr4Útemp_mvbrrrr‹Js"         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‡bs 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–ys      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)rArNrTrzr>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 ¡Sry)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|Sryrr{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[rfrurrrdrwr~rr€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< !H  "     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_length+s    z"HTTPConnection._get_content_lengthNé cCsn||_||_||_d|_g|_d|_t|_d|_d|_ d|_ i|_ |  ||¡\|_ |_| |j ¡tj|_dSry)Ú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[Ks 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_tunnelas 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Çys    zHTTPConnection._get_hostportcCs ||_dSry)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Ú HTTPStatusZOKrwÚ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ÃrXrwrÁ)r3rXrãrrrrw¾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!)r3rr!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_outputs:           þ ÿ 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Ú putrequest=sP             zHTTPConnection.putrequestcCs | d¡S)NrØ)r!)r3r rrrr¼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©rýcCs*|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. rN)rÃrÚ _CS_REQ_SENTrrÿ)r3rürýrrrÚ endheadersõs zHTTPConnection.endheaderscCs| |||||¡dS)z&Send a complete request to the server.N)Ú _send_request)r3rYrZr¹rBrýrrrr szHTTPConnection.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|]}| ¡VqdSry)r.)rÚkrrrÚ rz/HTTPConnection._send_request..rÈr-r zaccept-encodingr rkrjFrzUnable to determine size of %rTzTransfer-EncodingrTzContent-Lengthr¹r) Ú frozensetrr»rMr_r r^rpr§r*r) r3rYrZr¹rBrýZ header_namesZskipsZcontent_lengthrsr•rrrr s0      zHTTPConnection._send_requestcCsÌ|jr|j ¡rd|_|jtks&|jr0t|jƒ‚|jdkrR|j|j|j|jd�}n|j|j|jd�}zLz |  ¡Wnt yŽ|  ¡‚Yn0t |_|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ÃrrrMrÝrXrNruÚConnectionErrorrwrÂrW)r3rãrrrÚ getresponse5s.   ÿ   zHTTPConnection.getresponse)NN)NF)FF)N)%r7r8r9rûrrrÝÚ HTTP_PORTrÔrîrMÚ staticmethodr´r»rËÚ_GLOBAL_DEFAULT_TIMEOUTr[rÐrÇr×rårárwrÜrör÷rÿrrrrrÊr rr r r%rrrrrsJ  ÿ   & 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)rzr)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Ér/r0r½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)rzrárÄrÈr2Z wrap_socketrX)r3r3r|rrrá¤s  ÿzHTTPSConnection.connect) r7r8r9Ú__doc__Ú HTTPS_PORTrÔrËr(r[rár°rrr|rr)ysþý$r)c@s eZdZdS)rN©r7r8r9rrrrr³src@s eZdZdS)rNr6rrrrr¸src@s eZdZdS)r Nr6rrrrr »sr c@seZdZdd„ZdS)rcCs|f|_||_dSry)ÚargsrQ)r3rQrrrr[¿szUnknownProtocol.__init__N©r7r8r9r[rrrrr¾src@s eZdZdS)rNr6rrrrrÃsrc@s eZdZdS)r Nr6rrrrr Æsr c@s$eZdZddd„Zdd„ZejZdS)r NcCs|f|_||_||_dSry)r7ÚpartialÚexpected)r3r9r:rrrr[ÊszIncompleteRead.__init__cCs2|jdurd|j}nd}d|jjt|jƒ|fS)Nz, %i more expectedr]z%s(%i bytes read%s))r:r}r7r/r9rêrrrÚ__repr__Îs    ÿzIncompleteRead.__repr__)N)r7r8r9r[r;r$Ú__str__rrrrr És r c@s eZdZdS)r Nr6rrrrr ×sr c@s eZdZdS)r Nr6rrrrr Úsr c@s eZdZdS)rNr6rrrrrÝsrc@s eZdZdS)rNr6rrrrràsrc@seZdZdd„ZdS)rcCs|s t|ƒ}|f|_||_dSry)r`r7r5r‘rrrr[äszBadStatusLine.__init__Nr8rrrrrãsrc@seZdZdd„ZdS)rcCst |dt|f¡dS)Nz&got more than %d bytes when reading %s)rr[r?)r3Z line_typerrrr[ësÿzLineTooLong.__init__Nr8rrrrrêsrc@seZdZdd„ZdS)rcOs(t |d¡tj|g|¢Ri|¤ŽdS)Nr])rr[ÚConnectionResetError)r3ÚposÚkwrrrr[ðs zRemoteDisconnected.__init__Nr8rrrrrïsr)r)Cr4Z email.parserrHZ email.messagerérÞr±ÚrerËÚcollections.abcrðÚ urllib.parserÚ__all__r&r5rPrÂrrÚglobalsÚupdaterßÚ __members__rrrœr?r@ÚcompileÚ fullmatchrrrrrr¶r*räZMessager+rCrJÚBufferedIOBaserrr1Ú ImportErrorr)r2Ú Exceptionrrr rrr r r r rrrrr=rrrrrrÚszF       .] 8