MINI MINI MANI MO
3
  \                 @   sV  d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ dddddd	d
ddd
ddddddddgZdZ
dZdZdZdZdZe jejj dd ejjj D ZdZdZd Zejd!jZejd"jZ d#d$d%hZ!d?d'd(Z"G d)d* d*ej#j$Z%e%fd+d,Z&G d-d dej'Z(G d.d dZ)yddl*Z*W n e+k
rP   Y nX G d/d0 d0e)Z,ej-d0 G d1d de.Z/G d2d de/Z0G d3d de/Z1G d4d de/Z2G d5d	 d	e/Z3G d6d
 d
e/Z4G d7d de/Z5G d8d
 d
e/Z6G d9d de6Z7G d:d de6Z8G d;d de6Z9G d<d de/Z:G d=d de/Z;G d>d de<e:Z=e/Z>dS )@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
      |\_____________________________
      |                              | 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)urlsplitHTTPResponseHTTPConnection
HTTPExceptionNotConnectedUnknownProtocolUnknownTransferEncodingUnimplementedFileModeIncompleteRead
InvalidURLImproperConnectionStateCannotSendRequestCannotSendHeaderResponseNotReady
BadStatusLineLineTooLongRemoteDisconnectederror	responsesP   i  ZUNKNOWNZIdlezRequest-startedzRequest-sentc             C   s   i | ]}|j |qS  )phrase).0vr   r   #/usr/lib64/python3.6/http/client.py
<dictcomp>k   s    r   i   i   d   s   [^:\s][^:\r\n]*s   \n(?![ \t])|\r(?![ \t\n])ZPATCHZPOSTZPUTdatac             C   sf   y
| j dS  tk
r` } z:t|j|j|j|jd|j | |j|j |f dW Y dd}~X nX dS )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)r   nameerrr   r   r   _encode   s    
r'   c               @   s   e Zd Zdd ZdS )HTTPMessagec             C   sn   |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.
        :r   N   )lowerlenkeysisspaceappend)selfr%   nZlstZhitliner   r   r   getallmatchingheaders   s    
z!HTTPMessage.getallmatchingheadersN)__name__
__module____qualname__r3   r   r   r   r   r(      s   r(   c             C   s|   g }xR| j td }t|tkr(td|j| t|tkrJtdt |d	krP qW dj|jd}t	j
j|dj|S )
aG  Parses 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)r7   r8   r9   )
readline_MAXLINEr,   r   r/   _MAXHEADERSr   joindecodeemailparserZParserZparsestr)fpr:   headersr2   Zhstringr   r   r   
parse_headers   s    
rD   c                   s  e Zd Zd@ddZdd Zdd Zd	d
 Zdd Z fd
dZ fddZ	dd Z
dd ZdAddZdd Z
dd Zdd Zdd Zdd  Zd!d"