o
    #`^h)                     @   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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#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r8e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                   @      e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r-   r-   W/home/air/shanriGPT/back/venv/lib/python3.10/site-packages/aiohttp/client_exceptions.pyr   4       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   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history.r1   r2   r3   r4   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   )
r5   
ValueErrorwarningswarnDeprecationWarningr2   r3   r4   r6   args)selfr5   r6   r1   r2   r3   r4   r-   r-   r.   __init__B   s(   
zClientResponseError.__init__c                 C   s   d | j| jt| jjS )Nz{}, message={!r}, url={!r})formatr2   r3   strr5   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r#|d| j7 }| jd ur0|d| j7 }t| j d| dS )	Nz, r   z	, status=r0   z
, message=z
, headers=())r5   r6   r2   r3   r4   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 insteadr8   r9   r<   r=   r>   r2   rE   r-   r-   r.   r1   t   s   zClientResponseError.codevaluec                 C   s   t jdtdd || _d S rK   rL   )r@   rM   r-   r-   r.   r1   }   s   
)r)   r*   r+   r,   r   r   r
   r   intrC   r   rA   rF   rJ   propertyr1   setterr-   r-   r-   r.   r   8   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.   rQ      r/   rQ   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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
        a connection can not be established.
    connection_keyos_errorr7   Nc                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperrA   errnostrerrorr?   )r@   rR   rS   	__class__r-   r.   rA      s   zClientConnectorError.__init__c                 C      | j S rT   )rV   rE   r-   r-   r.   rS         zClientConnectorError.os_errorc                 C      | j jS rT   rU   hostrE   r-   r-   r.   r`         zClientConnectorError.hostc                 C   r^   rT   rU   portrE   r-   r-   r.   rc      ra   zClientConnectorError.portr   c                 C   r^   rT   )rU   sslrE   r-   r-   r.   rd      ra   zClientConnectorError.sslc                 C   &   d | | jdu rd| jS | j| jS )Nz6Cannot connect to host {0.host}:{0.port} ssl:{1} [{2}]TdefaultrB   rd   rY   rE   r-   r-   r.   rF      
   zClientConnectorError.__str__)r)   r*   r+   r,   r   OSErrorrA   rO   rS   rC   r`   r   rN   rc   r   
SSLContextboolrd   rF   BaseException
__reduce____classcell__r-   r-   rZ   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.
    pathrR   rS   r7   Nc                    s   || _ t || d S rT   )_pathrW   rA   )r@   rp   rR   rS   rZ   r-   r.   rA      s   z!UnixClientConnectorError.__init__c                 C   r\   rT   )rq   rE   r-   r-   r.   rp      r]   zUnixClientConnectorError.pathc                 C   re   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Trf   rg   rE   r-   r-   r.   rF      rh   z UnixClientConnectorError.__str__)r)   r*   r+   r,   rC   r   ri   rA   rO   rp   rF   rn   r-   r-   rZ   r.   ro      s    ro   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.Nr3   r7   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r?   r3   )r@   r3   r-   r-   r.   rA      s   
z ServerDisconnectedError.__init__rT   )r)   r*   r+   r,   r   r   rC   rA   r-   r-   r-   r.   r      s    "r   c                   @   r'   )r   zServer timeout error.Nr(   r-   r-   r-   r.   r      r/   r   c                   @   r'   )r   zConnection timeout error.Nr(   r-   r-   r-   r.   r      r/   r   c                   @   r'   )r   zSocket 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gotr`   rc   r7   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rT   )rr   rs   r`   rc   r?   )r@   rr   rs   r`   rc   r-   r-   r.   rA     s
   z"ServerFingerprintMismatch.__init__c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)rB   r[   r)   rr   rs   r`   rc   rE   r-   r-   r.   rJ     s   z"ServerFingerprintMismatch.__repr__)	r)   r*   r+   r,   bytesrC   rN   rA   rJ   r-   r-   r-   r.   r     s    r   c                   @   r'   )r    zResponse payload error.Nr(   r-   r-   r-   r.   r      r/   r    c                       st   e Zd ZdZddedeedf ddf fddZedefdd	Z	edddZ
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.
    Nurldescriptionr7   c                    s2   || _ || _|rt || d S t | d S rT   )_url_descriptionrW   rA   )r@   ru   rv   rZ   r-   r.   rA   !  s
   zInvalidURL.__init__c                 C   r\   rT   )rw   rE   r-   r-   r.   ru   ,  r]   zInvalidURL.url
str | Nonec                 C   r\   rT   )rx   rE   r-   r-   r.   rv   0  r]   zInvalidURL.descriptionc                 C   s   d| j j d|  dS )N< >)r[   r)   rE   r-   r-   r.   rJ   4  s   zInvalidURL.__repr__c                 C   s"   | j r| j d| j  S t| jS )Nz - )rx   rw   rC   rE   r-   r-   r.   rF   7  s   
zInvalidURL.__str__rT   )r7   ry   )r)   r*   r+   r,   r	   r   rC   rA   rO   ru   rv   rJ   rF   rn   r-   r-   rZ   r.   r!     s    $r!   c                   @   r'   )r"   zInvalid URL client error.Nr(   r-   r-   r-   r.   r"   =  r/   r"   c                   @   r'   )r#   zClient redirect error.Nr(   r-   r-   r-   r.   r#   A  r/   r#   c                   @   r'   )r$   zNon http URL client error.Nr(   r-   r-   r-   r.   r$   E  r/   r$   c                   @   r'   )r%   z"Invalid URL redirect client error.Nr(   r-   r-   r-   r.   r%   I  r/   r%   c                   @   r'   )r&   z#Non http URL redirect client error.Nr(   r-   r-   r-   r.   r&   M  r/   r&   c                   @   r'   )r   zBase error for ssl.*Errors.Nr(   r-   r-   r-   r.   r   Q  r/   r   c                   @   r'   )r   zResponse ssl error.Nr(   r-   r-   r-   r.   r   i  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.rR   certificate_errorr7   Nc                 C   s   || _ || _||f| _d S rT   )rU   _certificate_errorr?   )r@   rR   r}   r-   r-   r.   rA   p  s   z(ClientConnectorCertificateError.__init__c                 C   r\   rT   )r~   rE   r-   r-   r.   r}   w  r]   z1ClientConnectorCertificateError.certificate_errorc                 C   r^   rT   r_   rE   r-   r-   r.   r`   {  ra   z$ClientConnectorCertificateError.hostc                 C   r^   rT   rb   rE   r-   r-   r.   rc     ra   z$ClientConnectorCertificateError.portc                 C   r^   rT   )rU   is_sslrE   r-   r-   r.   rd     ra   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}])rB   rE   r-   r-   r.   rF     s   z'ClientConnectorCertificateError.__str__)r)   r*   r+   r,   r   	ExceptionrA   rO   r}   rC   r`   r   rN   rc   rk   rd   rF   r-   r-   r-   r.   r   m  s$    
r   )<r,   asyncior<   typingr   r   r   r   http_parserr   typedefsr   r	   rd   rj   ImportErrorclient_reqrepr
   r   r   r   __all__r   r   r   r   r   r   rQ   r   ri   r   r   r   ro   r   r   TimeoutErrorr   r   r   r   r    r;   r!   r"   r#   r$   r%   r&   r   CertificateErrorcert_errorscert_errors_basesSSLError
ssl_errorsssl_error_basestupler   r   r-   r-   r-   r.   <module>   sp    
O	&%
