o
    Ee$                     @  s
  d dl mZ d dlZd dlZd dlZd dlmZ d dlmZ	 ej
r9ddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZG dd deZejejdef ejedf f 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Z+G d/d0 d0eZ,G d1d2 d2e-eZ.G d3d4 d4e.Z/G d5d6 d6e.Z0G d7d8 d8eZ1G d9d: d:eZ2G d;d< d<e2Z3G d=d> d>e2Z4G d?d@ d@e2Z5G dAdB dBe2Z6G dCdD dDeZ7G dEdF dFe e-Z8G dGdH dHeZ9G dIdJ dJee	ZG dKdL dLee	Z:G dMdN dNeZ;G dOdP dPe<e0Z=G dQdR dRe-Z>G dSdT dTeZ?G dUdV dVeZ@dS )W    )annotationsN)MessageDefect)IncompleteRead   )HTTPConnection)ConnectionPool)HTTPResponse)Retryc                   @     e Zd ZdZdS )	HTTPErrorz#Base exception used by this module.N__name__
__module____qualname____doc__ r   r   S/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/urllib3/exceptions.pyr          r   c                   @  r
   )HTTPWarningz!Base warning used by this module.Nr   r   r   r   r   r      r   r   .c                      s,   e Zd ZdZd fdd	ZdddZ  ZS )	PoolErrorz/Base exception for errors caused within a pool.poolr   messagestrreturnNonec                       || _ t | d|  d S Nz: )r   super__init__)selfr   r   	__class__r   r   r   "      zPoolError.__init___TYPE_REDUCE_RESULTc                 C  s
   | j dfS )N)NNr    r   r   r   r   
__reduce__&   s   
zPoolError.__reduce__)r   r   r   r   r   r   r   r#   r   r   r   r   r   r%   __classcell__r   r   r    r   r          r   c                      s,   e Zd ZdZd fd	d
ZdddZ  ZS )RequestErrorz8Base exception for PoolErrors that have associated URLs.r   r   urlr   r   r   r   c                   s   || _ t || d S N)r+   r   r   )r   r   r+   r   r    r   r   r   .   s   zRequestError.__init__r#   c                 C  s   | j d | jd ffS r,   )r!   r+   r$   r   r   r   r%   2   s   zRequestError.__reduce__)r   r   r+   r   r   r   r   r   r&   r'   r   r   r    r   r*   +   r)   r*   c                   @  r
   )SSLErrorz9Raised when SSL certificate fails in an HTTPS connection.Nr   r   r   r   r   r-   7   r   r-   c                      s,   e Zd ZU dZded< d fd	d
Z  ZS )
ProxyErrorz,Raised when the connection to a proxy fails.	Exceptionoriginal_errorr   r   errorr   r   c                   s   t  || || _d S r,   )r   r   r0   )r   r   r1   r    r   r   r   A   s   
zProxyError.__init__)r   r   r1   r/   r   r   )r   r   r   r   __annotations__r   r(   r   r   r    r   r.   ;   s   
 r.   c                   @  r
   )DecodeErrorz;Raised when automatic decoding based on Content-Type fails.Nr   r   r   r   r   r3   F   r   r3   c                   @  r
   )ProtocolErrorz>Raised when something unexpected happens mid-request/response.Nr   r   r   r   r   r4   J   r   r4   c                      &   e Zd ZdZ	dd fddZ  ZS )MaxRetryErrora  Raised when the maximum number of retries is exceeded.

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

    Nr   r   r+   r   reasonException | Noner   r   c                   s,   || _ d| d|d}t ||| d S )NzMax retries exceeded with url: z (Caused by ))r7   r   r   )r   r   r+   r7   r   r    r   r   r   `   s   zMaxRetryError.__init__r,   )r   r   r+   r   r7   r8   r   r   r   r   r   r   r   r(   r   r   r    r   r6   U   s    r6   c                      r5   )HostChangedErrorz?Raised when an existing pool gets a request for a foreign host.   r   r   r+   r   retriesRetry | intr   r   c                   s$   d| }t  ||| || _d S )Nz'Tried to open a foreign host with url: )r   r   r=   )r   r   r+   r=   r   r    r   r   r   m   s   

zHostChangedError.__init__)r<   )r   r   r+   r   r=   r>   r   r   r:   r   r   r    r   r;   j   s    r;   c                   @  r
   )TimeoutStateErrorz1Raised when passing an invalid state to a timeoutNr   r   r   r   r   r?   u   r   r?   c                   @  r
   )TimeoutErrorzRaised when a socket timeout error occurs.

    Catching this error will catch both :exc:`ReadTimeoutErrors
    <ReadTimeoutError>` and :exc:`ConnectTimeoutErrors <ConnectTimeoutError>`.
    Nr   r   r   r   r   r@   y   r   r@   c                   @  r
   )ReadTimeoutErrorzFRaised when a socket timeout occurs while receiving data from a serverNr   r   r   r   r   rA      r   rA   c                   @  r
   )ConnectTimeoutErrorz@Raised when a socket timeout occurs while connecting to a serverNr   r   r   r   r   rB      r   rB   c                      s0   e Zd ZdZd fdd	Zedd
dZ  ZS )NewConnectionErrorzHRaised when we fail to establish a new connection. Usually ECONNREFUSED.connr   r   r   r   r   c                   r   r   )rD   r   r   )r   rD   r   r    r   r   r      r"   zNewConnectionError.__init__c                 C  s   t jdtdd | jS )Nz\The 'pool' property is deprecated and will be removed in urllib3 v2.1.0. Use 'conn' instead.   )
stacklevel)warningswarnDeprecationWarningrD   r$   r   r   r   r      s   zNewConnectionError.pool)rD   r   r   r   r   r   )r   r   )r   r   r   r   r   propertyr   r(   r   r   r    r   rC      s
    rC   c                      "   e Zd ZdZd
 fdd	Z  ZS )NameResolutionErrorz'Raised when host name resolution fails.hostr   rD   r   r7   socket.gaierrorc                   s$   d| d| d}t  || d S )NzFailed to resolve 'z' (r9   r   r   )r   rM   rD   r7   r   r    r   r   r      s   zNameResolutionError.__init__)rM   r   rD   r   r7   rN   r:   r   r   r    r   rL          rL   c                   @  r
   )EmptyPoolErrorzCRaised when a pool runs out of connections and no more are allowed.Nr   r   r   r   r   rQ      r   rQ   c                   @  r
   )FullPoolErrorzGRaised when we try to add a connection to a full pool in blocking mode.Nr   r   r   r   r   rR      r   rR   c                   @  r
   )ClosedPoolErrorzCRaised when a request enters a pool after the pool has been closed.Nr   r   r   r   r   rS      r   rS   c                   @  r
   )LocationValueErrorz<Raised when there is something wrong with a given URL input.Nr   r   r   r   r   rT      r   rT   c                      "   e Zd ZdZd fddZ  ZS )	LocationParseErrorz=Raised when get_host or similar fails to parse the URL input.locationr   r   r   c                       d| }t  | || _d S )NzFailed to parse: )r   r   rW   )r   rW   r   r    r   r   r         

zLocationParseError.__init__)rW   r   r   r   r:   r   r   r    r   rV      rP   rV   c                      s"   e Zd ZdZd fddZ  ZS )URLSchemeUnknownz2Raised when a URL input has an unsupported scheme.schemer   c                   rX   )NzNot supported URL scheme )r   r   r[   r   r[   r   r    r   r   r      rY   zURLSchemeUnknown.__init__)r[   r   r:   r   r   r    r   rZ      rP   rZ   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
   )InsecureRequestWarningz/Warned when making an unverified HTTPS request.Nr   r   r   r   r   ra      r   ra   c                   @  r
   )NotOpenSSLWarningz)Warned when using unsupported SSL libraryNr   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
   )DependencyWarningzc
    Warned when an attempt is made to import a module with missing optional
    dependencies.
    Nr   r   r   r   r   re      r   re   c                   @  r
   )ResponseNotChunkedz;Response needs to be chunked in order to read it as chunks.Nr   r   r   r   r   rf      r   rf   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   rg      r   rg   c                   @  s$   e Zd ZdZdddZdd
dZd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.
    partialintexpectedr   r   c                 C  s   || _ || _d S r,   rh   rj   )r   rh   rj   r   r   r   r      s   
zIncompleteRead.__init__r   c                 C     d| j | jf S )Nz/IncompleteRead(%i bytes read, %i more expected)rk   r$   r   r   r   __repr__     zIncompleteRead.__repr__N)rh   ri   rj   ri   r   r   r   r   r   r   r   r   r   rm   r   r   r   r   r      s    
r   c                   @  s$   e Zd ZdZddd	ZdddZdS )InvalidChunkLengthz+Invalid chunk length in a chunked response.responser   lengthbytesr   r   c                 C  s"   |  | _|j| _|| _|| _d S r,   )tellrh   length_remainingrj   rr   rs   )r   rr   rs   r   r   r   r     s   

zInvalidChunkLength.__init__r   c                 C  rl   )Nz0InvalidChunkLength(got length %r, %i bytes read))rs   rh   r$   r   r   r   rm     rn   zInvalidChunkLength.__repr__N)rr   r   rs   rt   r   r   ro   rp   r   r   r   r   rq   
  s    
rq   c                   @  r
   )InvalidHeaderz(The header provided was somehow invalid.Nr   r   r   r   r   rw     r   rw   c                      rU   )	ProxySchemeUnknownz1ProxyManager does not support the supplied schemer[   
str | Noner   r   c                   s6   |dkrd }|d u rd}nd| d}t  | d S )N	localhostz>Proxy URL had no scheme, should start with http:// or https://z!Proxy URL had unsupported scheme z , should use http:// or https://rO   r\   r    r   r   r   #  s   zProxySchemeUnknown.__init__)r[   ry   r   r   r:   r   r   r    r   rx     s    rx   c                   @  r
   )ProxySchemeUnsupportedz=Fetching HTTPS resources through HTTPS proxies is unsupportedNr   r   r   r   r   r{   /  r   r{   c                      rK   )HeaderParsingErrorzNRaised by assert_header_parsing, but we convert it to a log.warning statement.defectslist[MessageDefect]unparsed_databytes | str | Noner   r   c                   s"   |pd d|}t  | d S )NUnknownz, unparsed data: rO   )r   r}   r   r   r    r   r   r   6  s   zHeaderParsingError.__init__)r}   r~   r   r   r   r   r:   r   r   r    r   r|   3  rP   r|   c                   @  r
   )UnrewindableBodyErrorz9urllib3 encountered an error when trying to rewind a bodyNr   r   r   r   r   r   =  r   r   )A
__future__r   sockettypingrG   email.errorsr   http.clientr   httplib_IncompleteReadTYPE_CHECKING
connectionr   connectionpoolr   rr   r   
util.retryr	   r/   r   Warningr   TupleCallableobjectr#   r   r*   r-   r.   r3   r4   ConnectionErrorr6   r;   r?   r@   rA   rB   rC   rL   rQ   rR   rS   
ValueErrorrT   rV   rZ   r]   r`   ra   rb   rc   rd   re   rf   rg   rq   rw   AssertionErrorrx   r{   r|   r   r   r   r   r   <module>   sj    


