o
    Ñà7e   ã                   @   s~  d dl mZ d dlmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZ	G d	d
„ d
e	ƒZ
G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZeZG dd„ de
ƒZG dd„ de
ƒZG dd„ deƒZG dd„ deƒZG dd„ dee
ƒZG dd„ deƒZG dd „ d ee	ƒZG d!d"„ d"e	ƒZG d#d$„ d$e	ƒZG d%d&„ d&eeƒZG d'd(„ d(eƒZG d)d*„ d*eƒZG d+d,„ d,eƒZG d-d.„ d.eƒZG d/d0„ d0eƒZG d1d2„ d2eƒZ G d3d4„ d4eƒZ!G d5d6„ d6eƒZ"G d7d8„ d8eƒZ#G d9d:„ d:eƒZ$G d;d<„ d<eeƒZ%G d=d>„ d>eƒZ&G d?d@„ d@eeƒZG dAdB„ dBeeƒZ'G dCdD„ dDeƒZ(G dEdF„ dFe)eƒZ*G dGdH„ dHeƒZ+G dIdJ„ dJeƒZ,G dKdL„ dLeƒZ-dMS )Né    )Úabsolute_import)ÚIncompleteReadc                   @   ó   e Zd ZdZdS )Ú	HTTPErrorz#Base exception used by this module.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú4/usr/lib/python3/dist-packages/urllib3/exceptions.pyr      ó    r   c                   @   r   )ÚHTTPWarningz!Base warning used by this module.Nr   r   r   r   r   r      r   r   c                   @   ó    e Zd ZdZdd„ Zdd„ ZdS )Ú	PoolErrorz/Base exception for errors caused within a pool.c                 C   s   || _ t | d||f ¡ d S )Nz%s: %s)Úpoolr   Ú__init__)Úselfr   Úmessager   r   r   r      s   zPoolError.__init__c                 C   s
   | j dfS )N)NN©Ú	__class__©r   r   r   r   Ú
__reduce__   s   
zPoolError.__reduce__N©r   r   r	   r
   r   r   r   r   r   r   r      ó    r   c                   @   r   )ÚRequestErrorz8Base exception for PoolErrors that have associated URLs.c                 C   s   || _ t | ||¡ d S ©N)Úurlr   r   )r   r   r   r   r   r   r   r   #   s   zRequestError.__init__c                 C   s   | j d | jd ffS r   )r   r   r   r   r   r   r   '   s   zRequestError.__reduce__Nr   r   r   r   r   r       r   r   c                   @   r   )ÚSSLErrorz9Raised when SSL certificate fails in an HTTPS connection.Nr   r   r   r   r   r   ,   r   r   c                       ó    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
ProxyErrorz,Raised when the connection to a proxy fails.c                    s$   t t| ƒj||g|¢R Ž  || _d S r   )Úsuperr    r   Úoriginal_error)r   r   ÚerrorÚargsr   r   r   r   5   s   
zProxyError.__init__©r   r   r	   r
   r   Ú__classcell__r   r   r   r   r    2   ó    r    c                   @   r   )ÚDecodeErrorz;Raised when automatic decoding based on Content-Type fails.Nr   r   r   r   r   r(   :   r   r(   c                   @   r   )ÚProtocolErrorz>Raised when something unexpected happens mid-request/response.Nr   r   r   r   r   r)   @   r   r)   c                   @   s   e Zd ZdZddd„ZdS )ÚMaxRetryErrora  Raised when the maximum number of retries is exceeded.

    :param pool: The connection pool
    :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
    :param string url: The requested Url
    :param exceptions.Exception reason: The underlying error

    Nc                 C   s&   || _ d||f }t | |||¡ d S )Nz0Max retries exceeded with url: %s (Caused by %r))Úreasonr   r   )r   r   r   r+   r   r   r   r   r   W   s   zMaxRetryError.__init__r   ©r   r   r	   r
   r   r   r   r   r   r*   M   s    	r*   c                   @   s   e Zd ZdZddd„ZdS )ÚHostChangedErrorz?Raised when an existing pool gets a request for a foreign host.é   c                 C   s"   d| }t  | |||¡ || _d S )Nz)Tried to open a foreign host with url: %s)r   r   Úretries)r   r   r   r/   r   r   r   r   r   b   s   
zHostChangedError.__init__N)r.   r,   r   r   r   r   r-   _   s    r-   c                   @   r   )ÚTimeoutStateErrorz1Raised when passing an invalid state to a timeoutNr   r   r   r   r   r0   h   r   r0   c                   @   r   )ÚTimeoutErrorz¿Raised when a socket timeout error occurs.

    Catching this error will catch both :exc:`ReadTimeoutErrors
    <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
    Nr   r   r   r   r   r1   n   s    r1   c                   @   r   )ÚReadTimeoutErrorzFRaised when a socket timeout occurs while receiving data from a serverNr   r   r   r   r   r2   x   r   r2   c                   @   r   )ÚConnectTimeoutErrorz@Raised when a socket timeout occurs while connecting to a serverNr   r   r   r   r   r3   €   r   r3   c                   @   r   )ÚNewConnectionErrorzHRaised when we fail to establish a new connection. Usually ECONNREFUSED.Nr   r   r   r   r   r4   †   r   r4   c                   @   r   )ÚEmptyPoolErrorzCRaised when a pool runs out of connections and no more are allowed.Nr   r   r   r   r   r5   Œ   r   r5   c                   @   r   )ÚClosedPoolErrorzCRaised when a request enters a pool after the pool has been closed.Nr   r   r   r   r   r6   ’   r   r6   c                   @   r   )ÚLocationValueErrorz<Raised when there is something wrong with a given URL input.Nr   r   r   r   r   r7   ˜   r   r7   c                   @   s   e Zd ZdZdd„ ZdS )ÚLocationParseErrorz=Raised when get_host or similar fails to parse the URL input.c                 C   s   d| }t  | |¡ || _d S )NzFailed to parse: %s)r   r   Úlocation)r   r9   r   r   r   r   r   ¡   s   
zLocationParseError.__init__Nr,   r   r   r   r   r8   ž   s    r8   c                       r   )ÚURLSchemeUnknownz2Raised when a URL input has an unsupported scheme.c                    s"   d| }t t| ƒ |¡ || _d S )NzNot supported URL scheme %s)r!   r:   r   Úscheme©r   r;   r   r   r   r   r   «   s   
zURLSchemeUnknown.__init__r%   r   r   r   r   r:   ¨   r'   r:   c                   @   s   e Zd ZdZdZdZdS )ÚResponseErrorzDUsed as a container for an error reason supplied in a MaxRetryError.ztoo many error responsesz&too many {status_code} error responsesN)r   r   r	   r
   ÚGENERIC_ERRORÚSPECIFIC_ERRORr   r   r   r   r=   ²   s    r=   c                   @   r   )ÚSecurityWarningz0Warned when performing security reducing actionsNr   r   r   r   r   r@   ¹   r   r@   c                   @   r   )ÚSubjectAltNameWarningzBWarned when connecting to a host with a certificate missing a SAN.Nr   r   r   r   r   rA   ¿   r   rA   c                   @   r   )ÚInsecureRequestWarningz/Warned when making an unverified HTTPS request.Nr   r   r   r   r   rB   Å   r   rB   c                   @   r   )ÚSystemTimeWarningz0Warned when system time is suspected to be wrongNr   r   r   r   r   rC   Ë   r   rC   c                   @   r   )ÚInsecurePlatformWarningzIWarned when certain TLS/SSL configuration is not available on a platform.Nr   r   r   r   r   rD   Ñ   r   rD   c                   @   r   )ÚSNIMissingWarningz9Warned when making a HTTPS request without SNI available.Nr   r   r   r   r   rE   ×   r   rE   c                   @   r   )ÚDependencyWarningzc
    Warned when an attempt is made to import a module with missing optional
    dependencies.
    Nr   r   r   r   r   rF   Ý   ó    rF   c                   @   r   )ÚResponseNotChunkedz;Response needs to be chunked in order to read it as chunks.Nr   r   r   r   r   rH   æ   r   rH   c                   @   r   )ÚBodyNotHttplibCompatiblez‡
    Body should be :class:`http.client.HTTPResponse` like
    (have an fp attribute which returns raw chunks) for read_chunked().
    Nr   r   r   r   r   rI   ì   rG   rI   c                       ó(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )r   zÎ
    Response length doesn't match expected Content-Length

    Subclass of :class:`http.client.IncompleteRead` to allow int value
    for ``partial`` to avoid creating large objects on streamed reads.
    c                    s   t t| ƒ ||¡ d S r   )r!   r   r   )r   ÚpartialÚexpectedr   r   r   r   ý   s   zIncompleteRead.__init__c                 C   ó   d| j | jf S )Nz/IncompleteRead(%i bytes read, %i more expected))rK   rL   r   r   r   r   Ú__repr__   ó   þzIncompleteRead.__repr__©r   r   r	   r
   r   rN   r&   r   r   r   r   r   õ   s    r   c                       rJ   )ÚInvalidChunkLengthz+Invalid chunk length in a chunked response.c                    s(   t t| ƒ | ¡ |j¡ || _|| _d S r   )r!   rQ   r   ÚtellÚlength_remainingÚresponseÚlength)r   rT   rU   r   r   r   r   
  s
   

ÿ
zInvalidChunkLength.__init__c                 C   rM   )Nz0InvalidChunkLength(got length %r, %i bytes read))rU   rK   r   r   r   r   rN     rO   zInvalidChunkLength.__repr__rP   r   r   r   r   rQ     s    rQ   c                   @   r   )ÚInvalidHeaderz(The header provided was somehow invalid.Nr   r   r   r   r   rV     r   rV   c                       r   )ÚProxySchemeUnknownz1ProxyManager does not support the supplied schemec                    s6   |dkrd }|d u rd}nd| }t t| ƒ |¡ d S )NÚ	localhostz>Proxy URL had no scheme, should start with http:// or https://zCProxy URL had unsupported scheme %s, should use http:// or https://)r!   rW   r   r<   r   r   r   r   #  s   ÿÿzProxySchemeUnknown.__init__r%   r   r   r   r   rW     s    rW   c                   @   r   )ÚProxySchemeUnsupportedz=Fetching HTTPS resources through HTTPS proxies is unsupportedNr   r   r   r   r   rY   2  r   rY   c                       r   )ÚHeaderParsingErrorzNRaised by assert_header_parsing, but we convert it to a log.warning statement.c                    s$   d|pd|f }t t| ƒ |¡ d S )Nz%s, unparsed data: %rÚUnknown)r!   rZ   r   )r   ÚdefectsÚunparsed_datar   r   r   r   r   ;  s   zHeaderParsingError.__init__r%   r   r   r   r   rZ   8  r'   rZ   c                   @   r   )ÚUnrewindableBodyErrorz9urllib3 encountered an error when trying to rewind a bodyNr   r   r   r   r   r^   @  r   r^   N).Ú
__future__r   Úsix.moves.http_clientr   Úhttplib_IncompleteReadÚ	Exceptionr   ÚWarningr   r   r   r   r    r(   r)   ÚConnectionErrorr*   r-   r0   r1   r2   r3   r4   r5   r6   Ú
ValueErrorr7   r8   r:   r=   r@   rA   rB   rC   rD   rE   rF   rH   rI   rQ   rV   ÚAssertionErrorrW   rY   rZ   r^   r   r   r   r   Ú<module>   sP    	


		