• File: client.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/http/__pycache__/client.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 35.01 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Lj@sjdZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZeejjddejjDZdZdZd Zed!jZed"jZ ed#Z!ed$Z"d%d&d'hZ#dCd)d*Z$Gd+d,d,ej%j&Z'd-d.Z(e'fd/d0Z)Gd1ddej*Z+Gd2ddZ,yddl-Z-Wne.k
rdYnXGd3d4d4e,Z/e0d4Gd5dde1Z2Gd6dde2Z3Gd7dde2Z4Gd8dde2Z5Gd9d	d	e2Z6Gd:d
d
e2Z7Gd;dde2Z8Gd<d
d
e2Z9Gd=dde9Z:Gd>dde9Z;Gd?dde9Z<Gd@dde2Z=GdAdde2Z>GdBdde?e=Z@e2ZAdS)Da
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|]}|j|qS)phrase).0vrr0/opt/alt/python37/lib64/python3.7/http/client.py
<dictcomp>jsriids[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUTdatac
Csfy
|dStk
r`}z8t|j|j|j|jd|||j|j|fdWdd}~XYnXdS)z<Call data.encode("latin-1") but show a better error message.zlatin-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)HTTPMessagecCsn|d}t|}g}d}xL|D]@}|d||krDd}n|ddsXd}|r&||q&W|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__r3rrrrr(sr(cCs\g}xR|td}t|tkr(td||t|tkrJtdt|dkrPqW|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*zheader linezgot more than %d headers)s

)readline_MAXLINEr,rr/_MAXHEADERSr)fpheadersr2rrr
_read_headerss
r>cCs,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.

    r8z
iso-8859-1)_class)r>joindecodeemailparserZParserZparsestr)r<r?r=Zhstringrrr
parse_headerss
rDcseZdZd@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)Zmakefiler<
debuglevel_methodr=msg_UNKNOWNversionstatusreasonchunked
chunk_leftlength
will_close)r0sockrFmethodurlrrr__init__szHTTPResponse.__init__cCst|jtdd}t|tkr*td|jdkrBtdt||sNt	dy|
dd\}}}WnFtk
ry|
dd\}}d}Wntk
rd}YnXYnX|d	s|
t|y$t|}|d
ks|dkrt|Wntk
rt|YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without responsezHTTP/ri)strr<r9r:r,rrFprintreprrsplit
ValueError
startswith_close_connrint)r0r2rJrKrLrrr_read_statuss2

zHTTPResponse._read_statusc	Cs|jdk	rdSx<|\}}}|tkr(Pt|j}|jdkrFtd|~qW||_|_|	|_
|dkrrd|_n|drd|_nt
|t|j|_|_|jdkrx&|jD]\}}td|d|qW|jd	}|r|d
krd|_d|_nd|_||_d|_|jd
}|jd	}|rv|jsvyt||_Wntk
r`d|_YnX|jdkr|d|_nd|_|tks|tksd|krdksn|jdkrd|_|js|js|jdkrd|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9
zHTTP/1.zheader:r)ztransfer-encodingrMTFzcontent-lengthrHEAD)r=r_ZCONTINUEr>r<rFrXcoderKstriprLrJr\rrDrHitemsgetr+rMrN_check_closerPrOr^r[Z
NO_CONTENTZNOT_MODIFIEDrG)	r0rJrKrLZskipped_headershdrvalZtr_encrOrrrbegin8s\







zHTTPResponse.begincCsv|jd}|jdkr.|r*d|kr*dSdS|jdr>dS|rRd|krRdS|jd}|rrd|krrdSdS)NZ
connectionracloseTFz
keep-alivezproxy-connection)r=rgrJr+)r0ZconnZpconnrrrrhs
zHTTPResponse._check_closecCs|j}d|_|dS)N)r<rl)r0r<rrrr]szHTTPResponse._close_conncs$ztWd|jr|XdS)N)superrlr<r])r0)	__class__rrrlszHTTPResponse.closecst|jr|jdS)N)rmflushr<)r0)rnrrros
zHTTPResponse.flushcCsdS)zAlways returns TrueTr)r0rrrreadableszHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r<)r0rrrisclosedszHTTPResponse.isclosedcCs|jdkrdS|jdkr$|dS|dk	rRt|}||}t|d|S|jr`|S|j	dkrv|j
}n6y||j	}Wntk
r|YnXd|_	||SdS)Nr8rcr)
r<rGr]	bytearrayreadinto
memoryviewtobytesrM_readall_chunkedrOread
_safe_readr
)r0amtbr1srrrrws*



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.
        Nrrc)	r<rGr]rM_readinto_chunkedrOr,rtrs)r0rzr1rrrrss$





zHTTPResponse.readintocCsp|jtd}t|tkr$td|d}|dkrB|d|}y
t|dStk
rj|YnXdS)Nr*z
chunk size;r)	r<r9r:r,rfindr^r[r])r0r2irrr_read_next_chunk_sizes

z"HTTPResponse._read_next_chunk_sizecCs>x8|jtd}t|tkr&td|s,P|dkrPqWdS)Nr*ztrailer line)s
r7r8)r<r9r:r,r)r0r2rrr_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|dy|}Wntk
rDtdYnX|dkrb||d}||_|S)NrUr8r)rNrxrr[r
rr])r0rNrrr_get_chunk_left&s
zHTTPResponse._get_chunk_leftcCsr|jtkstg}y8x,|}|dkr(P|||d|_qWd|Stk
rltd|YnXdS)Nrr8)	rMrIAssertionErrorrr/rxrNr@r
)r0valuerNrrrrv>s

zHTTPResponse._readall_chunkedcCs|jtkstd}t|}yvxp|}|dkr2|St||krZ||}|||_||S|d|}||}||d}||7}d|_qWWn(tk
rtt	|d|YnXdS)Nr)
rMrIrrtrr,_safe_readintorNr
bytes)r0rztotal_bytesmvbrNr1temp_mvbrrrr|Ls&


zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jt|t}|s4td|||||t|8}qWd|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 <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.
        rr8)r<rwmin	MAXAMOUNTr
r@r/r,)r0ryr{chunkrrrrxds

zHTTPResponse._safe_readcCsd}t|}xt|t|krtt|kr@|dt}|j|}n|j|}|sjtt|d|t|||d}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)rtr,rr<rsr
r)r0rzrrrr1rrrr{s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.
        Nrcr8r)r<rGrM_read1_chunkedrOread1r]r,)r0r1resultrrrrs


zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(||S|j|S)Nrcr8)r<rGrM
_peek_chunkedpeek)r0r1rrrrs

zHTTPResponse.peekcs|jdks|jdkrdS|jr*t|S|jdk	rL|dksF||jkrL|j}|j|}|sj|rj|n|jdk	r|jt|8_|S)Nrcr8r)r<rGrMrmr9rOr]r,)r0limitr)rnrrr9s

zHTTPResponse.readlinecCsd|}|dks|dkrdSd|kr0|ks6n|}|j|}|jt|8_|s`td|S)Nrr8)rr<rrNr,r
)r0r1rNrwrrrrszHTTPResponse._read1_chunkedcCsBy|}Wntk
r dSX|dkr.dS|j|d|S)Nr8)rr
r<r)r0r1rNrrrrszHTTPResponse._peek_chunkedcCs
|jS)N)r<fileno)r0rrrrszHTTPResponse.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, )r=rZget_all
isinstancerWhasattrr@)r0r%defaultr=rrr	getheaders
zHTTPResponse.getheadercCs|jdkrtt|jS)z&Return list of (header, value) tuples.N)r=rlistrf)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.

        )r=)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.

        )rS)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.

        )rK)r0rrrgetcodeszHTTPResponse.getcode)rNN)N)r)r)r)N)"r4r5r6rTr_rkrhr]rlrorprqrwrsrrrrvr|rxrrrr9rrrrrrrrr
__classcell__rr)rnrrs<	
!K

 "

	

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);rrazHTTP/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_textIOcCsd|dkr|tkrdSdSt|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.
        Nrrw)	upper_METHODS_EXPECTING_BODYrrtnbytes	TypeErrorrrWr,)bodyrRZmvrrr_get_content_length-s

z"HTTPConnection._get_content_lengthNi cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|||\|_
|_||j
tj|_dS)N)timeoutsource_address	blocksizerQ_buffer_HTTPConnection__response_CS_IDLE_HTTPConnection__staterG_tunnel_host_tunnel_port_tunnel_headers
_get_hostporthostport_validate_hostsocketZcreate_connection_create_connection)r0rrrrrrrrrTMs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 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)rQRuntimeErrorrrrrclear)r0rrr=rrr
set_tunnelcszHTTPConnection.set_tunnelcCs|dkr|d}|d}||kryt||dd}WnHtk
r||dddkrh|j}ntd||ddYnX|d|}n|j}|r|ddkr|ddkr|dd}||fS)	Nr)]r*rVznonnumeric port: '%s'r[r)rfindr^r[default_portr)r0rrrjrrrr{s

zHTTPConnection._get_hostportcCs
||_dS)N)rF)r0levelrrrset_debuglevelszHTTPConnection.set_debuglevelc
Csht|jrtd|jfd|j|jf}|d}||xr|jD]d\}}|d}|d}t	|s~td|ft
|rtd|fd||f}||dqLW|d|j|j|j
d	}|\}	}
}|
tjjkr|td
|
|fxZ|jtd}t|tkr0td|s8P|d
krDP|jdkr
td|q
WdS)Nz/Tunnel host can't contain control characters %rzCONNECT %s:%d HTTP/1.0
asciizlatin-1zInvalid header name %rzInvalid header value %rz%s: %s
s
)rRzTunnel connection failed: %d %sr*zheader line)s
r7r8rzheader:)!_contains_disallowed_url_pchar_researchrr[rrsendrrf_is_legal_header_name_is_illegal_header_valueresponse_classrQrGr_http
HTTPStatusZOKrlOSErrorrer<r9r:r,rrFrXrA)
r0Zconnect_strZ
connect_bytesheaderrZheader_bytesZvalue_bytesZ
header_strresponserJrdmessager2rrr_tunnelsB






zHTTPConnection._tunnelcCsB||j|jf|j|j|_|jtjtj	d|j
r>|dS)z3Connect to the host and port specified in __init__.r*N)rrrrrrQZ
setsockoptrZIPPROTO_TCPZTCP_NODELAYrr)r0rrrconnects
zHTTPConnection.connectcCsBt|_z|j}|r d|_|Wd|j}|r<d|_|XdS)z(Close the connection to the HTTP server.N)rrrQrlr)r0rQrrrrrlszHTTPConnection.closecCs|jdkr |jr|nt|jdkr8tdt|t|dr|jdkrTtd||}|rt|jdkrttdx0|	|j
}|sP|r|d}|j|qvWdSy|j|WnPt
k
r
t|tjjrx*|D]}|j|qWnt
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:rwzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rQ	auto_openrrrFrXrYrrrwrrZsendallrrcollectionsabcIterabletype)r0rr	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)rr/)r0r{rrr_outputszHTTPConnection._outputccsb|jdkrtd||}|r2|jdkr2tdx*||j}|sFP|rT|d}|Vq4WdS)NrzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rFrXrrwrr)r0rprrrrr_read_readables


zHTTPConnection._read_readableFcCs$|jdd|j}|jdd=|||dk	r t|drN||}nZyt|WnFtk
ryt|}Wn$tk
rtdt	|YnXYnX|f}xZ|D]R}|s|j
dkrtdq|r|jdkrt
|d	d
d|d}||qW|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.
        )r8r8s
NrwzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredraXz
rs0

)rextendr@rrrrtriterrrFrX	_http_vsnr,r)r0message_bodyencode_chunkedrHZchunksrrrr_send_outputs4




zHTTPConnection._send_outputcCs|jr|jrd|_|jtkr(t|_n
t|j||||_|pHd}||d|||j	f}|
|||jdkr|sd}|
drt|\}}}}}|ry|d}Wntk
r|d}YnX|d	|n|jr|j}	|j}
n|j}	|j}
y|	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 %srarVrrZidnaZHostr)r[]z%s:%szAccept-EncodingZidentity)rrqrr_CS_REQ_STARTEDr
_validate_methodrG_validate_path
_http_vsn_strr_encode_requestrr\rrr	putheaderrrrrrrrA)r0rRrS	skip_hostskip_accept_encodingrequestZnetlocZnilZ
netloc_encrrZhost_encrrr
putrequestAsP






zHTTPConnection.putrequestcCs
|dS)Nr)r)r0rrrrrszHTTPConnection._encode_requestcCs,t|}|r(td|d|ddS)z&Validate a method name for putrequest.z)method can't contain control characters. z (found at least )N)$_contains_disallowed_method_pchar_rerr[group)r0rRmatchrrrrs
zHTTPConnection._validate_methodcCs,t|}|r(td|d|ddS)zValidate a url for putrequest.z&URL can't contain control characters. z (found at least rN)rrrr)r0rSrrrrrs
zHTTPConnection._validate_pathcCs,t|}|r(td|d|ddS)z9Validate a host so it doesn't contain control characters.z&URL can't contain control characters. z (found at least rN)rrrr)r0rrrrrrs
zHTTPConnection._validate_hostcGs|jtkrtt|dr$|d}t|s:td|ft|}xht|D]\\}}t|drn|d||<nt	|t
rt|d||<t||rLtd||fqLWd
|}|d|}||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)rrrrrrr[r	enumeraterr^rWrr@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||||||dS)z&Send a complete request to the server.N)
_send_request)r0rRrSrr=rrrrrszHTTPConnection.requestcCstdd|D}i}d|kr&d|d<d|kr6d|d<|j||f|d|krd	|krd
}|||}|dkr|dk	r|jdkrtd|d
}|ddq|dt|nd
}x |D]\}	}
||	|
qWt|trt	|d}|j
||ddS)Ncss|]}|VqdS)N)r+)rkrrr	<genexpr>
sz/HTTPConnection._send_request.<locals>.<genexpr>rr*rzaccept-encodingrzcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrMzContent-Lengthr)r)	frozensetrrrFrXrrWrfrr'r)r0rRrSrr=rZheader_namesZskipsZcontent_lengthrirrrrrs0	


zHTTPConnection._send_requestcCs|jr|jrd|_|jtks&|jr0t|j|jdkrR|j|j|j|jd}n|j|j|jd}yZy|	Wnt
k
r|YnX|jt
kstt|_|jr|n||_|S|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)rR)rrqrrrrFrrQrGrkConnectionErrorrlrPrIrr)r0rrrrgetresponse9s.


zHTTPConnection.getresponse)NN)NF)FF)N)%r4r5r6rrrr	HTTP_PORTrrrFstaticmethodrrr_GLOBAL_DEFAULT_TIMEOUTrTrrrrrrlrrrrrrrrrrrrrrrrrrrs@ 
'	&
6
~	
.csHeZdZdZeZdddejdfddddfddZfddZ	Z
S)	HTTPSConnectionz(This class allows communication via SSL.Ni )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.rUTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rmrrTwarningswarnDeprecationWarningkey_file	cert_filesslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr[Zload_cert_chain_context)r0rrrr	rrrrrrZwill_verify)rnrrrTs4

zHTTPSConnection.__init__cs6t|jr|j}n|j}|jj|j|d|_dS)z(Connect to a host on a given (SSL) port.)server_hostnameN)rmrrrrZwrap_socketrQ)r0r)rnrrrs

zHTTPSConnection.connect)r4r5r6__doc__
HTTPS_PORTrrrrTrrrr)rnrr}s!rc@seZdZdS)rN)r4r5r6rrrrrsc@seZdZdS)rN)r4r5r6rrrrrsc@seZdZdS)rN)r4r5r6rrrrrsc@seZdZddZdS)rcCs|f|_||_dS)N)argsrJ)r0rJrrrrTszUnknownProtocol.__init__N)r4r5r6rTrrrrrsc@seZdZdS)rN)r4r5r6rrrrrsc@seZdZdS)r	N)r4r5r6rrrrr	sc@s&eZdZdddZddZddZdS)	r
NcCs|f|_||_||_dS)N)rpartialexpected)r0rrrrrrTszIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j|fS)Nz, %i more expectedrVz%s(%i bytes read%s))rrnr4r,r)r0errr__repr__s

zIncompleteRead.__repr__cCst|S)N)rY)r0rrr__str__szIncompleteRead.__str__)N)r4r5r6rTrrrrrrr
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)rYrr2)r0r2rrrrTszBadStatusLine.__init__N)r4r5r6rTrrrrrsc@seZdZddZdS)rcCst|dt|fdS)Nz&got more than %d bytes when reading %s)rrTr:)r0Z	line_typerrrrTszLineTooLong.__init__N)r4r5r6rTrrrrrsc@seZdZddZdS)rcOs"t|dtj|f||dS)NrV)rrTConnectionResetError)r0poskwrrrrTszRemoteDisconnected.__init__N)r4r5r6rTrrrrrs)r)Br
Zemail.parserrBZ
email.messagerrrerZcollections.abcrZurllib.parser__all__rrrIrrrglobalsupdater__members__rrrr:r;compile	fullmatchrrrrrrr'rZMessager(r>rDBufferedIOBaserrr
ImportErrorrr/	Exceptionrrrrrr	r
rr
rrrrrrrrrrr<module>Es



1_8