a
    Rf)                     @   s  d Z ddlZddlZddlmZmZmZmZ ddlm	Z	 ddl
mZmZ zddlZejZW n eyt   d ZZY n0 erddlmZmZmZmZ nd Z ZZd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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#ej%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/d0 d0e,Z-G d1d2 d2eZ.G d3d4 d4eZ/G d5d6 d6e-e.Z0G d7d8 d8e/e.Z1G d9d: d:e Z2edurpej3fZ4e2ej3fZ5ej6fZ7e2ej6fZ8ne9 Z4e2e+fZ5e9 Z7e2fZ8G d;d< d<ge8R  Z:G d=d> d>ge5R  Z;dS )?zHTTP related errors.    N)TYPE_CHECKINGOptionalTupleUnion   )RawResponseMessage)LooseHeadersStrOrURL)ClientResponseConnectionKeyFingerprintRequestInfo)ClientErrorClientConnectionErrorClientOSErrorClientConnectorErrorClientProxyConnectionErrorClientSSLErrorClientConnectorSSLErrorClientConnectorCertificateErrorConnectionTimeoutErrorSocketTimeoutErrorServerConnectionErrorServerTimeoutErrorServerDisconnectedErrorServerFingerprintMismatchClientResponseErrorClientHttpProxyErrorWSServerHandshakeErrorContentTypeErrorClientPayloadError
InvalidURLInvalidUrlClientErrorRedirectClientErrorNonHttpUrlClientErrorInvalidUrlRedirectClientErrorNonHttpUrlRedirectClientErrorc                   @   s   e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r,   r,   R/var/www/ai-form-bot/venv/lib/python3.9/site-packages/aiohttp/client_exceptions.pyr   4   s   r   c                	   @   s   e Zd ZdZdddddeeedf ee ee e	ee
 ddddZe	d	d
dZe	d	ddZeed	ddZejeddddZdS )r   a  Base class for exceptions that occur after getting a response.

    request_info: An instance of RequestInfo.
    history: A sequence of responses, if redirects occurred.
    status: HTTP status code.
    message: Error message.
    headers: Response headers.
    N )codestatusmessageheaders.)request_infohistoryr/   r0   r1   r2   returnc                C   st   || _ |d ur.|d urtdtjdtdd |d ur>|| _n|d urN|| _nd| _|| _|| _|| _||f| _	d S )NzSBoth code and status arguments are provided; code is deprecated, use status insteadz/code argument is deprecated, use status instead   
stacklevelr   )
r3   
ValueErrorwarningswarnDeprecationWarningr0   r1   r2   r4   args)selfr3   r4   r/   r0   r1   r2   r,   r,   r-   __init__B   s(    
zClientResponseError.__init__r5   c                 C   s   d | j| jt| jjS )Nz{}, message={!r}, url={!r})formatr0   r1   strr3   Zreal_urlr>   r,   r,   r-   __str__c   s
    
zClientResponseError.__str__c                 C   sv   | j d| j}| jdkr,|d| j7 }| jdkrF|d| j7 }| jd ur`|d| j7 }t| j d| dS )	Nz, r   z	, status=r.   z
, message=z
, headers=())r3   r4   r0   r1   r2   typer(   )r>   r=   r,   r,   r-   __repr__j   s    


zClientResponseError.__repr__c                 C   s   t jdtdd | jS Nz/code property is deprecated, use status insteadr6   r7   r:   r;   r<   r0   rC   r,   r,   r-   r/   t   s    zClientResponseError.code)valuer5   c                 C   s   t jdtdd || _d S rI   rJ   )r>   rK   r,   r,   r-   r/   }   s    )r(   r)   r*   r+   r   r   r
   r   intrB   r   r?   rD   rH   propertyr/   setterr,   r,   r,   r-   r   8   s(   
!
r   c                   @   s   e Zd ZdZdS )r   zContentType found is not valid.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   z!websocket server handshake error.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zHTTP proxy error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
    proxy responds with status other than ``200 OK``
    on ``CONNECT`` request.
    Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )TooManyRedirectsz%Client was redirected too many times.Nr'   r,   r,   r,   r-   rO      s   rO   c                   @   s   e Zd ZdZdS )r   z$Base class for client socket errors.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zOSError error.Nr'   r,   r,   r,   r-   r      s   r   c                       s   e Zd ZdZeedd fddZeedddZee	dd	d
Z
eee dddZeeeedf dddZe	dddZejZ  ZS )r   zClient connector error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        a connection can not be established.
    N)connection_keyos_errorr5   c                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperr?   errnostrerrorr=   )r>   rP   rQ   	__class__r,   r-   r?      s    zClientConnectorError.__init__r@   c                 C   s   | j S rR   )rT   rC   r,   r,   r-   rQ      s    zClientConnectorError.os_errorc                 C   s   | j jS rR   rS   hostrC   r,   r,   r-   r[      s    zClientConnectorError.hostc                 C   s   | j jS rR   rS   portrC   r,   r,   r-   r]      s    zClientConnectorError.portr   c                 C   s   | j jS rR   )rS   sslrC   r,   r,   r-   r^      s    zClientConnectorError.sslc                 C   s    d | | jdu rdn| j| jS )Nz6Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]TdefaultrA   r^   rW   rC   r,   r,   r-   rD      s    zClientConnectorError.__str__)r(   r)   r*   r+   r   OSErrorr?   rM   rQ   rB   r[   r   rL   r]   r   
SSLContextboolr^   rD   BaseException
__reduce____classcell__r,   r,   rX   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zProxy connection error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        connection to proxy can not be established.
    Nr'   r,   r,   r,   r-   r      s   r   c                       sL   e Zd ZdZeeedd fddZeedddZ	edd	d
Z
  ZS )UnixClientConnectorErrorzUnix connector error.

    Raised in :py:class:`aiohttp.connector.UnixConnector`
    if connection to unix socket can not be established.
    N)pathrP   rQ   r5   c                    s   || _ t || d S rR   )_pathrU   r?   )r>   rh   rP   rQ   rX   r,   r-   r?      s    z!UnixClientConnectorError.__init__r@   c                 C   s   | j S rR   )ri   rC   r,   r,   r-   rh      s    zUnixClientConnectorError.pathc                 C   s    d | | jdu rdn| j| jS )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Tr_   r`   rC   r,   r,   r-   rD      s    z UnixClientConnectorError.__str__)r(   r)   r*   r+   rB   r   ra   r?   rM   rh   rD   rf   r,   r,   rX   r-   rg      s   rg   c                   @   s   e Zd ZdZdS )r   zServer connection errors.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s,   e Zd ZdZdeeedf ddddZdS )r   zServer disconnected.N)r1   r5   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r=   r1   )r>   r1   r,   r,   r-   r?      s    z ServerDisconnectedError.__init__)N)r(   r)   r*   r+   r   r   rB   r?   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zServer timeout error.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zConnection timeout error.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s   e Zd ZdZdS )r   zSocket timeout error.Nr'   r,   r,   r,   r-   r      s   r   c                   @   s4   e Zd ZdZeeeeddddZedddZdS )	r   z4SSL certificate does not match expected fingerprint.N)expectedgotr[   r]   r5   c                 C   s*   || _ || _|| _|| _||||f| _d S rR   )rj   rk   r[   r]   r=   )r>   rj   rk   r[   r]   r,   r,   r-   r?     s
    z"ServerFingerprintMismatch.__init__r@   c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)rA   rY   r(   rj   rk   r[   r]   rC   r,   r,   r-   rH     s    z"ServerFingerprintMismatch.__repr__)	r(   r)   r*   r+   bytesrB   rL   r?   rH   r,   r,   r,   r-   r     s   r   c                   @   s   e Zd ZdZdS )r    zResponse payload error.Nr'   r,   r,   r,   r-   r      s   r    c                       st   e Zd ZdZdeeedf dd fddZeedddZ	ed	dd
dZ
edddZedddZ  ZS )r!   zbInvalid URL.

    URL used for fetching is malformed, e.g. it doesn't contains host
    part.
    N)urldescriptionr5   c                    s0   || _ || _|r t || nt | d S rR   )_url_descriptionrU   r?   )r>   rm   rn   rX   r,   r-   r?   !  s
    zInvalidURL.__init__r@   c                 C   s   | j S rR   )ro   rC   r,   r,   r-   rm   ,  s    zInvalidURL.urlz
str | Nonec                 C   s   | j S rR   )rp   rC   r,   r,   r-   rn   0  s    zInvalidURL.descriptionc                 C   s   d| j j d|  dS )N< >)rY   r(   rC   r,   r,   r-   rH   4  s    zInvalidURL.__repr__c                 C   s"   | j r| j d| j  S t| jS )Nz - )rp   ro   rB   rC   r,   r,   r-   rD   7  s    zInvalidURL.__str__)N)r(   r)   r*   r+   r	   r   rB   r?   rM   rm   rn   rH   rD   rf   r,   r,   rX   r-   r!     s    r!   c                   @   s   e Zd ZdZdS )r"   zInvalid URL client error.Nr'   r,   r,   r,   r-   r"   =  s   r"   c                   @   s   e Zd ZdZdS )r#   zClient redirect error.Nr'   r,   r,   r,   r-   r#   A  s   r#   c                   @   s   e Zd ZdZdS )r$   zNon http URL client error.Nr'   r,   r,   r,   r-   r$   E  s   r$   c                   @   s   e Zd ZdZdS )r%   z"Invalid URL redirect client error.Nr'   r,   r,   r,   r-   r%   I  s   r%   c                   @   s   e Zd ZdZdS )r&   z#Non http URL redirect client error.Nr'   r,   r,   r,   r-   r&   M  s   r&   c                   @   s   e Zd ZdZdS )r   zBase error for ssl.*Errors.Nr'   r,   r,   r,   r-   r   Q  s   r   c                   @   s   e Zd ZdZdS )r   zResponse ssl error.Nr'   r,   r,   r,   r-   r   i  s   r   c                   @   s|   e Zd ZdZeeddddZeedddZee	dd	d
Z
eee dddZeedddZe	dddZdS )r   zResponse certificate error.N)rP   certificate_errorr5   c                 C   s   || _ || _||f| _d S rR   )rS   _certificate_errorr=   )r>   rP   rt   r,   r,   r-   r?   p  s    z(ClientConnectorCertificateError.__init__r@   c                 C   s   | j S rR   )ru   rC   r,   r,   r-   rt   w  s    z1ClientConnectorCertificateError.certificate_errorc                 C   s   | j jS rR   rZ   rC   r,   r,   r-   r[   {  s    z$ClientConnectorCertificateError.hostc                 C   s   | j jS rR   r\   rC   r,   r,   r-   r]     s    z$ClientConnectorCertificateError.portc                 C   s   | j jS rR   )rS   Zis_sslrC   r,   r,   r-   r^     s    z#ClientConnectorCertificateError.sslc                 C   s
   d | S )Nz{Cannot connect to host {0.host}:{0.port} ssl:{0.ssl} [{0.certificate_error.__class__.__name__}: {0.certificate_error.args}])rA   rC   r,   r,   r-   rD     s    z'ClientConnectorCertificateError.__str__)r(   r)   r*   r+   r   	Exceptionr?   rM   rt   rB   r[   r   rL   r]   rc   r^   rD   r,   r,   r,   r-   r   m  s   r   )<r+   Zasyncior:   typingr   r   r   r   Zhttp_parserr   Ztypedefsr   r	   r^   rb   ImportErrorZclient_reqrepr
   r   r   r   __all__rv   r   r   r   r   r   rO   r   ra   r   r   r   rg   r   r   TimeoutErrorr   r   r   r   r    r9   r!   r"   r#   r$   r%   r&   r   CertificateErrorZcert_errorsZcert_errors_basesSSLErrorZ
ssl_errorsZssl_error_basestupler   r   r,   r,   r,   r-   <module>   sl   
O	&%
