o
    `g,                     @   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?G dDdE dEe@ZAdS )Fz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NonHttpUrlRedirectClientErrorWSMessageTypeErrorc                   @      e Zd ZdZdS )r   z(Base class for client connection errors.N__name__
__module____qualname____doc__ r0   r0   T/var/www/html/propose/venv/lib/python3.10/site-packages/aiohttp/client_exceptions.pyr   9       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.r4   r5   r6   r7   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   )
r8   
ValueErrorwarningswarnDeprecationWarningr5   r6   r7   r9   args)selfr8   r9   r4   r5   r6   r7   r0   r0   r1   __init__G   s(   
zClientResponseError.__init__c                 C   s   d | j| jt| jjS )Nz{}, message={!r}, url={!r})formatr5   r6   strr8   real_urlrC   r0   r0   r1   __str__h   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=r3   z
, message=z
, headers=())r8   r9   r5   r6   r7   typer,   )rC   rB   r0   r0   r1   __repr__o   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@   rA   r5   rH   r0   r0   r1   r4   y   s   zClientResponseError.codevaluec                 C   s   t jdtdd || _d S rN   rO   )rC   rP   r0   r0   r1   r4      s   
)r,   r-   r.   r/   r   r   r	   r   intrF   r   rD   rI   rM   propertyr4   setterr0   r0   r0   r1   r   =   s6    

	
!
r   c                   @   r*   )r!   zContentType found is not valid.Nr+   r0   r0   r0   r1   r!      r2   r!   c                   @   r*   )r    z!websocket server handshake error.Nr+   r0   r0   r0   r1   r       r2   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+   r0   r0   r0   r1   r      r2   r   c                   @   r*   )TooManyRedirectsz%Client was redirected too many times.Nr+   r0   r0   r0   r1   rT      r2   rT   c                   @   r*   )r   z$Base class for client socket errors.Nr+   r0   r0   r0   r1   r      r2   r   c                   @   r*   )r   ConnectionResetErrorNr+   r0   r0   r0   r1   r      r2   r   c                   @   r*   )r   zOSError error.Nr+   r0   r0   r0   r1   r      r2   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_errorr:   Nc                    s,   || _ || _t |j|j ||f| _d S N)	_conn_key	_os_errorsuperrD   errnostrerrorrB   )rC   rV   rW   	__class__r0   r1   rD      s   zClientConnectorError.__init__c                 C      | j S rX   )rZ   rH   r0   r0   r1   rW         zClientConnectorError.os_errorc                 C      | j jS rX   rY   hostrH   r0   r0   r1   rd         zClientConnectorError.hostc                 C   rb   rX   rY   portrH   r0   r0   r1   rg      re   zClientConnectorError.portr   c                 C   rb   rX   )rY   sslrH   r0   r0   r1   rh      re   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rE   rh   r]   rH   r0   r0   r1   rI      
   zClientConnectorError.__str__)r,   r-   r.   r/   r
   OSErrorrD   rR   rW   rF   rd   r   rQ   rg   r   
SSLContextboolrh   rI   BaseException
__reduce____classcell__r0   r0   r^   r1   r      s    r   c                   @   r*   )r   zDNS resolution failed during client connection.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        DNS resolution fails.
    Nr+   r0   r0   r0   r1   r      r2   r   c                   @   r*   )r   zProxy connection error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        connection to proxy can not be established.
    Nr+   r0   r0   r0   r1   r      r2   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.
    pathrV   rW   r:   Nc                    s   || _ t || d S rX   )_pathr[   rD   )rC   rt   rV   rW   r^   r0   r1   rD      s   z!UnixClientConnectorError.__init__c                 C   r`   rX   )ru   rH   r0   r0   r1   rt      ra   zUnixClientConnectorError.pathc                 C   ri   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Trj   rk   rH   r0   r0   r1   rI      rl   z UnixClientConnectorError.__str__)r,   r-   r.   r/   rF   r
   rm   rD   rR   rt   rI   rr   r0   r0   r^   r1   rs      s    rs   c                   @   r*   )r   zServer connection errors.Nr+   r0   r0   r0   r1   r      r2   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.Nr6   r:   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)rB   r6   )rC   r6   r0   r0   r1   rD     s   
z ServerDisconnectedError.__init__rX   )r,   r-   r.   r/   r   r   rF   rD   r0   r0   r0   r1   r      s    "r   c                   @   r*   )r   zServer timeout error.Nr+   r0   r0   r0   r1   r   	  r2   r   c                   @   r*   )r   zConnection timeout error.Nr+   r0   r0   r0   r1   r     r2   r   c                   @   r*   )r   zSocket timeout error.Nr+   r0   r0   r0   r1   r     r2   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gotrd   rg   r:   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rX   )rv   rw   rd   rg   rB   )rC   rv   rw   rd   rg   r0   r0   r1   rD     s
   z"ServerFingerprintMismatch.__init__c                 C   s   d | jj| j| j| j| jS )Nz/<{} expected={!r} got={!r} host={!r} port={!r}>)rE   r_   r,   rv   rw   rd   rg   rH   r0   r0   r1   rM     s   z"ServerFingerprintMismatch.__repr__)	r,   r-   r.   r/   bytesrF   rQ   rD   rM   r0   r0   r0   r1   r     s    r   c                   @   r*   )r"   zResponse payload error.Nr+   r0   r0   r0   r1   r"   %  r2   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descriptionr:   c                    s2   || _ || _|rt || d S t | d S rX   )_url_descriptionr[   rD   )rC   ry   rz   r^   r0   r1   rD   2  s
   zInvalidURL.__init__c                 C   r`   rX   )r{   rH   r0   r0   r1   ry   =  ra   zInvalidURL.url
str | Nonec                 C   r`   rX   )r|   rH   r0   r0   r1   rz   A  ra   zInvalidURL.descriptionc                 C   s   d| j j d|  dS )N< >)r_   r,   rH   r0   r0   r1   rM   E  s   zInvalidURL.__repr__c                 C   s"   | j r| j d| j  S t| jS )Nz - )r|   r{   rF   rH   r0   r0   r1   rI   H  s   
zInvalidURL.__str__rX   )r:   r}   )r,   r-   r.   r/   r   r   rF   rD   rR   ry   rz   rM   rI   rr   r0   r0   r^   r1   r#   )  s    $r#   c                   @   r*   )r$   zInvalid URL client error.Nr+   r0   r0   r0   r1   r$   N  r2   r$   c                   @   r*   )r%   zClient redirect error.Nr+   r0   r0   r0   r1   r%   R  r2   r%   c                   @   r*   )r&   zNon http URL client error.Nr+   r0   r0   r0   r1   r&   V  r2   r&   c                   @   r*   )r'   z"Invalid URL redirect client error.Nr+   r0   r0   r0   r1   r'   Z  r2   r'   c                   @   r*   )r(   z#Non http URL redirect client error.Nr+   r0   r0   r0   r1   r(   ^  r2   r(   c                   @   r*   )r   zBase error for ssl.*Errors.Nr+   r0   r0   r0   r1   r   b  r2   r   c                   @   r*   )r   zResponse ssl error.Nr+   r0   r0   r0   r1   r   z  r2   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.rV   certificate_errorr:   Nc                 C   s   || _ || _||f| _d S rX   )rY   _certificate_errorrB   )rC   rV   r   r0   r0   r1   rD     s   z(ClientConnectorCertificateError.__init__c                 C   r`   rX   )r   rH   r0   r0   r1   r     ra   z1ClientConnectorCertificateError.certificate_errorc                 C   rb   rX   rc   rH   r0   r0   r1   rd     re   z$ClientConnectorCertificateError.hostc                 C   rb   rX   rf   rH   r0   r0   r1   rg     re   z$ClientConnectorCertificateError.portc                 C   rb   rX   )rY   is_sslrH   r0   r0   r1   rh     re   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}])rE   rH   r0   r0   r1   rI     s   z'ClientConnectorCertificateError.__str__)r,   r-   r.   r/   r
   	ExceptionrD   rR   r   rF   rd   r   rQ   rg   ro   rh   rI   r0   r0   r0   r1   r   ~  s$    
r   c                   @   r*   )r)   z$WebSocket message type is not valid.Nr+   r0   r0   r0   r1   r)     r2   r)   )Br/   asyncior?   typingr   r   r   r   	multidictr   typedefsr   rh   rn   ImportErrorclient_reqrepr	   r
   r   r   http_parserr   __all__r   r   r   r!   r    r   rT   r   rU   r   rm   r   r   r   r   rs   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   	TypeErrorr)   r0   r0   r0   r1   <module>   sx    
 O	&%
"