o
    mh(                     @  s  d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	 g 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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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 d0d1 d1ee Z!G d2d3 d3eZ"G d4d5 d5eZ#G d6d7 d7eZ$e$Z%dS )8ay  
:mod:`websockets.exceptions` defines the following exception hierarchy:

* :exc:`WebSocketException`
    * :exc:`ConnectionClosed`
        * :exc:`ConnectionClosedError`
        * :exc:`ConnectionClosedOK`
    * :exc:`InvalidHandshake`
        * :exc:`SecurityError`
        * :exc:`InvalidMessage`
        * :exc:`InvalidHeader`
            * :exc:`InvalidHeaderFormat`
            * :exc:`InvalidHeaderValue`
            * :exc:`InvalidOrigin`
            * :exc:`InvalidUpgrade`
        * :exc:`InvalidStatus`
        * :exc:`InvalidStatusCode` (legacy)
        * :exc:`NegotiationError`
            * :exc:`DuplicateParameter`
            * :exc:`InvalidParameterName`
            * :exc:`InvalidParameterValue`
        * :exc:`AbortHandshake`
        * :exc:`RedirectHandshake`
    * :exc:`InvalidState`
    * :exc:`InvalidURI`
    * :exc:`PayloadTooBig`
    * :exc:`ProtocolError`

    )annotationsN   )datastructuresframeshttp11)
StatusLike)WebSocketExceptionConnectionClosedConnectionClosedErrorConnectionClosedOKInvalidHandshakeSecurityErrorInvalidMessageInvalidHeaderInvalidHeaderFormatInvalidHeaderValueInvalidOriginInvalidUpgradeInvalidStatusInvalidStatusCodeNegotiationErrorDuplicateParameterInvalidParameterNameInvalidParameterValueAbortHandshakeRedirectHandshakeInvalidState
InvalidURIPayloadTooBigProtocolErrorWebSocketProtocolErrorc                   @     e Zd ZdZdS )r   z?
    Base class for all exceptions defined by websockets.

    N__name__
__module____qualname____doc__ r'   r'   M/var/www/html/zoom/venv/lib/python3.10/site-packages/websockets/exceptions.pyr   D       r   c                   @  sD   e Zd ZdZ	ddd
dZdddZedddZedddZdS )r	   a>  
    Raised when trying to interact with a closed connection.

    Attributes:
        rcvd (Close | None): if a close frame was received, its code and
            reason are available in ``rcvd.code`` and ``rcvd.reason``.
        sent (Close | None): if a close frame was sent, its code and reason
            are available in ``sent.code`` and ``sent.reason``.
        rcvd_then_sent (bool | None): if close frames were received and
            sent, this attribute tells in which order this happened, from the
            perspective of this side of the connection.

    Nrcvdframes.Close | Nonesentrcvd_then_sentbool | NonereturnNonec                 C  s   || _ || _|| _d S Nr*   r,   r-   )selfr*   r,   r-   r'   r'   r(   __init__Z   s   
zConnectionClosed.__init__strc                 C  s   | j d u r!| jd u r| jd u sJ dS | jd u sJ d| j dS | jd u r4| jd u s-J d| j  dS | jd us;J | jrHd| j  d| j S d| j d| j  S )Nzno close frame received or sentzsent z; no close frame receivedz	received z; no close frame sentz; then sent z; then received r2   r3   r'   r'   r(   __str__d   s   


zConnectionClosed.__str__intc                 C  s   | j d u r	tjjS | j jS r1   )r*   r   	CloseCodeABNORMAL_CLOSUREcoder6   r'   r'   r(   r;   y   s   
zConnectionClosed.codec                 C  s   | j d u rdS | j jS )N )r*   reasonr6   r'   r'   r(   r=      s   
zConnectionClosed.reasonr1   )r*   r+   r,   r+   r-   r.   r/   r0   r/   r5   )r/   r8   )	r#   r$   r%   r&   r4   r7   propertyr;   r=   r'   r'   r'   r(   r	   K   s    

r	   c                   @  r!   )r
   z
    Like :exc:`ConnectionClosed`, when the connection terminated with an error.

    A close frame with a code other than 1000 (OK) or 1001 (going away) was
    received or sent, or the closing handshake didn't complete properly.

    Nr"   r'   r'   r'   r(   r
      r)   r
   c                   @  r!   )r   z
    Like :exc:`ConnectionClosed`, when the connection terminated properly.

    A close code with code 1000 (OK) or 1001 (going away) or without a code was
    received and sent.

    Nr"   r'   r'   r'   r(   r      r)   r   c                   @  r!   )r   zK
    Raised during the handshake when the WebSocket connection fails.

    Nr"   r'   r'   r'   r(   r      r)   r   c                   @  r!   )r   zs
    Raised when a handshake request or response breaks a security rule.

    Security limits are hard coded.

    Nr"   r'   r'   r'   r(   r      r)   r   c                   @  r!   )r   zD
    Raised when a handshake request or response is malformed.

    Nr"   r'   r'   r'   r(   r      r)   r   c                   @  s&   e Zd ZdZddd	d
ZdddZdS )r   zK
    Raised when an HTTP header doesn't have a valid format or value.

    Nnamer5   value
str | Noner/   r0   c                 C     || _ || _d S r1   r@   rA   r3   r@   rA   r'   r'   r(   r4         
zInvalidHeader.__init__c                 C  sD   | j d u rd| j dS | j dkrd| j dS d| j d| j  S )Nzmissing z headerr<   zempty zinvalid z	 header: rA   r@   r6   r'   r'   r(   r7      s
   

zInvalidHeader.__str__r1   r@   r5   rA   rB   r/   r0   r>   r#   r$   r%   r&   r4   r7   r'   r'   r'   r(   r      s    r   c                      s"   e Zd ZdZd fd
dZ  ZS )r   z
    Raised when an HTTP header cannot be parsed.

    The format of the header doesn't match the grammar for that header.

    r@   r5   errorheaderposr8   r/   r0   c                   s"   t  || d| d|  d S )Nz at z in superr4   )r3   r@   rJ   rK   rL   	__class__r'   r(   r4      s   "zInvalidHeaderFormat.__init__)
r@   r5   rJ   r5   rK   r5   rL   r8   r/   r0   r#   r$   r%   r&   r4   __classcell__r'   r'   rO   r(   r      s    r   c                   @  r!   )r   z
    Raised when an HTTP header has a wrong value.

    The format of the header is correct but a value isn't acceptable.

    Nr"   r'   r'   r'   r(   r      r)   r   c                      s"   e Zd ZdZd fddZ  ZS )	r   zD
    Raised when the Origin header in a request isn't allowed.

    originrB   r/   r0   c                   s   t  d| d S )NOriginrM   )r3   rS   rO   r'   r(   r4         zInvalidOrigin.__init__)rS   rB   r/   r0   rQ   r'   r'   rO   r(   r      s    r   c                   @  r!   )r   zF
    Raised when the Upgrade or Connection header isn't correct.

    Nr"   r'   r'   r'   r(   r      r)   r   c                   @  s$   e Zd ZdZdddZdd	d
ZdS )r   zJ
    Raised when a handshake response rejects the WebSocket upgrade.

    responsehttp11.Responser/   r0   c                 C  
   || _ d S r1   )rV   )r3   rV   r'   r'   r(   r4         
zInvalidStatus.__init__r5   c                 C  s   d| j jdS )N+server rejected WebSocket connection: HTTP d)rV   status_coder6   r'   r'   r(   r7      s   zInvalidStatus.__str__N)rV   rW   r/   r0   r>   rI   r'   r'   r'   r(   r          
r   c                   @  s$   e Zd ZdZddd	ZdddZdS )r   zC
    Raised when a handshake response status code is invalid.

    r\   r8   headersdatastructures.Headersr/   r0   c                 C  rC   r1   )r\   r^   )r3   r\   r^   r'   r'   r(   r4      rF   zInvalidStatusCode.__init__r5   c                 C     d| j  S )NrZ   )r\   r6   r'   r'   r(   r7        zInvalidStatusCode.__str__N)r\   r8   r^   r_   r/   r0   r>   rI   r'   r'   r'   r(   r          
r   c                   @  r!   )r   z6
    Raised when negotiating an extension fails.

    Nr"   r'   r'   r'   r(   r     r)   r   c                   @  $   e Zd ZdZdddZddd	Zd
S )r   zK
    Raised when a parameter name is repeated in an extension header.

    r@   r5   r/   r0   c                 C  rX   r1   r@   r3   r@   r'   r'   r(   r4     rY   zDuplicateParameter.__init__c                 C  r`   )Nzduplicate parameter: rd   r6   r'   r'   r(   r7     ra   zDuplicateParameter.__str__Nr@   r5   r/   r0   r>   rI   r'   r'   r'   r(   r     r]   r   c                   @  rc   )r   zJ
    Raised when a parameter name in an extension header is invalid.

    r@   r5   r/   r0   c                 C  rX   r1   rd   re   r'   r'   r(   r4   "  rY   zInvalidParameterName.__init__c                 C  r`   )Nzinvalid parameter name: rd   r6   r'   r'   r(   r7   %  ra   zInvalidParameterName.__str__Nrf   r>   rI   r'   r'   r'   r(   r     r]   r   c                   @  s$   e Zd ZdZddd	Zdd
dZdS )r   zK
    Raised when a parameter value in an extension header is invalid.

    r@   r5   rA   rB   r/   r0   c                 C  rC   r1   rD   rE   r'   r'   r(   r4   /  rF   zInvalidParameterValue.__init__c                 C  s@   | j d u rd| j S | j dkrd| j S d| j d| j  S )Nzmissing value for parameter r<   zempty value for parameter zinvalid value for parameter z: rG   r6   r'   r'   r(   r7   3  s
   

zInvalidParameterValue.__str__NrH   r>   rI   r'   r'   r'   r(   r   )  rb   r   c                   @  s(   e Zd ZdZ	ddddZdddZdS )r   a  
    Raised to abort the handshake on purpose and return an HTTP response.

    This exception is an implementation detail.

    The public API is
    :meth:`~websockets.legacy.server.WebSocketServerProtocol.process_request`.

    Attributes:
        status (~http.HTTPStatus): HTTP status code.
        headers (Headers): HTTP response headers.
        body (bytes): HTTP response body.
        statusr   r^   datastructures.HeadersLikebodybytesr/   r0   c                 C  s"   t || _t|| _|| _d S r1   )http
HTTPStatusrh   r   Headersr^   rj   )r3   rh   r^   rj   r'   r'   r(   r4   K  s   
zAbortHandshake.__init__r5   c                 C  s(   d| j ddt| j dt| j dS )NzHTTP r[   z, z
 headers, z bytes)rh   lenr^   rj   r6   r'   r'   r(   r7   V  s   zAbortHandshake.__str__N)rg   )rh   r   r^   ri   rj   rk   r/   r0   r>   rI   r'   r'   r'   r(   r   <  s
    r   c                   @  rc   )r   zd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    urir5   r/   r0   c                 C  rX   r1   rp   )r3   rp   r'   r'   r(   r4   f  rY   zRedirectHandshake.__init__c                 C  r`   )Nzredirect to rq   r6   r'   r'   r(   r7   i  ra   zRedirectHandshake.__str__N)rp   r5   r/   r0   r>   rI   r'   r'   r'   r(   r   ^  s    
r   c                   @  r!   )r   z
    Raised when an operation is forbidden in the current state.

    This exception is an implementation detail.

    It should never be raised in normal circumstances.

    Nr"   r'   r'   r'   r(   r   m  r)   r   c                   @  s$   e Zd ZdZdddZdd	d
ZdS )r   zL
    Raised when connecting to a URI that isn't a valid WebSocket URI.

    rp   r5   msgr/   r0   c                 C  rC   r1   rp   rr   )r3   rp   rr   r'   r'   r(   r4   ~  rF   zInvalidURI.__init__c                 C  s   | j  d| j S )Nz isn't a valid URI: rs   r6   r'   r'   r(   r7     rU   zInvalidURI.__str__N)rp   r5   rr   r5   r/   r0   r>   rI   r'   r'   r'   r(   r   x  rb   r   c                   @  r!   )r   zS
    Raised when receiving a frame with a payload exceeding the maximum size.

    Nr"   r'   r'   r'   r(   r     r)   r   c                   @  r!   )r   z3
    Raised when a frame breaks the protocol.

    Nr"   r'   r'   r'   r(   r     r)   r   )&r&   
__future__r   rl   r<   r   r   r   typingr   __all__	Exceptionr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   AssertionErrorr   r   r   r   r    r'   r'   r'   r(   <module>   s>    ;

		
"