PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` 3 TSe@s`dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z dddddd d d d d ddddddddgZ dZ dZdZdZdZdZejejjddejjjDZdZdZd Zejd!jZejd"jZ ejd#Z!d$d%d&hZ"d@d(d)Z#Gd*d+d+ej$j%Z&e&fd,d-Z'Gd.ddej(Z)Gd/ddZ*y ddl+Z+Wne,k rZYnXGd0d1d1e*Z-e j.d1Gd2dde/Z0Gd3dde0Z1Gd4d d e0Z2Gd5dde0Z3Gd6d d e0Z4Gd7d d e0Z5Gd8d d e0Z6Gd9d d e0Z7Gd:dde7Z8Gd;dde7Z9Gddde0Ze0Z?dS)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 HTTPResponseHTTPConnection HTTPException NotConnectedUnknownProtocolUnknownTransferEncodingUnimplementedFileModeIncompleteRead InvalidURLImproperConnectionStateCannotSendRequestCannotSendHeaderResponseNotReady BadStatusLine LineTooLongRemoteDisconnectederror responsesPiZUNKNOWNZIdlezRequest-startedz Request-sentcCsi|] }|j|qS)phrase).0vrr/usr/lib64/python3.6/client.py ksriids[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]ZPATCHZPOSTZPUTdatacCsfy |jdStk r`}z:t|j|j|j|jd|j||j|j|fdWYdd}~XnXdS)zd?Z Z!S)IrrNcCsR|jd|_||_||_d|_|_t|_t|_t|_ t|_ t|_ t|_ t|_ dS)Nrb)makefilerB debuglevel_methodrCmsg_UNKNOWNversionstatusreasonchunked chunk_leftlength will_close)r0sockrGmethodurlrrr__init__s  zHTTPResponse.__init__cCst|jjtdd}t|tkr*td|jdkrBtdt||sNt dy|j dd\}}}WnFt k ry|j dd\}}d}Wnt k rd}YnXYnX|j d s|j t|y$t|}|d ks|d krt|Wnt k rt|YnX|||fS) Nr*z iso-8859-1z status linerzreply:z-Remote end closed connection without responsezHTTP/ri)strrBr;r<r,rrGprintreprrsplit ValueError startswith _close_connrint)r0r2rKrLrMrrr _read_status s2    zHTTPResponse._read_statusc Cs|jdk rdSxh|j\}}}|tkr(PxJ|jjtd}t|tkrNtd|j}|s\P|j dkr*t d|q*WqW||_ |_ |j|_ |dkrd|_n|jdrd |_nt|t|j|_|_|j dkrx&|jD]}t d|d |jj|qW|jjd }|r,|jd kr,d |_d|_nd|_|j|_d|_|jjd}|jjd }|r|j ryt||_Wntk rd|_YnX|jdkrd|_nd|_|tks|tksd|kodkns|jdkrd|_|j r|j r|jdkrd |_dS)Nr*z header linerzheader:HTTP/1.0HTTP/0.9 zHTTP/1. r)ztransfer-encodingrNTFzcontent-lengthrHEAD)rarb)rCr`ZCONTINUErBr;r<r,rstriprGrYcoderLrMrKr]rrDrIgetr+rNrO _check_closerQrPr_r\Z NO_CONTENTZ NOT_MODIFIEDrH)r0rKrLrMskiphdrZtr_encrPrrrbegin,sf                  zHTTPResponse.begincCs|jjd}|jdkr:|jjd}|r6d|jkr6dSdS|jjdrJdS|r^d|jkr^dS|jjd}|r~d|jkr~dSdS)NZ connectionrdcloseTFz keep-alivezproxy-connection)rCrirKr+)r0ZconnZpconnrrrrj|s     zHTTPResponse._check_closecCs|j}d|_|jdS)N)rBrn)r0rBrrrr^szHTTPResponse._close_connc s$ztjWd|jr|jXdS)N)superrnrBr^)r0) __class__rrrnszHTTPResponse.closecstj|jr|jjdS)N)roflushrB)r0)rprrrqs zHTTPResponse.flushcCsdS)zAlways returns TrueTr)r0rrrreadableszHTTPResponse.readablecCs |jdkS)z!True if the connection is closed.N)rB)r0rrrisclosedszHTTPResponse.isclosedc Cs|jdkrdS|jdkr$|jdS|dk rRt|}|j|}t|d|jS|jr`|jS|j dkrv|jj }n6y|j |j }Wnt k r|jYnXd|_ |j|SdS)Nr9rfr) rBrHr^ bytearrayreadinto memoryviewtobytesrN_readall_chunkedrPread _safe_readr )r0amtbr1srrrrys*     zHTTPResponse.readcCs|jdkrdS|jdkr$|jdS|jr4|j|S|jdk r^t||jkr^t|d|j}|jj|}| r~|r~|jn&|jdk r|j|8_|js|j|S)z^Read up to len(b) bytes into bytearray b and return the number of bytes read. Nrrf) rBrHr^rN_readinto_chunkedrPr,rvru)r0r|r1rrrrus$        zHTTPResponse.readintoc Csp|jjtd}t|tkr$td|jd}|dkrB|d|}y t|dStk rj|jYnXdS)Nr*z chunk size;r) rBr;r<r,rfindr_r\r^)r0r2irrr_read_next_chunk_sizes    z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd}t|tkr&td|s,P|dkrPqWdS)Nr*z trailer line r8r9)rr8r9)rBr;r<r,r)r0r2rrr_read_and_discard_trailers z&HTTPResponse._read_and_discard_trailerc Csl|j}|sh|dk r|jdy |j}Wntk rDtdYnX|dkrb|j|jd}||_|S)NrVr9r)rOrzrr\r rr^)r0rOrrr_get_chunk_left s  zHTTPResponse._get_chunk_leftc Csr|jtkstg}y8x,|j}|dkr(P|j|j|d|_qWdj|Stk rltdj|YnXdS)Nrr9) rNrJAssertionErrorrr/rzrOr>r )r0valuerOrrrrx8s  zHTTPResponse._readall_chunkedc Cs|jtkstd}t|}yvxp|j}|dkr2|St||krZ|j|}|||_||S|d|}|j|}||d}||7}d|_qWWn(tk rtt |d|YnXdS)Nr) rNrJrrvrr,_safe_readintorOr bytes)r0r| total_bytesmvbrOr1temp_mvbrrrr~Fs&      zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jjt|t}|s4tdj|||j||t|8}qWdj|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. rr9)rBrymin MAXAMOUNTr r>r/r,)r0r{r}chunkrrrrz^s  zHTTPResponse._safe_readcCsd}t|}xt|t|krtt|kr@|dt}|jj|}n |jj|}|sjtt|d|t|||d}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)rvr,rrBrur r)r0r|rrrr1rrrrus     zHTTPResponse._safe_readintor*c Cs|jdks|jdkrdS|jr(|j|S|jdk rJ|dksD||jkrJ|j}y|jj|}Wn*tk r|dkrt|jjd}YnX| r|r|jn|jdk r|jt|8_|S)zvRead with at most one underlying system call. If at least one byte is buffered, return that instead. Nrfr9rrii@) rBrHrN_read1_chunkedrPread1r\r^r,)r0r1resultrrrrs"    zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|S|jj|S)Nrfr9)rBrHrN _peek_chunkedpeek)r0r1rrrrs  zHTTPResponse.peekcs|jdks|jdkrdS|jr*tj|S|jdk rL|dksF||jkrL|j}|jj|}| rl|rl|jn|jdk r|jt|8_|S)Nrfr9r)rBrHrNror;rPr^r,)r0limitr)rprrr;s     zHTTPResponse.readlinecCsf|j}|dks|dkrdSd|ko.|kns8|}|jj|}|jt|8_|sbtd|S)Nrr9)rrBrrOr,r )r0r1rOryrrrrs zHTTPResponse._read1_chunkedc CsBy |j}Wntk r dSX|dkr.dS|jj|d|S)Nr9)rr rBr)r0r1rOrrrrs zHTTPResponse._peek_chunkedcCs |jjS)N)rBfileno)r0rrrrszHTTPResponse.filenocCsH|jdkrt|jj|p|}t|ts6t|d r:|Sdj|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, )rCrZget_all isinstancerXhasattrr>)r0r%defaultrCrrr getheaders zHTTPResponse.getheadercCs|jdkrtt|jjS)z&Return list of (header, value) tuples.N)rCrlistitems)r0rrr getheaderss zHTTPResponse.getheaderscCs|S)Nr)r0rrrrszHTTPResponse.__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. )rC)r0rrrinfoszHTTPResponse.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. )rT)r0rrrgeturl s zHTTPResponse.geturlcCs|jS)zuReturn the HTTP status code that was sent with the response, or None if the URL is not an HTTP URL. )rL)r0rrrgetcodeszHTTPResponse.getcode)rNN)N)rr)rr)r)N)"r4r5r6rUr`rmrjr^rnrqrrrsryrurrrrxr~rzrrrr;rrrrrrrrr __classcell__rr)rprrs< !P  "     c@seZdZdZdZeZeZdZ dZ e ddZ e ddZ d ejd fd d Zd.d d ZddZddZddZddZddZddZddZddZd/dd Zd0d!d"Zd#d$Zd1dd%d&d'Zd ifdd%d(d)Zd*d+Zd,d-Z d S)2rrdzHTTP/1.1r*rcCs t|tjS)zFTest whether a file-like object is a text or a binary stream. )rio TextIOBase)streamrrr _is_textIO(szHTTPConnection._is_textIOc Csd|dkr|jtkrdSdSt|dr*dSyt|}|jStk rLYnXt|tr`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. Nrry) upper_METHODS_EXPECTING_BODYrrvnbytes TypeErrorrrXr,)bodyrSZmvrrr_get_content_length.s   z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_ i|_ |j ||\|_ |_ tj|_dS)N)timeoutsource_addressrR_buffer_HTTPConnection__response_CS_IDLE_HTTPConnection__staterH _tunnel_host _tunnel_port_tunnel_headers _get_hostporthostportsocketZcreate_connection_create_connection)r0rrrrrrrrUNszHTTPConnection.__init__cCs<|jrtd|j||\|_|_|r.||_n |jjdS)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 HTML 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)rR RuntimeErrorrrrrclear)r0rrrCrrr set_tunnelas zHTTPConnection.set_tunnelc Cs|dkr|jd}|jd}||kryt||dd}WnHtk r||dddkrh|j}ntd||ddYnX|d|}n|j}|r|ddkr|ddkr|dd }||fS) Nr)]r*rWznonnumeric port: '%s'r[rr)rfindr_r\ default_portr )r0rrrjrrrrys   zHTTPConnection._get_hostportcCs ||_dS)N)rG)r0levelrrrset_debuglevelszHTTPConnection.set_debuglevelc Csd|j|jf}|jd}|j|x6|jjD](\}}d||f}|jd}|j|q0W|jd|j|j|jd}|j \}} } | t j j kr|j td| | jfxP|jjtd} t| tkrtd | sP| dkrP|jd krtd | jqWdS)NzCONNECT %s:%d HTTP/1.0 asciiz%s: %s zlatin-1 )rSzTunnel connection failed: %d %sr*z header liner8r9rzheader:)rr8r9)rrrsendrrresponse_classrRrHr`http HTTPStatusZOKrnOSErrorrgrBr;r<r,rrGrYr?) r0Z connect_strZ connect_bytesheaderrZ header_strZ header_bytesresponserKrhmessager2rrr_tunnels2         zHTTPConnection._tunnelcCsB|j|j|jf|j|j|_|jjtjtj d|j r>|j dS)z3Connect to the host and port specified in __init__.r*N) rrrrrrRZ setsockoptrZ IPPROTO_TCPZ TCP_NODELAYrr)r0rrrconnects zHTTPConnection.connectc CsBt|_z|j}|r d|_|jWd|j}|rrrrrvriterrrGrY _http_vsnr,r)r0 message_bodyencode_chunkedrIZchunksrrrr _send_outputs4           zHTTPConnection._send_outputc Cs|jr|jjrd|_|jtkr(t|_n t|j||_|s@d}tj|}|rht d|d|j dd|||j f}|j |j d|jdkr|sd }|jd rt|\}}}}}|ry|j d} Wntk r|j d } YnX|jd | n|jr|j} |j} n |j} |j} y| j d} Wn tk rJ| j d } YnX| jd dkrhd| d} | |jkr|jd | n| jd} |jd d| | f|s|jddndS)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&URL can't contain control characters. z (found at least )z%s %s %srrdrWrZidnaZHostr)r[]z%s:%szAccept-EncodingZidentity)rrsrr_CS_REQ_STARTEDr rH!_contains_disallowed_url_pchar_researchr group _http_vsn_strrrrr]rr putheaderrrrrrrr?) r0rSrT skip_hostskip_accept_encodingmatchrequestZnetlocZnilZ netloc_encrrZhost_encrrr putrequest9sT           zHTTPConnection.putrequestcGs|jtkrtt|dr$|jd}t|s:td|ft|}xht|D]\\}}t|drn|jd||<nt |t rt |jd||<t ||rLtd||fqLWdj |}|d|}|j|dS) zkSend a request header line to the server. For example: h.putheader('Accept', 'text/html') rrzInvalid header name %rzlatin-1zInvalid header value %rs s: N)rrrrr_is_legal_header_namer\r enumeraterr_rX_is_illegal_header_valuer>r)r0rvaluesrZ one_valuerrrrrs"        zHTTPConnection.putheader)rcCs*|jtkrt|_nt|j||ddS)zIndicate 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)rr _CS_REQ_SENTrr)r0rrrrr endheaderss zHTTPConnection.endheaderscCs|j|||||dS)z&Send a complete request to the server.N) _send_request)r0rSrTrrCrrrrrszHTTPConnection.requestc Cstdd|D}i}d|kr&d|d<d|kr6d|d<|j||f|d|krd |krd }|j||}|dkr|dk r|jd krtd |d }|jddq|jdt|nd }x |jD]\} } |j| | qWt|trt |d}|j ||ddS)Ncss|]}|jVqdS)N)r+)rkrrr sz/HTTPConnection._send_request..rr*rzaccept-encodingrzcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrNzContent-Lengthr)r) frozensetrrrGrYrrXrrr'r) r0rSrTrrCrZ header_namesZskipsZcontent_lengthrlrrrrrs0      zHTTPConnection._send_requestcCs|jr|jjrd|_|jtks&|jr0t|j|jdkrR|j|j|j|jd}n|j|j|jd}yZy |j Wnt k r|j YnX|j t kstt|_|j r|j n||_|S|j YnXdS)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. Nr)rS)rrsrrrrGrrRrHrmConnectionErrorrnrQrJrr)r0rrrr getresponses.      zHTTPConnection.getresponse)NN)NF)FF)N)!r4r5r6rrrr HTTP_PORTrrrG staticmethodrrr_GLOBAL_DEFAULT_TIMEOUTrUrrrrrrnrrrrrrrrrrrrrrrs:     ' 6  .csFeZdZdZeZdddejdfdddfdd ZfddZ Z S)HTTPSConnectionz(This class allows communication via SSL.N)contextcheck_hostnamec stt|j|||||dk s.|dk s.|dk rDddl} | jdtd||_||_|dkr`tj }|j tj k} |dkrz|j }|r| rt d|s|r|j||||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rVzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrUwarningswarnDeprecationWarningkey_file cert_filesslZ_create_default_https_contextZ verify_modeZ CERT_NONErr\Zload_cert_chain_context_check_hostname) r0rrrrrrrrrZ will_verify)rprrrUas(   zHTTPSConnection.__init__c stj|jr|j}n|j}|jj|j|d|_|jj r|jryt j |jj |Wn.t k r|jj tj|jjYnXdS)z(Connect to a host on a given (SSL) port.)server_hostnameN)rorrrr Z wrap_socketrRrr r Zmatch_hostnameZ getpeercert ExceptionZshutdownrZ SHUT_RDWRrn)r0r )rprrr|s    zHTTPSConnection.connect) r4r5r6__doc__ HTTPS_PORTrrrrUrrrr)rprrZsrc@s eZdZdS)rN)r4r5r6rrrrrsc@s eZdZdS)rN)r4r5r6rrrrrsc@s eZdZdS)r N)r4r5r6rrrrr sc@seZdZddZdS)rcCs|f|_||_dS)N)argsrK)r0rKrrrrUszUnknownProtocol.__init__N)r4r5r6rUrrrrrsc@s eZdZdS)rN)r4r5r6rrrrrsc@s eZdZdS)r N)r4r5r6rrrrr sc@s&eZdZdddZddZddZdS) r NcCs|f|_||_||_dS)N)rpartialexpected)r0rrrrrrUszIncompleteRead.__init__cCs2|jdk rd|j}nd}d|jjt|j|fS)Nz, %i more expectedrWz%s(%i bytes read%s))rrpr4r,r)r0errr__repr__s   zIncompleteRead.__repr__cCst|S)N)rZ)r0rrr__str__szIncompleteRead.__str__)N)r4r5r6rUrrrrrrr s c@s eZdZdS)r N)r4r5r6rrrrr sc@s eZdZdS)r N)r4r5r6rrrrr sc@s eZdZdS)rN)r4r5r6rrrrrsc@s eZdZdS)rN)r4r5r6rrrrrsc@seZdZddZdS)rcCs|s t|}|f|_||_dS)N)rZrr2)r0r2rrrrUszBadStatusLine.__init__N)r4r5r6rUrrrrrsc@seZdZddZdS)rcCstj|dt|fdS)Nz&got more than %d bytes when reading %s)rrUr<)r0Z line_typerrrrUszLineTooLong.__init__N)r4r5r6rUrrrrrsc@seZdZddZdS)rcOs"tj|dtj|f||dS)NrW)rrUConnectionResetError)r0poskwrrrrUs zRemoteDisconnected.__init__N)r4r5r6rUrrrrrs)r)@rZ email.parserr@Z email.messagerrosrerrZ urllib.parser__all__rrrJrrrglobalsupdater __members__rrrr<r=compile fullmatchrrrrrr'rZMessager(rDBufferedIOBaserrr  ImportErrorrr/r rrr rrr r r r rrrrrrrrrrrEs       >; 6