ok

Mini Shell

Direktori : /lib64/python3.6/http/__pycache__/
Upload File :
Current File : //lib64/python3.6/http/__pycache__/client.cpython-36.opt-1.pyc

3

��f*��@srdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZdddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe�jejj�dd�ejjj�D�ZdZdZd Zejd!�jZejd"�jZ ejd#�Z!ejd$�Z"d%d&d'hZ#dCd)d*�Z$Gd+d,�d,ej%j&�Z'd-d.�Z(e'fd/d0�Z)Gd1d�dej*�Z+Gd2d�d�Z,yddl-Z-Wne.k
�rlYnXGd3d4�d4e,�Z/ej0d4�Gd5d�de1�Z2Gd6d�de2�Z3Gd7d�de2�Z4Gd8d�de2�Z5Gd9d	�d	e2�Z6Gd:d
�d
e2�Z7Gd;d�de2�Z8Gd<d
�d
e2�Z9Gd=d�de9�Z:Gd>d�de9�Z;Gd?d�de9�Z<Gd@d�de2�Z=GdAd�de2�Z>GdBd�de?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�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.6/http/client.py�
<dictcomp>ksrii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]ZPATCHZPOSTZPUT�datacCsfy
|jd�Stk
r`}z:t|j|j|j|jd|j�||j|j�|f�d�WYdd}~XnXdS)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)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s
r'c@seZdZdd�ZdS)�HTTPMessagecCsn|j�d}t|�}g}d}xL|j�D]@}|d|�j�|krDd}n|dd�j�sXd}|r&|j|�q&W|S)a�Find 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�)�lower�len�keys�isspace�append)�selfr%�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r3rrrrr(�sr(cCs\g}xR|jtd�}t|�tkr(td��|j|�t|�tkrJtdt��|dkrPqW|S)z�Reads 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�
�
�)r7r8r9)�readline�_MAXLINEr,rr/�_MAXHEADERSr)�fp�headersr2rrr�
_read_headers�s
r?cCs,t|�}dj|�jd�}tjj|d�j|�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.

    r9z
iso-8859-1)�_class)r?�join�decode�email�parserZParserZparsestr)r=r@r>Zhstringrrr�
parse_headers�s
rEcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd(d)�ZdEd*d+�ZdG�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdHd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)IrrNcCsR|jd�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefiler=�
debuglevel�_methodr>�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r0�sockrH�method�urlrrr�__init__�szHTTPResponse.__init__cCst|jjtd�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��y|j
dd�\}}}WnFtk
r�y|j
dd�\}}d}Wntk
r�d}YnXYnX|jd	�s�|j
�t|��y$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr=r:r;r,rrH�print�reprr�split�
ValueError�
startswith�_close_connr�int)r0r2rLrMrNrrr�_read_statuss2

zHTTPResponse._read_statuscCs�|jdk	rdSx<|j�\}}}|tkr(Pt|j�}|jdkrFtd|�~qW||_|_|j	�|_
|dkrrd|_n|jd�r�d|_nt
|��t|j�|_|_|jdkr�x&|jD]}td|d	|jj|��q�W|jjd
�}|r�|j�dkr�d|_d|_nd
|_|j�|_d|_|jjd�}|jjd
�}|�rx|j�rxyt|�|_Wntk
�rbd|_YnX|jdk�r~d|_nd|_|tk�s�|tk�s�d|k�o�dkn�s�|jdk�r�d|_|j�r�|j�r�|jdk�r�d|_dS)Nrzheaders:�HTTP/1.0�HTTP/0.9�
zHTTP/1.�zheader:r)ztransfer-encodingrOTFzcontent-lengthr���HEAD)rbrc)r>raZCONTINUEr?r=rHrZ�coderM�striprNrLr^rrErJ�getr+rOrP�_check_closerRrQr`r]Z
NO_CONTENTZNOT_MODIFIEDrI)r0rLrMrNZskipped_headers�hdrZtr_encrQrrr�begin9s\









zHTTPResponse.begincCs�|jjd�}|jdkr:|jjd�}|r6d|j�kr6dSdS|jjd�rJdS|r^d|j�kr^dS|jjd�}|r~d|j�kr~dSdS)NZ
connectionre�closeTFz
keep-alivezproxy-connection)r>rjrLr+)r0ZconnZpconnrrrrk�s
zHTTPResponse._check_closecCs|j}d|_|j�dS)N)r=rn)r0r=rrrr_�szHTTPResponse._close_connc
s$zt�j�Wd|jr|j�XdS)N)�superrnr=r_)r0)�	__class__rrrn�szHTTPResponse.closecst�j�|jr|jj�dS)N)ro�flushr=)r0)rprrrq�s
zHTTPResponse.flushcCsdS)zAlways returns TrueTr)r0rrr�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r=)r0rrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|j�dS|dk	rRt|�}|j|�}t|�d|�j�S|jr`|j�S|j	dkrv|jj
�}n6y|j|j	�}Wntk
r�|j��YnXd|_	|j�|SdS)Nr9rgr)
r=rIr_�	bytearray�readinto�
memoryview�tobytesrO�_readall_chunkedrQ�read�
_safe_readr
)r0�amt�br1�srrrry�s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|j�dS|jr4|j|�S|jdk	r^t|�|jkr^t|�d|j�}|jj|�}|r~|r~|j�n&|jdk	r�|j|8_|js�|j�|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrrg)	r=rIr_rO�_readinto_chunkedrQr,rvru)r0r|r1rrrru�s$






zHTTPResponse.readintocCsp|jjtd�}t|�tkr$td��|jd�}|dkrB|d|�}y
t|d�Stk
rj|j��YnXdS)Nr*z
chunk size�;r�)	r=r:r;r,r�findr`r]r_)r0r2�irrr�_read_next_chunk_size
s

z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd�}t|�tkr&td��|s,P|dkrPqWdS)Nr*ztrailer line�
r8r9)r�r8r9)r=r:r;r,r)r0r2rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|jd�y|j�}Wntk
rDtd��YnX|dkrb|j�|j�d}||_|S)NrWr9r)rPrzr�r]r
r�r_)r0rPrrr�_get_chunk_left(s
zHTTPResponse._get_chunk_leftcCsdg}y8x,|j�}|dkrP|j|j|��d|_qWdj|�Stk
r^tdj|���YnXdS)Nrr9)r�r/rzrPrAr
)r0�valuerPrrrrx@s

zHTTPResponse._readall_chunkedcCs�d}t|�}yvxp|j�}|dkr$|St|�|krL|j|�}|||_||S|d|�}|j|�}||d�}||7}d|_qWWn(tk
r�tt|d|����YnXdS)Nr)rvr�r,�_safe_readintorPr
�bytes)r0r|�total_bytes�mvbrPr1�temp_mvbrrrr~Ns$


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 <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.
        rr9)r=ry�min�	MAXAMOUNTr
rAr/r,)r0r{r}�chunkrrrrzfs

zHTTPResponse._safe_readcCs�d}t|�}xt|t|�kr�tt|�kr@|dt�}|jj|�}n|jj|�}|sjtt|d|��t|���||d�}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)rvr,r�r=rur
r�)r0r|r�r�r�r1rrrr�}s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�|j�n|jdk	r�|jt|�8_|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nrgr9rr�ii@)	r=rIrO�_read1_chunkedrQ�read1r]r_r,)r0r1�resultrrrr��s"



zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|�S|jj|�S)Nrgr9)r=rIrO�
_peek_chunked�peek)r0r1rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t�j|�S|jdk	rL|dksF||jkrL|j}|jj|�}|rl|rl|j�n|jdk	r�|jt|�8_|S)Nrgr9r)r=rIrOror:rQr_r,)r0�limitr�)rprrr:�s


zHTTPResponse.readlinecCsf|j�}|dks|dkrdSd|ko.|kns8|}|jj|�}|jt|�8_|sbtd��|S)Nrr9)r�r=r�rPr,r
)r0r1rPryrrrr��szHTTPResponse._read1_chunkedcCsBy|j�}Wntk
r dSX|dkr.dS|jj|�d|�S)Nr9)r�r
r=r�)r0r1rPrrrr��szHTTPResponse._peek_chunkedcCs
|jj�S)N)r=�fileno)r0rrrr��szHTTPResponse.filenocCsH|jdkrt��|jj|�p|}t|t�s6t|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, )r>rZget_all�
isinstancerY�hasattrrA)r0r%�defaultr>rrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|jj��S)z&Return list of (header, value) tuples.N)r>r�list�items)r0rrr�
getheaders�s
zHTTPResponse.getheaderscCs|S)Nr)r0rrrr��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.

        )r>)r0rrr�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.

        )rU)r0rrr�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.

        )rM)r0rrr�getcodeszHTTPResponse.getcode)rNN)N���)r�r�)r�r�)r�)N)"r4r5r6rVrarmrkr_rnrqrrrsryrur�r�r�rxr~rzr�r�r�r:r�r�r�r�r�r�r�r�r��
__classcell__rr)rprr�s<	
!K

 "

	

c@s�eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	fd
d�Zd0dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd1dd �Zd2d!d"�Zd#d$�Zd%d&�Zd3dd'�d(d)�Zd	ifdd'�d*d+�Zd,d-�Z d.d/�Z!d	S)4rrezHTTP/1.1r*rcCst|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streamrrr�
_is_textIO0szHTTPConnection._is_textIOcCsd|dkr|j�tkrdSdSt|d�r*dSyt|�}|jStk
rLYnXt|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.
        Nrry)	�upper�_METHODS_EXPECTING_BODYr�rv�nbytes�	TypeErrorr�rYr,)�bodyrTZmvrrr�_get_content_length6s

z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrS�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterI�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r0r�r�r�r�rrrrVVszHTTPConnection.__init__cCs<|jrtd��|j||�\|_|_|r.||_n
|jj�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 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)rS�RuntimeErrorr�r�r�r��clear)r0r�r�r>rrr�
set_tunneliszHTTPConnection.set_tunnelcCs�|dkr�|jd�}|jd�}||kr�yt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd	�}||fS)
Nr)�]r*rXznonnumeric port: '%s'r�[r�r�)�rfindr`r]�default_portr)r0r�r�r��jrrrr��s

zHTTPConnection._get_hostportcCs
||_dS)N)rH)r0�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelcCsd|j|jf}|jd�}|j|�x6|jj�D](\}}d||f}|jd�}|j|�q0W|jd�|j|j|jd�}|j	�\}}	}
|	t
jjkr�|j
�td|	|
j�f��xP|jjtd�}t|�tkr�td	��|s�P|dkr�P|jdkr�td
|j��q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
)rTzTunnel connection failed: %d %sr*zheader liner8r9rzheader:)r�r8r9)r�r�r�sendr�r��response_classrSrIra�http�
HTTPStatusZOKrn�OSErrorrir=r:r;r,rrHrZrB)r0Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserLrh�messager2rrr�_tunnel�s2





zHTTPConnection._tunnelcCsB|j|j|jf|j|j�|_|jjtjtj	d�|j
r>|j�dS)z3Connect to the host and port specified in __init__.r*N)r�r�r�r�r�rSZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�)r0rrr�connect�s
zHTTPConnection.connectcCsBt|_z|j}|r d|_|j�Wd|j}|r<d|_|j�XdS)z(Close the connection to the HTTP server.N)r�r�rSrnr�)r0rSr�rrrrn�szHTTPConnection.closecCs|jdkr |jr|j�nt��|jdkr8tdt|��d}t|d�r�|jdkrXtd�|j|�}|rx|jdkrxtd�x.|j	|�}|s�P|r�|j
d�}|jj|�qzWdSy|jj|�WnNtk
�r
t
|tj�r�x*|D]}|jj|�q�Wntd	t|���YnXdS)
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:i ryzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rS�	auto_openr�rrHrZr[r�r�ryrZsendallr�r��collections�Iterable�type)r0r�	blocksizer�	datablock�drrrr��s:








zHTTPConnection.sendcCs|jj|�dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)r�r/)r0r}rrr�_output�szHTTPConnection._outputccsdd}|jdkrtd�|j|�}|r6|jdkr6td�x(|j|�}|sHP|rV|jd�}|Vq8WdS)Ni rzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rHrZr�ryr)r0rrr�rr�rrr�_read_readable�s



zHTTPConnection._read_readableFcCs$|jjd
�dj|j�}|jdd�=|j|�|dk	�r t|d�rN|j|�}nZyt|�WnFtk
r�yt|�}Wn$tk
r�tdt	|���YnXYnX|f}xZ|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d	�d
�jd�|d}|j|�q�W|�r |jdk�r |jd�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.
        r9s
NryzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredre�Xz
r�s0

)r9r9)r��extendrAr�r�r�rvr��iterr�rHrZ�	_http_vsnr,r)r0�message_body�encode_chunkedrJZchunksr�rrr�_send_outputs4




zHTTPConnection._send_outputc

Cs�|jr|jj�rd|_|jtkr(t|_n
t|j��|j|�||_|sJd}tj	|�}|rrt
d|�d|j��d���d|||jf}|j
|jd��|jdk�r�|�s�d	}|jd
�r�t|�\}}}}}|�ry|jd�}	Wntk
r�|jd�}	YnX|jd|	�n�|j�r|j}
|j}n|j}
|j}y|
jd�}Wn tk
�rV|
jd�}YnX|
jd
�dk�rtd|d}||jk�r�|jd|�n|jd�}|jdd||f�|�s�|jdd�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&URL can't contain control characters. z (found at least �)z%s %s %sr�rerXr�ZidnaZHostr)r�[�]z%s:%szAccept-EncodingZidentity)r�rsr�r��_CS_REQ_STARTEDr
�_validate_methodrI�!_contains_disallowed_url_pchar_re�searchr�group�
_http_vsn_strr�rr�r^rr�	putheaderr�r�r�r�r�r�rB)
r0rTrU�	skip_host�skip_accept_encoding�match�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequestAsV






zHTTPConnection.putrequestcCs,tj|�}|r(td|�d|j��d���dS)z&Validate a method name for putrequest.z)method can't contain control characters. z (found at least r�N)�$_contains_disallowed_method_pchar_rer�r]r�)r0rTr�rrrr��s
zHTTPConnection._validate_methodcGs�|jtkrt��t|d�r$|jd�}t|�s:td|f��t|�}xht|�D]\\}}t|d�rn|jd�||<nt	|t
�r�t|�jd�||<t||�rLtd||f��qLWdj
|�}|d|}|j|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rr�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: N)r�r�rr�r�_is_legal_header_namer]r��	enumerater�r`rY�_is_illegal_header_valuerAr�)r0r��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.
        )r�N)r�r��_CS_REQ_SENTrr�)r0r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|j|||||�dS)z&Send a complete request to the server.N)�
_send_request)r0rTrUr�r>r�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|j||�}|dkr�|dk	r�|jdkr�td|�d
}|jdd�q�|jdt|��nd
}x |j�D]\}	}
|j|	|
�q�Wt|t�r�t	|d�}|j
||d�dS)Ncss|]}|j�VqdS)N)r+)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r*r�zaccept-encodingr�zcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrOzContent-Lengthr�)r�)�	frozensetr�r�rHrZr�rYr�r�r'r�)r0rTrUr�r>r�Zheader_namesZskipsZcontent_lengthrlr�rrrr��s0	


zHTTPConnection._send_requestcCs�|jr|jj�rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}yLy|j	�Wnt
k
r�|j��YnXt|_|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)rT)r�rsr�r�rrHr�rSrIrm�ConnectionErrorrnr�rR)r0r�rrr�getresponse)s,


zHTTPConnection.getresponse)NN)NF)FF)N)"r4r5r6r�r�rr��	HTTP_PORTr�r�rH�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrVr�r�r�r�r�rnr�r�r�r�r�r�r�r�r�r�r�rrrrr&s< 
	'
6
	
.csFeZdZdZeZdddejdfddd��fdd�Z�fdd�Z	�Z
S)�HTTPSConnectionz(This class allows communication via SSL.N)�context�check_hostnamecs�tt|�j||||�|dk	s.|dk	s.|dk	rDddl}	|	jdtd�||_||_|dkrptj	�}|j
dk	rpd|_
|jtjk}
|dkr�|j
}|r�|
r�td��|s�|r�|j||�|j
dk	r�d|_
||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rWTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrV�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr]Zload_cert_chain�_context�_check_hostname)r0r�r�rr	r�r�rrrZwill_verify)rprrrVts0


zHTTPSConnection.__init__cs�t�j�|jr|j}n|j}|jj|j|d�|_|jjr�|jr�yt	j
|jj�|�Wn.tk
r�|jj
tj�|jj��YnXdS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)ror�r�r�rZwrap_socketrSrrr
Zmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRrn)r0r
)rprrr��s



zHTTPSConnection.connect)r4r5r6�__doc__�
HTTPS_PORTr�r�rrVr�r�rr)rprrmsrc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrL)r0rLrrrrV�szUnknownProtocol.__init__N)r4r5r6rVrrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r	N)r4r5r6rrrrr	�sc@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs|f|_||_||_dS)N)r�partial�expected)r0rrrrrrV�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedrXz%s(%i bytes read%s))rrpr4r,r)r0�errr�__repr__�s

zIncompleteRead.__repr__cCst|�S)N)r[)r0rrr�__str__�szIncompleteRead.__str__)N)r4r5r6rVrrrrrrr
�s
c@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r
N)r4r5r6rrrrr
�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dS)N)r[rr2)r0r2rrrrV�szBadStatusLine.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrVr;)r0Z	line_typerrrrV�szLineTooLong.__init__N)r4r5r6rVrrrrr�sc@seZdZdd�ZdS)rcOs"tj|d�tj|f|�|�dS)NrX)rrV�ConnectionResetError)r0�pos�kwrrrrV�szRemoteDisconnected.__init__N)r4r5r6rVrrrrr�s)r)BrZemail.parserrCZ
email.messager�r��os�rer�r�Zurllib.parser�__all__r�rrKr�r�r��globals�updater��__members__r�rr�r;r<�compile�	fullmatchr�r�r�r�r�r�r'r�ZMessager(r?rE�BufferedIOBaserrr
�ImportErrorrr/rrrrrrr	r
rr
rrrrrrrrrrr�<module>Es�



9F=


Zerion Mini Shell 1.0