o
    ~#i+                     @   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 z	ddlZejZW n ey8   d ZZY nw erNddlmZmZmZmZ ddlmZ nd Z 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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j)Z*G d*d+ d+e*Z+G d,d- d-e*Z,G d.d/ d/e'Z-G d0d1 d1eZ.G d2d3 d3ee/Z0G d4d5 d5e0Z1G d6d7 d7eZ2G d8d9 d9eZ3G d:d; d;e1e2Z4G d<d= d=e3e2Z5G d>d? d?e#Z6edurOej7fZ8e6ej7fZ9ej:fZ;e6ej:fZ<ne= Z8e6e/fZ9e= Z;e6fZ<G d@dA dAge<R  Z>G dBdC dCge9R  Z?dS )DzHTTP related errors.    N)TYPE_CHECKINGOptionalTupleUnion)MultiMapping   )StrOrURL)ClientResponseConnectionKeyFingerprintRequestInfo)RawResponseMessage)ClientErrorClientConnectionErrorClientConnectionResetErrorClientOSErrorClientConnectorErrorClientProxyConnectionErrorClientSSLErrorClientConnectorDNSError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/   `/var/www/GraceOrthoHospital/venv_grace/lib/python3.10/site-packages/aiohttp/client_exceptions.pyr   8       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
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.r3   r4   r5   r6   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   )
r7   
ValueErrorwarningswarnDeprecationWarningr4   r5   r6   r8   args)selfr7   r8   r3   r4   r5   r6   r/   r/   r0   __init__F   s(   
zClientResponseError.__init__c                 C   s   d | j| jt| jjS )Nz{}, message={!r}, url={!r})formatr4   r5   strr7   real_urlrB   r/   r/   r0   __str__g   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=r2   z
, message=z
, headers=())r7   r8   r4   r5   r6   typer+   )rB   rA   r/   r/   r0   __repr__n   s   


zClientResponseError.__repr__c                 C   s   t jdtdd | jS Nz/code property is deprecated, use status insteadr:   r;   r>   r?   r@   r4   rG   r/   r/   r0   r3   x   s   zClientResponseError.codevaluec                 C   s   t jdtdd || _d S rM   rN   )rB   rO   r/   r/   r0   r3      s   
)r+   r,   r-   r.   r   r   r	   r   intrE   r   rC   rH   rL   propertyr3   setterr/   r/   r/   r0   r   <   s6    

	
!
r   c                   @   r)   )r!   zContentType found is not valid.Nr*   r/   r/   r/   r0   r!      r1   r!   c                   @   r)   )r    z!websocket server handshake error.Nr*   r/   r/   r/   r0   r       r1   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/   r0   r      r1   r   c                   @   r)   )TooManyRedirectsz%Client was redirected too many times.Nr*   r/   r/   r/   r0   rS      r1   rS   c                   @   r)   )r   z$Base class for client socket errors.Nr*   r/   r/   r/   r0   r      r1   r   c                   @   r)   )r   ConnectionResetErrorNr*   r/   r/   r/   r0   r      r1   r   c                   @   r)   )r   zOSError error.Nr*   r/   r/   r/   r0   r      r1   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_errorr9   Nc                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperrC   errnostrerrorrA   )rB   rU   rV   	__class__r/   r0   rC      s   zClientConnectorError.__init__c                 C      | j S rW   )rY   rG   r/   r/   r0   rV         zClientConnectorError.os_errorc                 C      | j jS rW   rX   hostrG   r/   r/   r0   rc         zClientConnectorError.hostc                 C   ra   rW   rX   portrG   r/   r/   r0   rf      rd   zClientConnectorError.portr   c                 C   ra   rW   )rX   sslrG   r/   r/   r0   rg      rd   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rD   rg   r\   rG   r/   r/   r0   rH      
   zClientConnectorError.__str__)r+   r,   r-   r.   r
   OSErrorrC   rQ   rV   rE   rc   r   rP   rf   r   
SSLContextboolrg   rH   BaseException
__reduce____classcell__r/   r/   r]   r0   r      s    r   c                   @   r)   )r   zDNS resolution failed during client connection.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        DNS resolution fails.
    Nr*   r/   r/   r/   r0   r      r1   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/   r0   r      r1   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.
    pathrU   rV   r9   Nc                    s   || _ t || d S rW   )_pathrZ   rC   )rB   rs   rU   rV   r]   r/   r0   rC      s   z!UnixClientConnectorError.__init__c                 C   r_   rW   )rt   rG   r/   r/   r0   rs      r`   zUnixClientConnectorError.pathc                 C   rh   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Tri   rj   rG   r/   r/   r0   rH      rk   z UnixClientConnectorError.__str__)r+   r,   r-   r.   rE   r
   rl   rC   rQ   rs   rH   rq   r/   r/   r]   r0   rr      s    rr   c                   @   r)   )r   zServer connection errors.Nr*   r/   r/   r/   r0   r      r1   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.Nr5   r9   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)rA   r5   )rB   r5   r/   r/   r0   rC      s   
z ServerDisconnectedError.__init__rW   )r+   r,   r-   r.   r   r   rE   rC   r/   r/   r/   r0   r      s    "r   c                   @   r)   )r   zServer timeout error.Nr*   r/   r/   r/   r0   r     r1   r   c                   @   r)   )r   zConnection timeout error.Nr*   r/   r/   r/   r0   r     r1   r   c                   @   r)   )r   zSocket timeout error.Nr*   r/   r/   r/   r0   r     r1   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gotrc   rf   r9   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rW   )ru   rv   rc   rf   rA   )rB   ru   rv   rc   rf   r/   r/   r0   rC     s
   z"ServerFingerprintMismatch.__init__c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)rD   r^   r+   ru   rv   rc   rf   rG   r/   r/   r0   rL     s   z"ServerFingerprintMismatch.__repr__)	r+   r,   r-   r.   bytesrE   rP   rC   rL   r/   r/   r/   r0   r     s    r   c                   @   r)   )r"   zResponse payload error.Nr*   r/   r/   r/   r0   r"   $  r1   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descriptionr9   c                    s2   || _ || _|rt || d S t | d S rW   )_url_descriptionrZ   rC   )rB   rx   ry   r]   r/   r0   rC   1  s
   zInvalidURL.__init__c                 C   r_   rW   )rz   rG   r/   r/   r0   rx   <  r`   zInvalidURL.url
str | Nonec                 C   r_   rW   )r{   rG   r/   r/   r0   ry   @  r`   zInvalidURL.descriptionc                 C   s   d| j j d|  dS )N< >)r^   r+   rG   r/   r/   r0   rL   D  s   zInvalidURL.__repr__c                 C   s"   | j r| j d| j  S t| jS )Nz - )r{   rz   rE   rG   r/   r/   r0   rH   G  s   
zInvalidURL.__str__rW   )r9   r|   )r+   r,   r-   r.   r   r   rE   rC   rQ   rx   ry   rL   rH   rq   r/   r/   r]   r0   r#   (  s    $r#   c                   @   r)   )r$   zInvalid URL client error.Nr*   r/   r/   r/   r0   r$   M  r1   r$   c                   @   r)   )r%   zClient redirect error.Nr*   r/   r/   r/   r0   r%   Q  r1   r%   c                   @   r)   )r&   zNon http URL client error.Nr*   r/   r/   r/   r0   r&   U  r1   r&   c                   @   r)   )r'   z"Invalid URL redirect client error.Nr*   r/   r/   r/   r0   r'   Y  r1   r'   c                   @   r)   )r(   z#Non http URL redirect client error.Nr*   r/   r/   r/   r0   r(   ]  r1   r(   c                   @   r)   )r   zBase error for ssl.*Errors.Nr*   r/   r/   r/   r0   r   a  r1   r   c                   @   r)   )r   zResponse ssl error.Nr*   r/   r/   r/   r0   r   y  r1   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.rU   certificate_errorr9   Nc                 C   s   || _ || _||f| _d S rW   )rX   _certificate_errorrA   )rB   rU   r   r/   r/   r0   rC     s   z(ClientConnectorCertificateError.__init__c                 C   r_   rW   )r   rG   r/   r/   r0   r     r`   z1ClientConnectorCertificateError.certificate_errorc                 C   ra   rW   rb   rG   r/   r/   r0   rc     rd   z$ClientConnectorCertificateError.hostc                 C   ra   rW   re   rG   r/   r/   r0   rf     rd   z$ClientConnectorCertificateError.portc                 C   ra   rW   )rX   is_sslrG   r/   r/   r0   rg     rd   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}])rD   rG   r/   r/   r0   rH     s   z'ClientConnectorCertificateError.__str__)r+   r,   r-   r.   r
   	ExceptionrC   rQ   r   rE   rc   r   rP   rf   rn   rg   rH   r/   r/   r/   r0   r   }  s$    
r   )@r.   asyncior>   typingr   r   r   r   	multidictr   typedefsr   rg   rm   ImportErrorclient_reqrepr	   r
   r   r   http_parserr   __all__r   r   r   r!   r    r   rS   r   rT   r   rl   r   r   r   r   rr   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/   r0   <module>   sv    
O	&%
