o
    4˜ŽjY-  ã                   @   s  d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 er(ddl
Z
e
jZnz	ddl
Z
e
jZW n ey>   d Z
ZY nw erTd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-ƒZ.G d4d5„ d5e.ƒZ/G d6d7„ d7eƒZ0G d8d9„ d9eƒZ1G d:d;„ d;e/e0ƒZ2G d<d=„ d=e1e0ƒZ3G d>d?„ d?e!ƒZ4e
du�rUe
j5fZ6e4e
j5fZ7e
j8fZ9e4e
j8fZ:ne;ƒ Z6e4e-fZ7e;ƒ Z9e4fZ:G d@dA„ dAge:¢R Ž Z<G dBdC„ dCge7¢R Ž Z=G dDdE„ dEe>ƒZ?dS )FzHTTP related errors.é    N)ÚTYPE_CHECKINGÚ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__© r.   r.   úV/var/www/kodo/Anonymous/send/lib/python3.10/site-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dB d	edB d
ede	e dB 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.r2   r3   r4   r5   Ú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   )
r6   Ú
ValueErrorÚwarningsÚwarnÚDeprecationWarningr3   r4   r5   r7   Úargs)Úselfr6   r7   r2   r3   r4   r5   r.   r.   r/   Ú__init__K   s(   
ÿýzClientResponseError.__init__c                 C   s    | j › d| j›dt| jjƒ›�S )Nú
, message=z, url=)r3   r4   Ústrr6   Úreal_url©rA   r.   r.   r/   Ú__str__l   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=r1   rC   z
, headers=ú(ú))r6   r7   r3   r4   r5   Útyper*   )rA   r@   r.   r.   r/   Ú__repr__o   s   


zClientResponseError.__repr__c                 C   s   t jdtdd� | jS ©Nz/code property is deprecated, use status insteadr9   r:   ©r=   r>   r?   r3   rF   r.   r.   r/   r2   y   s   ýzClientResponseError.codeÚvaluec                 C   s   t jdtdd� || _d S rL   rM   )rA   rN   r.   r.   r/   r2   ‚   s   ý
)r*   r+   r,   r-   r
   Útupler   ÚintrD   r   rB   rG   rK   Úpropertyr2   Úsetterr.   r.   r.   r/   r   A   s6    øþ
ýûúù
ø	
÷!
r   c                   @   r(   )r   zContentType found is not valid.Nr)   r.   r.   r.   r/   r   Œ   r0   r   c                   @   r(   )r   z!websocket server handshake error.Nr)   r.   r.   r.   r/   r   �   r0   r   c                   @   r(   )r   z¡HTTP 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   ”   r0   r   c                   @   r(   )ÚTooManyRedirectsz%Client was redirected too many times.Nr)   r.   r.   r.   r/   rS   �   r0   rS   c                   @   r(   )r   z$Base class for client socket errors.Nr)   r.   r.   r.   r/   r   ¡   r0   r   c                   @   r(   )r   ÚConnectionResetErrorNr)   r.   r.   r.   r/   r   ¥   r0   r   c                   @   r(   )r   zOSError error.Nr)   r.   r.   r.   r/   r   ©   r0   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dB 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   zƒClient connector error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        a connection can not be established.
    Úconnection_keyÚos_errorr8   Nc                    s,   || _ || _tƒ  |j|j¡ ||f| _d S ©N)Ú	_conn_keyÚ	_os_errorÚsuperrB   ÚerrnoÚstrerrorr@   )rA   rU   rV   ©Ú	__class__r.   r/   rB   ´   s   zClientConnectorError.__init__c                 C   ó   | j S rW   )rY   rF   r.   r.   r/   rV   º   ó   zClientConnectorError.os_errorc                 C   ó   | j jS rW   ©rX   ÚhostrF   r.   r.   r/   rc   ¾   ó   zClientConnectorError.hostc                 C   ra   rW   ©rX   ÚportrF   r.   r.   r/   rf   Â   rd   zClientConnectorError.portr	   c                 C   ra   rW   )rX   ÚsslrF   r.   r.   r/   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©Úformatrg   r\   rF   r.   r.   r/   rG   Ê   ó
   ÿÿzClientConnectorError.__str__)r*   r+   r,   r-   r   ÚOSErrorrB   rQ   rV   rD   rc   rP   rf   r   Ú
SSLContextÚboolrg   rG   ÚBaseExceptionÚ
__reduce__Ú__classcell__r.   r.   r]   r/   r   ­   s    r   c                   @   r(   )r   zŒDNS resolution failed during client connection.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        DNS resolution fails.
    Nr)   r.   r.   r.   r/   r   Ó   r0   r   c                   @   r(   )r   zŠProxy connection error.

    Raised in :class:`aiohttp.connector.TCPConnector` if
        connection to proxy can not be established.
    Nr)   r.   r.   r.   r/   r   Û   r0   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 )ÚUnixClientConnectorErrorzŽUnix connector error.

    Raised in :py:class:`aiohttp.connector.UnixConnector`
    if connection to unix socket can not be established.
    ÚpathrU   rV   r8   Nc                    s   || _ tƒ  ||¡ d S rW   )Ú_pathrZ   rB   )rA   rt   rU   rV   r]   r.   r/   rB   ê   s   z!UnixClientConnectorError.__init__c                 C   r_   rW   )ru   rF   r.   r.   r/   rt   ð   r`   zUnixClientConnectorError.pathc                 C   rh   )Nz4Cannot connect to unix socket {0.path} ssl:{1} [{2}]Tri   rj   rF   r.   r.   r/   rG   ô   rl   z UnixClientConnectorError.__str__)r*   r+   r,   r-   rD   r   rm   rB   rQ   rt   rG   rr   r.   r.   r]   r/   rs   ã   s    ÿÿÿþrs   c                   @   r(   )r   zServer connection errors.Nr)   r.   r.   r.   r/   r   ú   r0   r   c                   @   s,   e Zd ZdZddeeB dB ddfdd„ZdS )r   zServer disconnected.Nr4   r8   c                 C   s   |d u rd}|f| _ || _d S )NzServer disconnected)r@   r4   )rA   r4   r.   r.   r/   rB     s   
z ServerDisconnectedError.__init__rW   )r*   r+   r,   r-   r   rD   rB   r.   r.   r.   r/   r   þ   s     r   c                   @   r(   )r   zServer timeout error.Nr)   r.   r.   r.   r/   r   	  r0   r   c                   @   r(   )r   zConnection timeout error.Nr)   r.   r.   r.   r/   r     r0   r   c                   @   r(   )r   zSocket timeout error.Nr)   r.   r.   r.   r/   r     r0   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   r8   Nc                 C   s*   || _ || _|| _|| _||||f| _d S rW   )rv   rw   rc   rf   r@   )rA   rv   rw   rc   rf   r.   r.   r/   rB     s
   z"ServerFingerprintMismatch.__init__c                 C   s0   d| j j› d| j›d| j›d| j›d| j›d�S )Nú<z
 expected=z got=z host=z port=ú>)r^   r*   rv   rw   rc   rf   rF   r.   r.   r/   rK     s   0z"ServerFingerprintMismatch.__repr__)	r*   r+   r,   r-   ÚbytesrD   rP   rB   rK   r.   r.   r.   r/   r     s    r   c                   @   r(   )r    zResponse payload error.Nr)   r.   r.   r.   r/   r    #  r0   r    c                       sp   e Zd ZdZddededB 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Údescriptionr8   c                    s2   || _ || _|rtƒ  ||¡ d S tƒ  |¡ d S rW   )Ú_urlÚ_descriptionrZ   rB   )rA   r{   r|   r]   r.   r/   rB   0  s
   zInvalidURL.__init__c                 C   r_   rW   )r}   rF   r.   r.   r/   r{   ;  r`   zInvalidURL.urlú
str | Nonec                 C   r_   rW   )r~   rF   r.   r.   r/   r|   ?  r`   zInvalidURL.descriptionc                 C   s   d| j j› d| › d�S )Nrx   ú ry   )r^   r*   rF   r.   r.   r/   rK   C  s   zInvalidURL.__repr__c                 C   s"   | j r| j› d| j › �S t| jƒS )Nz - )r~   r}   rD   rF   r.   r.   r/   rG   F  s   
zInvalidURL.__str__rW   )r8   r   )r*   r+   r,   r-   r   rD   rB   rQ   r{   r|   rK   rG   rr   r.   r.   r]   r/   r!   '  s     r!   c                   @   r(   )r"   zInvalid URL client error.Nr)   r.   r.   r.   r/   r"   L  r0   r"   c                   @   r(   )r#   zClient redirect error.Nr)   r.   r.   r.   r/   r#   P  r0   r#   c                   @   r(   )r$   zNon http URL client error.Nr)   r.   r.   r.   r/   r$   T  r0   r$   c                   @   r(   )r%   z"Invalid URL redirect client error.Nr)   r.   r.   r.   r/   r%   X  r0   r%   c                   @   r(   )r&   z#Non http URL redirect client error.Nr)   r.   r.   r.   r/   r&   \  r0   r&   c                   @   r(   )r   zBase error for ssl.*Errors.Nr)   r.   r.   r.   r/   r   `  r0   r   c                   @   r(   )r   zResponse ssl error.Nr)   r.   r.   r.   r/   r   x  r0   r   c                       s’   e Zd ZU dZeed< 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dB fdd„ƒZedefdd„ƒZde
fdd„Z‡  ZS )r   zResponse certificate error.rX   rU   Úcertificate_errorr8   Nc                    s>   t |ttf ƒr|}ntƒ }tƒ  ||¡ || _||f| _d S rW   )Ú
isinstanceÚcert_errorsrm   rZ   rB   Ú_certificate_errorr@   )rA   rU   r�   rV   r]   r.   r/   rB   �  s   z(ClientConnectorCertificateError.__init__c                 C   r_   rW   )r„   rF   r.   r.   r/   r�   ‘  r`   z1ClientConnectorCertificateError.certificate_errorc                 C   ra   rW   rb   rF   r.   r.   r/   rc   •  rd   z$ClientConnectorCertificateError.hostc                 C   ra   rW   re   rF   r.   r.   r/   rf   ™  rd   z$ClientConnectorCertificateError.portc                 C   ra   rW   )rX   Úis_sslrF   r.   r.   r/   rg   �  rd   z#ClientConnectorCertificateError.sslc                 C   s4   d| j › d| j› d| j› d| jjj› d| jj› d�S )NzCannot connect to host ú:z ssl:z [z: ú])rc   rf   rg   r�   r^   r*   r@   rF   r.   r.   r/   rG   ¡  s   ÿþÿz'ClientConnectorCertificateError.__str__)r*   r+   r,   r-   r   Ú__annotations__Ú	ExceptionrB   rQ   r�   rD   rc   rP   rf   ro   rg   rG   rr   r.   r.   r]   r/   r   |  s&   
 ýüûr   c                   @   r(   )r'   z$WebSocket message type is not valid.Nr)   r.   r.   r.   r/   r'   ©  r0   r'   )@r-   Úasyncior=   Útypingr   r   Ú	multidictr   Útypedefsr   rg   rn   ÚImportErrorÚclient_reqrepr   r   r	   r
   Úhttp_parserr   Ú__all__r‰   r   r   r   r   r   rS   r   rT   r   rm   r   r   r   r   rs   r   r   ÚTimeoutErrorr   r   r   r   r    r<   r!   r"   r#   r$   r%   r&   r   ÚCertificateErrorrƒ   Úcert_errors_basesÚSSLErrorÚ
ssl_errorsÚssl_error_basesrO   r   r   Ú	TypeErrorr'   r.   r.   r.   r/   Ú<module>   s~    
ÿ K	&%
þþ-