AlkantarClanX12

Your IP : 3.147.65.111


Current Path : /opt/alt/python34/lib64/python3.4/http/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/http/__pycache__/client.cpython-34.pyo

�
e f��@sRdZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
dddddd	d
ddd
dddddddgZdZdZ
dZdZdZdZdZdZdZdZdZd Zd!Zd"Zd#Zd$Zd%Zd&Zd'Zd(Zd)Z d*Z!d+Z"d,Z#d-Z$d.Z%d/Z&d0Z'd1Z(d2Z)d3Z*d4Z+d5Z,d6Z-d7Z.d8Z/d9Z0d:Z1d;Z2d<Z3d=Z4d>Z5d?Z6d@Z7dAZ8dBZ9dCZ:dDZ;dEZ<dFZ=dGZ>dHZ?dIZ@dJZAdKZBdLZCdMZDdNZEdOZFi-dPd6dQd6dRd6dSd6dTd 6dUd!6dVd"6dWd#6dXd$6dYd'6dZd(6d[d)6d\d*6d]d+6d^d,6d_d`6dad-6dbd.6dcd/6ddd06ded16dfd26dgd36dhd46did56djd66dkd76dld86dmd96dnd:6dod;6dpd<6dqd=6drd>6dsd?6dtdD6dudE6dvdF6dwdG6dxdH6dydI6dzdJ6d{dK6d|dL6d}dO6ZGd~ZHdZIdZJejKd��jLZMejKd��jNZOd�d�d�hZPGd�d��d�ejQjR�ZSeSd�d��ZTGd�d�dejU�ZVGd�d�d�ZWyddlXZXWneYk
rYn$XGd�d��d�eW�ZZej[d��Gd�d�de\�Z]Gd�d�de]�Z^Gd�d�de]�Z_Gd�d�de]�Z`Gd�d	�d	e]�ZaGd�d
�d
e]�ZbGd�d�de]�ZcGd�d
�d
e]�ZdGd�d�ded�ZeGd�d�ded�ZfGd�d�ded�ZgGd�d�de]�ZhGd�d�de]�Zie]ZjdS)�a�	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
      |
      | response = getresponse()
      v
    Unread-response   [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�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sent�d�e�f������������������i,i-i.i/i0i1i3i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�i�ZContinuezSwitching Protocols�OKZCreatedZAcceptedzNon-Authoritative Informationz
No Contentz
Reset ContentzPartial ContentzMultiple ChoiceszMoved PermanentlyZFoundz	See OtherzNot Modifiedz	Use Proxyz(Unused)i2zTemporary RedirectzBad RequestZUnauthorizedzPayment RequiredZ	Forbiddenz	Not FoundzMethod Not AllowedzNot AcceptablezProxy Authentication RequiredzRequest TimeoutZConflictZGonezLength RequiredzPrecondition FailedzRequest Entity Too LargezRequest-URI Too LongzUnsupported Media TypezRequested Range Not SatisfiablezExpectation FailedzPrecondition RequiredzToo Many RequestszRequest Header Fields Too LargezInternal Server ErrorzNot ImplementedzBad GatewayzService UnavailablezGateway TimeoutzHTTP Version Not SupportedzNetwork Authentication Requirediis[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])ZPATCHZPOSTZPUTc@seZdZdd�ZdS)�HTTPMessagecCs�|j�d}t|�}g}d}xn|j�D]`}|d|�j�|kr`d}n|dd�j�sd}n|r5|j|�q5q5W|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)�self�name�nZlstZhit�line�r.�0/opt/alt/python34/lib64/python3.4/http/client.py�getallmatchingheaderss
		z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r0r.r.r.r/r"�sr"cCs�g}xz|jtd�}t|�tkr=td��n|j|�t|�tkrotdt��n|d	kr	Pq	q	Wdj|�jd�}t	j
jd|�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.

    r$zheader linezgot more than %d headers�
�
�z
iso-8859-1�_class)r4r5r6)
�readline�_MAXLINEr&rr)�_MAXHEADERSr�join�decode�email�parserZParserZparsestr)�fpr7�headersr-Zhstringr.r.r/�
parse_headerss

rAcsQeZdZddddd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�Zd�fdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zdd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z�S)3rrNcCsw|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)r*�sockrD�method�urlr.r.r/�__init__=s								zHTTPResponse.__init__cCsxt|jjtd�d�}t|�tkr@td��n|jdkretdt|��n|szt	|��ny|j
dd�\}}}WnOtk
r�y"|j
dd�\}}d}Wntk
r�d}YnXYnX|jd�s|j
�t	|��ny7t|�}|d	ks:|d
krIt	|��nWntk
rjt	|��YnX|||fS)Nr$z
iso-8859-1zstatus linerzreply:��zHTTP/ri�)�strr?r8r9r&rrD�print�reprr�split�
ValueError�
startswith�_close_conn�int)r*r-rHrIrJr.r.r/�_read_status[s2




zHTTPResponse._read_statuscCs�|jdk	rdSx�|j�\}}}|tkr;Pnxp|jjtd�}t|�tkrutd��n|j�}|s�Pn|j	dkr>t
d|�q>q>WqW||_|_|j�|_
|dkr�d|_n'|jd�rd	|_nt|��t|j�|_|_|j	dkrbx'|jD]}t
d|d
d�qBWn|jjd�}|r�|j�d
kr�d|_d|_n	d|_|j�|_d|_|jjd�}|jjd�}|rE|jrEyt|�|_Wntk
r&d|_YqNX|jdkrNd|_qNn	d|_|tks�|tks�d|ko}dkns�|jdkr�d|_n|jr�|jr�|jdkr�d|_ndS)Nr$zheader linerzheader:�HTTP/1.0�HTTP/0.9�
zHTTP/1.��end� ztransfer-encodingrKTFzcontent-lengthrr�HEAD)r^r_)r@r]�CONTINUEr?r8r9r&r�striprDrV�coderIrJrHrZrrArF�getr%rKrL�_check_closerNrMr\rY�
NO_CONTENT�NOT_MODIFIEDrE)r*rHrIrJ�skip�hdrZtr_encrMr.r.r/�begin{sf			
	

zHTTPResponse.begincCs�|jjd�}|jdkrS|jjd�}|rOd|j�krOdSdS|jjd�ridS|r�d|j�kr�dS|jjd�}|r�d|j�kr�dSdS)NZ
connectionra�closeTFz
keep-alivezproxy-connection)r@rhrHr%)r*ZconnZpconnr.r.r/ri�szHTTPResponse._check_closecCs |j}d|_|j�dS)N)r?ro)r*r?r.r.r/r[�s		zHTTPResponse._close_connc
s/zt�j�Wd|jr*|j�nXdS)N)�superror?r[)r*)�	__class__r.r/ro�s	zHTTPResponse.closecs*t�j�|jr&|jj�ndS)N)rp�flushr?)r*)rqr.r/rr�s
	zHTTPResponse.flushcCsdS)NTr.)r*r.r.r/�readable�szHTTPResponse.readablecCs
|jdkS)z!True if the connection is closed.N)r?)r*r.r.r/�isclosedszHTTPResponse.isclosedcs�|jdkrdS|jdkr0|j�dS|dk	rRtt|�j|�S|jre|j�S|jdkr�|jj�}nAy|j	|j�}Wnt
k
r�|j��YnXd|_|j�|SdS)Nr6rdr)r?rEr[rpr�readrK�_readall_chunkedrM�
_safe_readr
)r*�amt�s)rqr.r/rus&
	


	
zHTTPResponse.readcCs�|jdkrdS|jdkr0|j�dS|jrF|j|�S|jdk	r�t|�|jkr�t|�d|j�}q�n|jj|�}|r�|r�|j�n7|jdk	r�|j|8_|js�|j�q�n|S)Nrrd)	r?rEr[rK�_readinto_chunkedrMr&�
memoryview�readinto)r*�br,r.r.r/r|-s$
	


	zHTTPResponse.readintocCs�|jjtd�}t|�tkr7td��n|jd�}|dkre|d|�}nyt|d�SWntk
r�|j��YnXdS)Nr$z
chunk size�;r�)	r?r8r9r&r�findr\rYr[)r*r-�ir.r.r/�_read_next_chunk_sizeKs

z"HTTPResponse._read_next_chunk_sizecCs\xU|jjtd�}t|�tkr:td��n|sDPn|dkrPqqWdS)Nr$ztrailer line�
�
r6)r�r�r6)r?r8r9r&r)r*r-r.r.r/�_read_and_discard_trailer[sz&HTTPResponse._read_and_discard_trailercCs�|j}g}x�|dkrky |j�}|dkr=PnWqktk
rgtdj|���YqkXn|j|j|��|jd�d}qW|j�|j�dj|�S)Nrr6rS)	rLr�rYr
r;r)rwr�r[)r*rL�valuer.r.r/rvis 	




zHTTPResponse._readall_chunkedcCs[|j}d}t|�}x%|dkr~y |j�}|dkrIPnWq~tk
rztt|d|����Yq~Xnt|�|kr�|j|�}|||_||St|�|kr�|j|�}|jd�d|_||S|d|�}|j|�}||d�}||7}|jd�d}qW|j	�|j
�|S)NrrS)rLr{r�rYr
�bytesr&�_safe_readintorwr�r[)r*r}rL�total_bytes�mvbr,�temp_mvbr.r.r/rz�s:	
$

	




zHTTPResponse._readinto_chunkedcCsg}xi|dkrq|jjt|t��}|sQtdj|�|��n|j|�|t|�8}q	Wdj|�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.
        rr6)r?ru�min�	MAXAMOUNTr
r;r)r&)r*rxry�chunkr.r.r/rw�s
zHTTPResponse._safe_readcCs�d}t|�}x�|t|�kr�tt|�kr^|dt�}|jj|�}n|jj|�}|s�tt|d|��t|���n||d�}||7}qW|S)z2Same as _safe_read, but for reading into a buffer.rN)r{r&r�r?r|r
r�)r*r}r�r�r�r,r.r.r/r��s(zHTTPResponse._safe_readintocCs
|jj�S)N)r?�fileno)r*r.r.r/r��szHTTPResponse.filenocCsg|jdkrt��n|jj|�p0|}t|t�sRt|d�rV|Sdj|�SdS)N�__iter__z, )r@rZget_all�
isinstancerU�hasattrr;)r*r+�defaultr@r.r.r/�	getheader�szHTTPResponse.getheadercCs.|jdkrt��nt|jj��S)z&Return list of (header, value) tuples.N)r@r�list�items)r*r.r.r/�
getheaders�szHTTPResponse.getheaderscCs|S)Nr.)r*r.r.r/r��szHTTPResponse.__iter__cCs|jS)N)r@)r*r.r.r/�info�szHTTPResponse.infocCs|jS)N)rQ)r*r.r.r/�geturl�szHTTPResponse.geturlcCs|jS)N)rI)r*r.r.r/�getcode�szHTTPResponse.getcode)r1r2r3rRr]rnrir[rorrrsrtrur|r�r�rvrzrwr�r�r�r�r�r�r�r�r.r.)rqr/r4s0	 P
)	c@s*eZdZdZdZeZeZdZ	dZ
dZdej
ddd�Zddd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zddd�Zdddd�Zdd�Zddd �Zdid!d"�Zd#d$�Zd%d&�Zd'd(�ZdS))rrazHTTP/1.1r$ri@NcCs�||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrO�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterE�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r*r�r�r�r�r.r.r/rRs										zHTTPConnection.__init__cCsY|jrtd��n|j||�\|_|_|rH||_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)rO�RuntimeErrorr�r�r�r��clear)r*r�r�r@r.r.r/�
set_tunnels	zHTTPConnection.set_tunnelcCs|dkr|jd�}|jd�}||kr�yt||dd��}WnVtk
r�||dd�dkr�|j}ntd||dd���YnX|d|�}n	|j}|r|ddkr|ddkr|dd	�}qn||fS)
Nr#�]r$rTznonnumeric port: '%s'r�[���r�)�rfindr\rY�default_portr)r*r�r�r��jr.r.r/r�1s
#	&zHTTPConnection._get_hostportcCs
||_dS)N)rD)r*�levelr.r.r/�set_debuglevelEszHTTPConnection.set_debuglevelcCsLd|j|jf}|jd�}|j|�xI|jj�D]8\}}d||f}|jd�}|j|�qBW|jd�|j|jd|j�}|j	�\}}	}
|	dkr�|j
�td|	|
j�f��nxU|j
jtd	�}t|�tkr*td
��n|s4Pn|d
kr�Pq�q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
rPrzTunnel connection failed: %d %sr$zheader line�
r6)r�r�r6)r�r��encode�sendr�r��response_classrOrEr]ro�OSErrorrfr?r8r9r&r)r*Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserHrg�messager-r.r.r/�_tunnelHs.	



	zHTTPConnection._tunnelcCsD|j|j|jf|j|j�|_|jr@|j�ndS)z3Connect to the host and port specified in __init__.N)r�r�r�r�r�rOr�r�)r*r.r.r/�connectds	zHTTPConnection.connectcCs_t|_z)|j}|r1d|_|j�nWd|j}|rZd|_|j�nXdS)z(Close the connection to the HTTP server.N)r�r�rOror�)r*rOr�r.r.r/rols					zHTTPConnection.closecCs�|jdkr1|jr%|j�q1t��n|jdkrVtdt|��nd}t|d�r,|jdkr�td�nd}y
|j}Wnt	k
r�Yn2Xd|kr�d	}|jdkr�td
�q�nxE|j
|�}|s�Pn|r|jd�}n|jj|�q�WdSy|jj|�Wn^t
k
r�t|tj�r�x7|D]}|jj|�qiWnt
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 ruzsendIng a read()ableFr}Tzencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rO�	auto_openr�rrDrVrWr��mode�AttributeErrorrur�Zsendall�	TypeErrorr��collections�Iterable�type)r*�dataZ	blocksizer�r�Z	datablock�dr.r.r/r�zsF	





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))r*ryr.r.r/�_output�szHTTPConnection._outputcCs�|jjd�dj|j�}|jdd�=t|t�rit|�|jkri||7}d}n|j|�|dk	r�|j|�ndS)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.
        r6s
N)r6r6)r��extendr;r�r�r&�mssr�)r*�message_bodyrFr.r.r/�_send_output�s$
	
zHTTPConnection._send_outputc
Cs%|jr$|jj�r$d|_n|jtkr?t|_nt|j��||_|sfd}nd|||jf}|j|j	d��|j
dkr!|sd}|jd�r�t|�\}}}}}n|r*y|j	d�}Wn!t
k
r|j	d�}YnX|jd	|�q|jrH|j}	|j}
n|j}	|j}
y|	j	d�}Wn!t
k
r�|	j	d�}YnX|	jd
�dkr�d|d
}n|
|jkr�|jd	|�q|jd�}|jd	d||
f�n|s!|jdd�q!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 %sr�rarTZhttpZidnaZHostr#r�[�]z%s:%szAccept-EncodingZidentity)r�rtr�r��_CS_REQ_STARTEDr
rE�
_http_vsn_strr�r��	_http_vsnrZr�UnicodeEncodeError�	putheaderr�r�r�r�r�r�r<)r*rPrQ�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encr.r.r/�
putrequest�sN		
				

zHTTPConnection.putrequestcGs/|jtkrt��nt|d�r<|jd�}nt|�s^td|f��nt|�}x�t|�D]�\}}t|d�r�|jd�||<n+t	|t
�r�t|�jd�||<nt||�rwtd||f��qwqwWdj
|�}|d|}|j|�dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        r�r�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: N)r�r�rr�r��_is_legal_header_namerYr��	enumerater�r\rU�_is_illegal_header_valuer;r�)r*r��valuesr�Z	one_valuer�r.r.r/r�Ds"zHTTPConnection.putheadercCs5|jtkrt|_n	t��|j|�dS)a�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.  The message body will be sent in the same packet as the
        message headers if it is a string, otherwise it is sent as a separate
        packet.
        N)r�r��_CS_REQ_SENTrr�)r*r�r.r.r/�
endheaders`s		zHTTPConnection.endheaderscCs|j||||�dS)z&Send a complete request to the server.N)�
_send_request)r*rPrQ�bodyr@r.r.r/r�oszHTTPConnection.requestcCs�d}|j�tk}|dkr3|r3d}n�|dk	r�ytt|��}Wq�tk
r�y"ttj|j��j�}Wn4t	t
fk
r�|jdkr�td�nYnXYq�Xn|dk	r�|j
d|�ndS)N�0rz
Cannot stat!!zContent-Length)�upper�_METHODS_EXPECTING_BODYrUr&r��os�fstatr��st_sizer�r�rDrVr�)r*r�rPZthelenZmethod_expects_bodyr.r.r/�_set_content_lengthss	
"z"HTTPConnection._set_content_lengthc	Cs�tjdd�|D��}i}d|kr;d|d<nd|krTd|d<n|j|||�d|kr�|j||�nx*|j�D]\}}|j||�q�Wt|t�r�|jd	�}n|j	|�dS)
NcSsg|]}|j��qSr.)r%)�.0�kr.r.r/�
<listcomp>�s	z0HTTPConnection._send_request.<locals>.<listcomp>r�r$r�zaccept-encodingr�zcontent-lengthz
iso-8859-1)
�dict�fromkeysr�r�r�r�r�rUr�r�)	r*rPrQr�r@Zheader_namesZskipsrmr�r.r.r/r��s

zHTTPConnection._send_requestc	Cs�|jr$|jj�r$d|_n|jtks<|jrNt|j��n|jdkr�|j|j|jd|j�}n|j|jd|j�}y:|j	�t
|_|jr�|j�n	||_|SWn|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
        class 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.
        NrrP)
r�rtr�r�rrDr�rOrErnr�rNro)r*r�r.r.r/�getresponse�s$
		
	
zHTTPConnection.getresponse)r1r2r3r�r�rr��	HTTP_PORTr�r�rDr�r��_GLOBAL_DEFAULT_TIMEOUTrRr�r�r�r�r�ror�r�r�r�r�r�r�r�r�r�r.r.r.r/r�s2	0{cs^eZdZdZeZdddejddddd�fdd�Z�fdd�Z	�S)	�HTTPSConnectionz(This class allows communication via SSL.N�context�check_hostnamec
s�tt|�j||||�||_||_|dkrLtj�}n|jtjk}	|dkrv|j	}n|r�|	r�t
d��n|s�|r�|j||�n||_||_
dS)NzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rpr�rR�key_file�	cert_file�sslZ_create_default_https_contextZverify_modeZ	CERT_NONEr�rYZload_cert_chain�_context�_check_hostname)
r*r�r�r�r�r�r�r�r�Zwill_verify)rqr.r/rR�s		
	zHTTPSConnection.__init__cs�t�j�|jr"|j}n	|j}|jj|jd|�|_|jjr�|jr�yt	j
|jj�|�Wq�tk
r�|jj
tj�|jj��Yq�XndS)z(Connect to a host on a given (SSL) port.�server_hostnameN)rpr�r�r�r�Zwrap_socketrOr�r�r�Zmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRro)r*r�)rqr.r/r��s
		

zHTTPSConnection.connect)
r1r2r3�__doc__�
HTTPS_PORTr�r�r�rRr�r.r.)rqr/r��s	r�c@seZdZdS)rN)r1r2r3r.r.r.r/rsc@seZdZdS)rN)r1r2r3r.r.r.r/rsc@seZdZdS)rN)r1r2r3r.r.r.r/rsc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrH)r*rHr.r.r/rRszUnknownProtocol.__init__N)r1r2r3rRr.r.r.r/rsc@seZdZdS)rN)r1r2r3r.r.r.r/r"sc@seZdZdS)r	N)r1r2r3r.r.r.r/r	%sc@s7eZdZddd�Zdd�Zdd�ZdS)r
NcCs"|f|_||_||_dS)N)r��partial�expected)r*r�r�r.r.r/rR)s	zIncompleteRead.__init__cCs<|jdk	rd|j}nd}dt|j�|fS)Nz, %i more expectedrTzIncompleteRead(%i bytes read%s))r�r&r�)r*�er.r.r/�__repr__-szIncompleteRead.__repr__cCs
t|�S)N)rW)r*r.r.r/�__str__3szIncompleteRead.__str__)r1r2r3rRrrr.r.r.r/r
(sc@seZdZdS)rN)r1r2r3r.r.r.r/r6sc@seZdZdS)r
N)r1r2r3r.r.r.r/r
9sc@seZdZdS)rN)r1r2r3r.r.r.r/r<sc@seZdZdS)rN)r1r2r3r.r.r.r/r?sc@seZdZdd�ZdS)rcCs.|st|�}n|f|_||_dS)N)rWr�r-)r*r-r.r.r/rRCszBadStatusLine.__init__N)r1r2r3rRr.r.r.r/rBsc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrRr9)r*Z	line_typer.r.r/rRJszLineTooLong.__init__N)r1r2r3rRr.r.r.r/rIs)kr�Zemail.parserr=Z
email.message�ior��rer�r�Zurllib.parser�__all__r�r�rGr�r�r�reZSWITCHING_PROTOCOLSZ
PROCESSINGr!ZCREATEDZACCEPTEDZNON_AUTHORITATIVE_INFORMATIONrjZ
RESET_CONTENTZPARTIAL_CONTENTZMULTI_STATUSZIM_USEDZMULTIPLE_CHOICESZMOVED_PERMANENTLYZFOUNDZ	SEE_OTHERrkZ	USE_PROXYZTEMPORARY_REDIRECTZBAD_REQUESTZUNAUTHORIZEDZPAYMENT_REQUIREDZ	FORBIDDENZ	NOT_FOUNDZMETHOD_NOT_ALLOWEDZNOT_ACCEPTABLEZPROXY_AUTHENTICATION_REQUIREDZREQUEST_TIMEOUTZCONFLICTZGONEZLENGTH_REQUIREDZPRECONDITION_FAILEDZREQUEST_ENTITY_TOO_LARGEZREQUEST_URI_TOO_LONGZUNSUPPORTED_MEDIA_TYPEZREQUESTED_RANGE_NOT_SATISFIABLEZEXPECTATION_FAILEDZUNPROCESSABLE_ENTITYZLOCKEDZFAILED_DEPENDENCYZUPGRADE_REQUIREDZPRECONDITION_REQUIREDZTOO_MANY_REQUESTSZREQUEST_HEADER_FIELDS_TOO_LARGEZINTERNAL_SERVER_ERRORZNOT_IMPLEMENTEDZBAD_GATEWAYZSERVICE_UNAVAILABLEZGATEWAY_TIMEOUTZHTTP_VERSION_NOT_SUPPORTEDZINSUFFICIENT_STORAGEZNOT_EXTENDEDZNETWORK_AUTHENTICATION_REQUIREDrr�r9r:�compile�	fullmatchr��searchr�r�r�ZMessager"rA�	RawIOBaserrr��ImportErrorr�r)r�rrrrrr	r
rr
rrrrrr.r.r.r/�<module>Cs.			
����
0