o
    n~b=$                     @   sD  d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
 ddlmZ z	ddlZejZW n ey:   d ZZY nw erJd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e)Z*G d+d, d,e Z+edurej,fZ-e+ej,fZ.ej/fZ0e+ej/fZ1ne2 Z-e+e)fZ.e2 Z0e+fZ1G d-d. d.ge1R  Z3G d/d0 d0ge.R  Z4dS )1zHTTP related errors.    N)TYPE_CHECKINGAnyOptionalTupleUnion   )RawResponseMessage)LooseHeaders)ClientResponseConnectionKeyFingerprintRequestInfo)ClientErrorClientConnectionErrorClientOSErrorClientConnectorErrorClientProxyConnectionErrorClientSSLErrorClientConnectorSSLErrorClientConnectorCertificateErrorServerConnectionErrorServerTimeoutErrorServerDisconnectedErrorServerFingerprintMismatchClientResponseErrorClientHttpProxyErrorWSServerHandshakeErrorContentTypeErrorClientPayloadError
InvalidURLc                   @      e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r&   r&   D/usr/local/lib/python3.10/dist-packages/aiohttp/client_exceptions.pyr   -       r   c                   @   s   e Zd ZdZddddddedeedf dee d	ee d
e	dee
 ddfddZde	fddZde	fddZedefddZejdeddfddZdS )r   zYConnection error during reading response.

    request_info: instance of RequestInfo
    N )codestatusmessageheadersrequest_infohistory.r*   r+   r,   r-   returnc                C   st   || _ |d ur|d urtdtjdtdd |d ur|| _n|d ur'|| _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   )
r.   
ValueErrorwarningswarnDeprecationWarningr+   r,   r-   r/   args)selfr.   r/   r*   r+   r,   r-   r&   r&   r'   __init__7   s(   
zClientResponseError.__init__c                 C   s   d | j| j| jjS )Nz{}, message={!r}, url={!r})formatr+   r,   r.   Zreal_urlr9   r&   r&   r'   __str__X   s
   zClientResponseError.__str__c                 C   sv   | j d| j}| jdkr|d| j7 }| jdkr#|d| j7 }| jd ur0|d| j7 }t| j d| dS )	Nz, r   z	, status=r)   z
, message=z
, headers=())r.   r/   r+   r,   r-   typer"   )r9   r8   r&   r&   r'   __repr___   s   


zClientResponseError.__repr__c                 C   s   t jdtdd | jS Nz/code property is deprecated, use status insteadr1   r2   r5   r6   r7   r+   r<   r&   r&   r'   r*   i   s   zClientResponseError.codevaluec                 C   s   t jdtdd || _d S rB   rC   )r9   rD   r&   r&   r'   r*   r   s   
)r"   r#   r$   r%   r   r   r
   r   intstrr	   r:   r=   rA   propertyr*   setterr&   r&   r&   r'   r   1   s6    

	
!
r   c                   @   r    )r   zContentType found is not valid.Nr!   r&   r&   r&   r'   r   |   r(   r   c                   @   r    )r   z!websocket server handshake error.Nr!   r&   r&   r&   r'   r      r(   r   c                   @   r    )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      r(   r   c                   @   r    )TooManyRedirectsz%Client was redirected too many times.Nr!   r&   r&   r&   r'   rI      r(   rI   c                   @   r    )r   z$Base class for client socket errors.Nr!   r&   r&   r&   r'   r      r(   r   c                   @   r    )r   zOSError error.Nr!   r&   r&   r&   r'   r      r(   r   c                       s   e Zd ZdZdededdf fddZedefdd	Zede	fd
dZ
edee fddZedeededf fddZde	fddZejZ  ZS )r   zClient connector error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        connection to proxy can not be established.
    connection_keyos_errorr0   Nc                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperr:   errnostrerrorr8   )r9   rJ   rK   	__class__r&   r'   r:      s   zClientConnectorError.__init__c                 C      | j S rL   )rN   r<   r&   r&   r'   rK         zClientConnectorError.os_errorc                 C      | j jS rL   rM   hostr<   r&   r&   r'   rX         zClientConnectorError.hostc                 C   rV   rL   rM   portr<   r&   r&   r'   r[      rY   zClientConnectorError.portr   c                 C   rV   rL   )rM   sslr<   r&   r&   r'   r\      rY   zClientConnectorError.sslc                 C   &   d | | jd ur| j| jS d| jS )Nz6Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]defaultr;   r\   rQ   r<   r&   r&   r'   r=      
   zClientConnectorError.__str__)r"   r#   r$   r%   r   OSErrorr:   rG   rK   rF   rX   r   rE   r[   r   
SSLContextboolr\   r=   BaseException
__reduce____classcell__r&   r&   rR   r'   r      s    r   c                   @   r    )r   zProxy connection error.

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

    Raised in :py:class:`aiohttp.connector.UnixConnector`
    if connection to unix socket can not be established.
    pathrJ   rK   r0   Nc                    s   || _ t || d S rL   )_pathrO   r:   )r9   rh   rJ   rK   rR   r&   r'   r:      s   z!UnixClientConnectorError.__init__c                 C   rT   rL   )ri   r<   r&   r&   r'   rh      rU   zUnixClientConnectorError.pathc                 C   r]   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]r^   r_   r<   r&   r&   r'   r=      r`   z UnixClientConnectorError.__str__)r"   r#   r$   r%   rF   r   ra   r:   rG   rh   r=   rf   r&   r&   rR   r'   rg      s    rg   c                   @   r    )r   zServer connection errors.Nr!   r&   r&   r&   r'   r      r(   r   c                   @   s.   e Zd ZdZddeeedf ddfddZdS )r   zServer disconnected.Nr,   r0   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r8   r,   )r9   r,   r&   r&   r'   r:      s   
z ServerDisconnectedError.__init__rL   )r"   r#   r$   r%   r   r   rF   r:   r&   r&   r&   r'   r      s    "r   c                   @   r    )r   zServer timeout error.Nr!   r&   r&   r&   r'   r      r(   r   c                
   @   s<   e Zd ZdZdededededdf
dd	Zdefd
dZdS )r   z4SSL certificate does not match expected fingerprint.expectedgotrX   r[   r0   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rL   )rj   rk   rX   r[   r8   )r9   rj   rk   rX   r[   r&   r&   r'   r:      s
   z"ServerFingerprintMismatch.__init__c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)r;   rS   r"   rj   rk   rX   r[   r<   r&   r&   r'   rA      s   z"ServerFingerprintMismatch.__repr__)	r"   r#   r$   r%   bytesrF   rE   r:   rA   r&   r&   r&   r'   r      s    r   c                   @   r    )r   zResponse payload error.Nr!   r&   r&   r&   r'   r     r(   r   c                       sJ   e Zd ZdZdeddf fddZedefddZdefd	d
Z	  Z
S )r   zbInvalid URL.

    URL used for fetching is malformed, e.g. it doesn't contains host
    part.
    urlr0   Nc                    s   t  | d S rL   )rO   r:   )r9   rm   rR   r&   r'   r:     s   zInvalidURL.__init__c                 C   s
   | j d S )Nr   )r8   r<   r&   r&   r'   rm     s   
zInvalidURL.urlc                 C   s   d| j j d| j dS )N< >)rS   r"   rm   r<   r&   r&   r'   rA     s   zInvalidURL.__repr__)r"   r#   r$   r%   r   r:   rG   rm   rF   rA   rf   r&   r&   rR   r'   r     s    r   c                   @   r    )r   zBase error for ssl.*Errors.Nr!   r&   r&   r&   r'   r     r(   r   c                   @   r    )r   zResponse ssl error.Nr!   r&   r&   r&   r'   r   3  r(   r   c                   @   s   e Zd ZdZdededdfddZedefdd	Zede	fd
dZ
edee fddZedefddZde	fddZdS )r   zResponse certificate error.rJ   certificate_errorr0   Nc                 C   s   || _ || _||f| _d S rL   )rM   _certificate_errorr8   )r9   rJ   rq   r&   r&   r'   r:   :  s   z(ClientConnectorCertificateError.__init__c                 C   rT   rL   )rr   r<   r&   r&   r'   rq   A  rU   z1ClientConnectorCertificateError.certificate_errorc                 C   rV   rL   rW   r<   r&   r&   r'   rX   E  rY   z$ClientConnectorCertificateError.hostc                 C   rV   rL   rZ   r<   r&   r&   r'   r[   I  rY   z$ClientConnectorCertificateError.portc                 C   rV   rL   )rM   Zis_sslr<   r&   r&   r'   r\   M  rY   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}])r;   r<   r&   r&   r'   r=   Q  s   z'ClientConnectorCertificateError.__str__)r"   r#   r$   r%   r   	Exceptionr:   rG   rq   rF   rX   r   rE   r[   rc   r\   r=   r&   r&   r&   r'   r   7  s$    
r   )5r%   asyncior5   typingr   r   r   r   r   Zhttp_parserr   Ztypedefsr	   r\   rb   ImportErrorZclient_reqrepr
   r   r   r   __all__rs   r   r   r   r   r   rI   r   ra   r   r   r   rg   r   r   TimeoutErrorr   r   r   r4   r   r   CertificateErrorZcert_errorsZcert_errors_basesSSLErrorZ
ssl_errorsZssl_error_basestupler   r   r&   r&   r&   r'   <module>   sb    
K	&