%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/http/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/http/__pycache__/client.cpython-38.pyc

U

pa@sfdZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZeejjddejjDZdZdZed jZed!jZed"Z ed#Z!d$d%d&hZ"dBd(d)Z#Gd*d+d+ej$j%Z&d,d-Z'e&fd.d/Z(Gd0ddej)Z*Gd1ddZ+zddl,Z,Wne-k
r`YnXGd2d3d3e+Z.e/d3Gd4dde0Z1Gd5dde1Z2Gd6dde1Z3Gd7dde1Z4Gd8d	d	e1Z5Gd9d
d
e1Z6Gd:dde1Z7Gd;d
d
e1Z8Gd<dde8Z9Gd=dde8Z:Gd>dde8Z;Gd?dde1Z<Gd@dde1Z=GdAdde>e<Z?e1Z@dS)Ca
HTTP/1.1 client library

<intro stuff goes here>
<other stuff, too>

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           <response_class>
Req-started-unread-response    _CS_REQ_STARTED    <response_class>
Req-sent-unread-response       _CS_REQ_SENT       <response_class>
N)urlsplitHTTPResponseHTTPConnection
HTTPExceptionNotConnectedUnknownProtocolUnknownTransferEncodingUnimplementedFileModeIncompleteRead
InvalidURLImproperConnectionStateCannotSendRequestCannotSendHeaderResponseNotReady
BadStatusLineLineTooLongRemoteDisconnectederror	responsesPiZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}||jqS)phrase).0vrr'/usr/local/lib/python3.8/http/client.py
<dictcomp>jsrids[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTPUTdatac
Cshz|dWStk
rb}z8t|j|j|j|jd|||j|j|fdW5d}~XYnXdS)z<Call data.encode("latin-1") but show a better error message.latin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.N)encodeUnicodeEncodeErrorencodingobjectstartendtitle)rnameerrrrr_encodesr)c@seZdZddZdS)HTTPMessagecCsj|d}t|}g}d}|D]@}|d||krBd}n|ddsVd}|r$||q$|S)aFind all header lines matching a given header name.

        Look through the list of headers and find all lines matching a given
        header name (and their continuation lines).  A list of the lines is
        returned, without interpretation.  If the header does not occur, an
        empty list is returned.  If the header occurs multiple times, all
        occurrences are returned.  Case is not important in the header name.

        :rN)lowerlenkeysisspaceappend)selfr'nZlstZhitlinerrrgetallmatchingheaderss
z!HTTPMessage.getallmatchingheadersN)__name__
__module____qualname__r5rrrrr*sr*cCsXg}|td}t|tkr&td||t|tkrHtdt|dkrqTq|S)zReads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r,header linezgot more than %d headers

)readline_MAXLINEr.rr1_MAXHEADERSr)fpheadersr4rrr
_read_headerss
rCcCs,t|}d|d}tjj|d|S)aGParses only RFC2822 headers from a file pointer.

    email Parser wants to see strings rather than bytes.
    But a TextIOWrapper around self.rfile would buffer too many bytes
    from the stream, bytes which we later need to read as bytes.
    So we read the correct bytes here, as bytes, for email Parser
    to parse.

    r=
iso-8859-1)_class)rCjoindecodeemailparserZParserZparsestr)rArErBZhstringrrr
parse_headerss
rJcseZdZd@ddZddZddZd	d
ZddZfd
dZfddZ	ddZ
ddZdAddZddZ
ddZddZddZdd Zd!d"Zd#d$Zd%d&ZdBd(d)ZdCd*d+ZdDfd,d-	Zd.d/Zd0d1Zd2d3ZdEd4d5Zd6d7Zd8d9Zd:d;Zd<d=Zd>d?Z Z!S)FrrNcCsR|d|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)Nrb)makefilerA
debuglevel_methodrBmsg_UNKNOWNversionstatusreasonchunked
chunk_leftlength
will_close)r2sockrMmethodurlrrr__init__szHTTPResponse.__init__cCst|jtdd}t|tkr*td|jdkrBtdt||sNt	dz|
dd\}}}WnFtk
rz|
dd\}}d}Wntk
rd}YnXYnX|d	s|
t|z$t|}|d
ks|dkrt|Wntk
rt|YnX|||fS)Nr,rDzstatus linerzreply:z-Remote end closed connection without responsezHTTP/ri)strrAr>r?r.rrMprintreprrsplit
ValueError
startswith_close_connrint)r2r4rQrRrSrrr_read_statuss2

zHTTPResponse._read_statusc	Cs|jdk	rdS|\}}}|tkr&qHt|j}|jdkrDtd|~q||_|_|	|_
|dkrnd|_n|drd|_nt
|t|j|_|_|jdkr|jD]\}}td|d|q|jd	}|r|d
krd|_d|_nd|_||_d|_|jd
}|rb|jsbzt||_Wntk
rLd|_YnX|jdkrhd|_nd|_|tks|tksd|krdksn|jdkrd|_|js|js|jdkrd|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9
zHTTP/1.header:r+transfer-encodingrTTFcontent-lengthrHEAD)rBrfZCONTINUErCrArMr_coderRstriprSrQrcrrJrOitemsgetr-rTrU_check_closerWrVrerbZ
NO_CONTENTZNOT_MODIFIEDrN)	r2rQrRrSZskipped_headershdrvalZtr_encrVrrrbegin5sf









zHTTPResponse.begincCsv|jd}|jdkr.|r*d|kr*dSdS|jdr>dS|rRd|krRdS|jd}|rrd|krrdSdS)N
connectionrhcloseTFz
keep-alivezproxy-connection)rBrqrQr-)r2connZpconnrrrrr}s
zHTTPResponse._check_closecCs|j}d|_|dSN)rArw)r2rArrrrdszHTTPResponse._close_conncs$ztW5|jr|XdSry)rArdsuperrwr2	__class__rrrwszHTTPResponse.closecst|jr|jdSry)rzflushrAr{r|rrr~s
zHTTPResponse.flushcCsdS)zAlways returns TrueTrr{rrrreadableszHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)rAr{rrrisclosedszHTTPResponse.isclosedcCs|jdkrdS|jdkr$|dS|dk	rRt|}||}t|d|S|jr`|S|j	dkrv|j
}n6z||j	}Wntk
r|YnXd|_	||SdS)Nr=rmr)
rArNrd	bytearrayreadinto
memoryviewtobytesrT_readall_chunkedrVread
_safe_readr
)r2amtbr3srrrrs*



zHTTPResponse.readcCs|jdkrdS|jdkr$|dS|jr4||S|jdk	r^t||jkr^t|d|j}|j|}|s||r||n&|jdk	r|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.rr)r2rr3rrrrs$





zHTTPResponse.readintocCsr|jtd}t|tkr$td|d}|dkrB|d|}zt|dWStk
rl|YnXdS)Nr,z
chunk size;r)	rAr>r?r.rfindrerbrd)r2r4irrr_read_next_chunk_sizes
z"HTTPResponse._read_next_chunk_sizecCs:|jtd}t|tkr$td|s*q6|dkrq6qdS)Nr,ztrailer liner:)rAr>r?r.rr2r4rrr_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|dz|}Wntk
rDtdYnX|dkrb||d}||_|S)Nr\r=r)rUrrrbr
rrd)r2rUrrr_get_chunk_left s
zHTTPResponse._get_chunk_leftcCsp|jtkstg}z6|}|dkr&q>|||d|_qd|WStk
rjtd|YnXdSNrr=)	rTrPAssertionErrorrr1rrUrFr
)r2valuerUrrrr8szHTTPResponse._readall_chunkedcCs|jtkstd}t|}zv|}|dkr2|WSt||kr\||}|||_||WS|d|}||}||d}||7}d|_qWn(tk
rtt	|d|YnXdS)Nr)
rTrPrrrr._safe_readintorUr
bytes)r2rZtotal_bytesZmvbrUr3Ztemp_mvbrrrrFs$



zHTTPResponse._readinto_chunkedcCs.|j|}t||kr*t||t||S)aRead the number of bytes requested.

        This function should be used when <amt> 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.
        )rArr.r
)r2rrrrrr^szHTTPResponse._safe_readcCs:t|}|j|}||kr6tt|d||||S)z2Same as _safe_read, but for reading into a buffer.N)r.rArr
r)r2rrr3rrrrjs
zHTTPResponse._safe_readintocCs|jdks|jdkrdS|jr(||S|jdk	rJ|dksD||jkrJ|j}|j|}|sh|rh|n|jdk	r|jt|8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrmr=r)rArNrT_read1_chunkedrVread1rdr.)r2r3resultrrrrrs


zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(||S|j|S)Nrmr=)rArNrT
_peek_chunkedpeek)r2r3rrrrs

zHTTPResponse.peekcs|jdks|jdkrdS|jr*t|S|jdk	rL|dksF||jkrL|j}|j|}|sj|rj|n|jdk	r|jt|8_|S)Nrmr=r)rArNrTrzr>rVrdr.)r2limitrr|rrr>s

zHTTPResponse.readlinecCsd|}|dks|dkrdSd|kr0|ks6n|}|j|}|jt|8_|s`td|Sr)rrArrUr.r
)r2r3rUrrrrrszHTTPResponse._read1_chunkedcCsDz|}Wntk
r"YdSX|dkr0dS|j|d|S)Nr=)rr
rAr)r2r3rUrrrrszHTTPResponse._peek_chunkedcCs
|jSry)rAfilenor{rrrrszHTTPResponse.filenocCsF|jdkrt|j|p|}t|ts4t|ds8|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)r2r'defaultrBrrr	getheaders
zHTTPResponse.getheadercCs|jdkrtt|jS)z&Return list of (header, value) tuples.N)rBrlistrpr{rrr
getheaderss
zHTTPResponse.getheaderscCs|Sryrr{rrrrszHTTPResponse.__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{rrrinfoszHTTPResponse.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{rrrgeturls
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{rrrgetcodeszHTTPResponse.getcode)rNN)N)r)r)r)N)"r6r7r8r[rfrurrrdrwr~rrrrrrrrrrrrrr>rrrrrrrrr
__classcell__rrr|rrs<	
!H

 "

	

c@s
eZdZdZdZeZeZdZ	dZ
eddZeddZ
d	ejd	d
fddZd7d
dZddZddZddZddZddZddZddZddZd8d d!Zd9d"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Z d:dd.d/d0Z!d	ifdd.d1d2Z"d3d4Z#d5d6Z$d	S);rrhzHTTP/1.1r,rcCst|tjS)zFTest whether a file-like object is a text or a binary stream.
        )rio
TextIOBase)streamrrr
_is_textIOszHTTPConnection._is_textIOcCsf|dkr|tkrdSdSt|dr*dSzt|}|jWStk
rNYnXt|trbt|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_BODYrrnbytes	TypeErrorrr^r.)bodyrYmvrrr_get_content_lengths

z"HTTPConnection._get_content_lengthN cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|||\|_
|_||j
tj|_dSry)timeoutsource_address	blocksizerX_buffer_HTTPConnection__response_CS_IDLE_HTTPConnection__staterN_tunnel_host_tunnel_port_tunnel_headers
_get_hostporthostport_validate_hostsocketcreate_connection_create_connection)r2rrrrrrrrr[4szHTTPConnection.__init__cCs<|jrtd|||\|_|_|r.||_n
|jdS)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RuntimeErrorrrrrclear)r2rrrBrrr
set_tunnelJszHTTPConnection.set_tunnelcCs|dkr|d}|d}||krzt||dd}WnHtk
r||dddkrh|j}ntd||ddYnX|d|}n|j}|r|ddkr|ddkr|dd}||fS)	Nr+]r,r]znonnumeric port: '%s'r[r)rfindrerbdefault_portr)r2rrrjrrrrbs

zHTTPConnection._get_hostportcCs
||_dSry)rM)r2levelrrrset_debuglevelvszHTTPConnection.set_debuglevelcCsd|j|jf}|d}|||jD](\}}d||f}|d}||q.|d|j|j|jd}|	\}}	}
|	t
jjkr|
td|	|
f|jtd}t|tkrtd	|sq|d
krq|jdkrtd|qdS)
NzCONNECT %s:%d HTTP/1.0
asciiz%s: %s
rr;rYzTunnel connection failed: %d %sr,r9r:rri)rrr sendrrpresponse_classrXrNrfhttp
HTTPStatusZOKrwOSErrorrorAr>r?r.rrMr_rG)r2Zconnect_strZ
connect_bytesheaderrZ
header_strZheader_bytesresponserQrnmessager4rrr_tunnelys4




zHTTPConnection._tunnelcCsB||j|jf|j|j|_|jtjtj	d|j
r>|dS)z3Connect to the host and port specified in __init__.r,N)rrrrrrX
setsockoptrIPPROTO_TCPTCP_NODELAYrrr{rrrconnects
zHTTPConnection.connectcCsBt|_z|j}|r d|_|W5|j}|r<d|_|XdS)z(Close the connection to the HTTP server.N)rrrrwrX)r2rrXrrrrwszHTTPConnection.closecCs|jdkr |jr|nt|jdkr8tdt|t|dr|jdkrTtd||}|rt|jdkrttd|	|j
}|sq|r|d}|j|qtdSz|j|WnLt
k
rt|tjjr|D]}|j|qnt
dt|YnXdS)	zSend `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:rsendIng a read()ableencoding file using iso-8859-1rDz9data should be a bytes-like object or an iterable, got %r)rX	auto_openrrrMr_r`rrrrr sendallrrcollectionsabcIterabletype)r2rr 	datablockdrrrrs8






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)rr1)r2rrrr_outputszHTTPConnection._outputccs^|jdkrtd||}|r2|jdkr2td||j}|sDqZ|rR|d}|Vq2dS)NrrrrD)rMr_rrrr )r2rr rrrr_read_readables


zHTTPConnection._read_readableFcCs |jdd|j}|jdd=|||dk	rt|drN||}nZzt|WnFtk
rzt|}Wn$tk
rtdt	|YnXYnX|f}|D]R}|s|j
dkrtdq|r|jdkrt
|d	d
d|d}||q|r|jdkr|ddS)
zSend 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.
        )r=r=r;NrzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrhXz
rs0

)rextendrFrrrrriterrrMr_	_http_vsnr.r )r2message_bodyencode_chunkedrOchunkschunkrrr_send_outputs:



zHTTPConnection._send_outputcCs|jr|jrd|_|jtkr(t|_n
t|j||||_|pHd}||d|||j	f}|
|||jdkr|sd}|
drt|\}}}}}|rz|d}Wntk
r|d}YnX|d	|n|jr|j}	|j}
n|j}	|j}
z|	d}Wn tk
r4|	d}YnX|	d
dkrRd|d
}|
|jkrl|d	|n|d}|d	d||
f|s|ddndS)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]rrZidnaZHostr+r[]z%s:%szAccept-Encodingidentity)rrrr_CS_REQ_STARTEDr
_validate_methodrN_validate_path
_http_vsn_strr_encode_requestrrcrr r!	putheaderrrrrrrrG)r2rYrZ	skip_hostskip_accept_encodingrequestZnetlocnilZ
netloc_encrrZhost_encrrr
putrequest sP






zHTTPConnection.putrequestcCs
|dS)Nr)r )r2rrrrrszHTTPConnection._encode_requestcCs,t|}|r(td|d|ddS)z&Validate a method name for putrequest.z)method can't contain control characters.  (found at least )N)$_contains_disallowed_method_pchar_researchrbgroup)r2rYmatchrrrrs

zHTTPConnection._validate_methodcCs,t|}|r(td|d|ddS)zValidate a url for putrequest.&URL can't contain control characters. rrN!_contains_disallowed_url_pchar_rer	rr
)r2rZrrrrrs
zHTTPConnection._validate_pathcCs,t|}|r(td|d|ddS)z9Validate a host so it doesn't contain control characters.rrrNr
)r2rrrrrrs
zHTTPConnection._validate_hostcGs|jtkrtt|dr$|d}t|s:td|ft|}t|D]\\}}t|drl|d||<nt	|t
rt|d||<t||rJtd||fqJd
|}|d|}||dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        r rzInvalid header name %rrzInvalid header value %rs
	s: N)rrrrr _is_legal_header_namerbr	enumeraterrer^_is_illegal_header_valuerFr)r2rvaluesrZ	one_valuerrrrrs"





zHTTPConnection.putheaderrcCs*|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)r2rrrrr
endheaderss
zHTTPConnection.endheaderscCs||||||dS)z&Send a complete request to the server.N)
_send_request)r2rYrZrrBrrrrrszHTTPConnection.requestcCstdd|D}i}d|kr&d|d<d|kr6d|d<|j||f|d|krd	|krd
}|||}|dkr|dk	r|jdkrtd|d
}|ddq|dt|nd
}|D]\}	}
||	|
qt|trt	|d}|j
||ddS)Ncss|]}|VqdSry)r-)rkrrr	<genexpr>sz/HTTPConnection._send_request.<locals>.<genexpr>rr,rzaccept-encodingrrkrjFrzUnable to determine size of %rTzTransfer-EncodingrTzContent-Lengthrr)	frozensetrrrMr_rr^rprr)r)r2rYrZrrBrZheader_namesZskipsZcontent_lengthrsrrrrrs0	


zHTTPConnection._send_requestcCs|jr|jrd|_|jtks&|jr0t|j|jdkrR|j|j|j|jd}n|j|j|jd}z\z|	Wnt
k
r|YnX|jt
kstt|_|jr|n||_|WS|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.
        Nrr)rrrrrrMrrXrNruConnectionErrorrwrWrPrr)r2rrrrgetresponses0


zHTTPConnection.getresponse)NN)NF)FF)N)%r6r7r8rrrr	HTTP_PORTrrrMstaticmethodrrr_GLOBAL_DEFAULT_TIMEOUTr[rrrrrrwrrrrrrrrrrrrrrrrrrrsL



	&
6
	
.csHeZdZdZeZdddejdfddddfddZfddZ	Z
S)	HTTPSConnectionz(This class allows communication via SSL.Nr)contextcheck_hostnamercstt|j|||||	d|dk	s2|dk	s2|dk	rHddl}
|
dtd||_||_|dkrtt	}|j
dk	rtd|_
|jtjk}|dkr|j
}|r|std|s|r||||j
dk	rd|_
||_|dk	r||j_
dS)N)rrzTkey_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)rzrr[warningswarnDeprecationWarningkey_file	cert_filesslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONEr!rbZload_cert_chain_context)r2rrr%r&rrr r!rr"Zwill_verifyr|rrr[cs<

zHTTPSConnection.__init__cs6t|jr|j}n|j}|jj|j|d|_dS)z(Connect to a host on a given (SSL) port.)server_hostnameN)rzrrrr(Zwrap_socketrX)r2r)r|rrrs

zHTTPSConnection.connect)r6r7r8__doc__
HTTPS_PORTrrrr[rrrrr|rr\s$rc@seZdZdS)rNr6r7r8rrrrrsc@seZdZdS)rNr,rrrrrsc@seZdZdS)rNr,rrrrrsc@seZdZddZdS)rcCs|f|_||_dSry)argsrQ)r2rQrrrr[szUnknownProtocol.__init__Nr6r7r8r[rrrrrsc@seZdZdS)rNr,rrrrrsc@seZdZdS)r	Nr,rrrrr	sc@s$eZdZdddZddZejZdS)r
NcCs|f|_||_||_dSry)r-partialexpected)r2r/r0rrrr[szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j|fS)Nz, %i more expectedr]z%s(%i bytes read%s))r0r}r6r.r/)r2errr__repr__s
zIncompleteRead.__repr__)N)r6r7r8r[r2r#__str__rrrrr
s
c@seZdZdS)rNr,rrrrrsc@seZdZdS)r
Nr,rrrrr
sc@seZdZdS)rNr,rrrrrsc@seZdZdS)rNr,rrrrrsc@seZdZddZdS)rcCs|st|}|f|_||_dSry)r`r-r4rrrrr[szBadStatusLine.__init__Nr.rrrrrsc@seZdZddZdS)rcCst|dt|fdS)Nz&got more than %d bytes when reading %s)rr[r?)r2Z	line_typerrrr[szLineTooLong.__init__Nr.rrrrrsc@seZdZddZdS)rcOs"t|dtj|f||dS)Nr])rr[ConnectionResetError)r2poskwrrrr[szRemoteDisconnected.__init__Nr.rrrrrs)r)Ar*Zemail.parserrHZ
email.messagerrrercollections.abcrZurllib.parser__all__rr+rPrrrglobalsupdater__members__rrr?r@compile	fullmatchrr	rrrrr)rZMessager*rCrJBufferedIOBaserrr'ImportErrorrr1	Exceptionrrrrrr	r
rr
rrrrr4rrrrrr<module>sF



W8


Zerion Mini Shell 1.0