
    g2                    R   d Z ddlmZ ddlZddlmZ g dZ G d de          Z G d	 d
e          Z	 G d de	          Z
 G d de	          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d d e          Z G d! d"e          Z G d# d$e          Z G d% d&e          Z G d' d(e          Z G d) d*e          Z G d+ d,e          Z G d- d.e          Z G d/ d0e          Z G d1 d2e          Z G d3 d4e          Z G d5 d6e          Z G d7 d8ee           Z! G d9 d:ee"          Z#dd;l$m%Z%m&Z&  e e'            d<d<d<d<d=>           dS )?aU  
:mod:`websockets.exceptions` defines the following hierarchy of exceptions.

* :exc:`WebSocketException`
    * :exc:`ConnectionClosed`
        * :exc:`ConnectionClosedOK`
        * :exc:`ConnectionClosedError`
    * :exc:`InvalidURI`
    * :exc:`InvalidProxy`
    * :exc:`InvalidHandshake`
        * :exc:`SecurityError`
        * :exc:`ProxyError`
            * :exc:`InvalidProxyMessage`
            * :exc:`InvalidProxyStatus`
        * :exc:`InvalidMessage`
        * :exc:`InvalidStatus`
        * :exc:`InvalidStatusCode` (legacy)
        * :exc:`InvalidHeader`
            * :exc:`InvalidHeaderFormat`
            * :exc:`InvalidHeaderValue`
            * :exc:`InvalidOrigin`
            * :exc:`InvalidUpgrade`
        * :exc:`NegotiationError`
            * :exc:`DuplicateParameter`
            * :exc:`InvalidParameterName`
            * :exc:`InvalidParameterValue`
        * :exc:`AbortHandshake` (legacy)
        * :exc:`RedirectHandshake` (legacy)
    * :exc:`ProtocolError` (Sans-I/O)
    * :exc:`PayloadTooBig` (Sans-I/O)
    * :exc:`InvalidState` (Sans-I/O)
    * :exc:`ConcurrencyError`

    )annotationsN   )lazy_import)WebSocketExceptionConnectionClosedConnectionClosedOKConnectionClosedError
InvalidURIInvalidProxyInvalidHandshakeSecurityError
ProxyErrorInvalidProxyMessageInvalidProxyStatusInvalidMessageInvalidStatusInvalidHeaderInvalidHeaderFormatInvalidHeaderValueInvalidOriginInvalidUpgradeNegotiationErrorDuplicateParameterInvalidParameterNameInvalidParameterValueProtocolErrorPayloadTooBigInvalidStateConcurrencyErrorc                      e Zd ZdZdS )r   z?
    Base class for all exceptions defined by websockets.

    N__name__
__module____qualname____doc__     a/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/websockets/exceptions.pyr   r   I              r'   r   c                  V    e Zd ZdZ	 ddd
ZddZedd            Zedd            ZdS )r   a  
    Raised when trying to interact with a closed connection.

    Attributes:
        rcvd: If a close frame was received, its code and reason are available
            in ``rcvd.code`` and ``rcvd.reason``.
        sent: If a close frame was sent, its code and reason are available
            in ``sent.code`` and ``sent.reason``.
        rcvd_then_sent: 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                n    || _         || _        || _        | j        d u | j         d u p| j        d u k    sJ d S Nr+   r-   r.   )selfr+   r-   r.   s       r(   __init__zConnectionClosed.__init___   sM     		,#t+d1B1WdiSWFWXXXXXXr'   strc                    | j         | j        dS d| j         dS | j        d| j          dS | j        rd| 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 r4   r5   s    r(   __str__zConnectionClosed.__str__j   s    9y 88CtyCCCCy C49CCCC& JItyIIdiIIII49IIdiIIIr'   intc                ~    t          j        dt                     | j        t          j        j        S | j        j        S )NzZConnectionClosed.code is deprecated; use Protocol.close_code or ConnectionClosed.rcvd.code)warningswarnDeprecationWarningr+   frames	CloseCodeABNORMAL_CLOSUREcoder9   s    r(   rC   zConnectionClosed.code{   s?    D	
 	
 	

 9#44y~r'   c                `    t          j        dt                     | j        dS | j        j        S )Nz`ConnectionClosed.reason is deprecated; use Protocol.close_reason or ConnectionClosed.rcvd.reason )r=   r>   r?   r+   reasonr9   s    r(   rF   zConnectionClosed.reason   s9    H	
 	
 	

 92yr'   r3   )r+   r,   r-   r,   r.   r/   r0   r1   r0   r7   )r0   r;   )	r"   r#   r$   r%   r6   r:   propertyrC   rF   r&   r'   r(   r   r   P   s         $ '+		Y 	Y 	Y 	Y 	YJ J J J"    X       X     r'   r   c                      e Zd ZdZdS )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                      e Zd ZdZdS )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	      rJ   r'   r	   c                  "    e Zd ZdZd
dZddZd	S )r
   zL
    Raised when connecting to a URI that isn't a valid WebSocket URI.

    urir7   msgr0   r1   c                "    || _         || _        d S r3   rM   rN   )r5   rM   rN   s      r(   r6   zInvalidURI.__init__   s    r'   c                $    | j          d| j         S )Nz isn't a valid URI: rP   r9   s    r(   r:   zInvalidURI.__str__   s    (:::::r'   N)rM   r7   rN   r7   r0   r1   rG   r"   r#   r$   r%   r6   r:   r&   r'   r(   r
   r
      sF         
   ; ; ; ; ; ;r'   r
   c                  "    e Zd ZdZd
dZddZd	S )r   z?
    Raised when connecting via a proxy that isn't valid.

    proxyr7   rN   r0   r1   c                "    || _         || _        d S r3   rT   rN   )r5   rT   rN   s      r(   r6   zInvalidProxy.__init__   s    
r'   c                $    | j          d| j         S )Nz isn't a valid proxy: rV   r9   s    r(   r:   zInvalidProxy.__str__   s    *>>DH>>>r'   N)rT   r7   rN   r7   r0   r1   rG   rR   r&   r'   r(   r   r      sF         
   ? ? ? ? ? ?r'   r   c                      e Zd ZdZdS )r   zM
    Base class for exceptions raised when the opening handshake fails.

    Nr!   r&   r'   r(   r   r      r)   r'   r   c                      e Zd ZdZdS )r   z
    Raised when a handshake request or response breaks a security rule.

    Security limits can be configured with :doc:`environment variables
    <../reference/variables>`.

    Nr!   r&   r'   r(   r   r      rJ   r'   r   c                      e Zd ZdZdS )r   z5
    Raised when failing to connect to a proxy.

    Nr!   r&   r'   r(   r   r      r)   r'   r   c                      e Zd ZdZdS )r   z;
    Raised when an HTTP proxy response is malformed.

    Nr!   r&   r'   r(   r   r      r)   r'   r   c                  "    e Zd ZdZd
dZddZd	S )r   z<
    Raised when an HTTP proxy rejects the connection.

    responsehttp11.Responser0   r1   c                    || _         d S r3   r]   r5   r]   s     r(   r6   zInvalidProxyStatus.__init__        r'   r7   c                "    d| j         j        dS )Nz proxy rejected connection: HTTP dr]   status_coder9   s    r(   r:   zInvalidProxyStatus.__str__   s    O$-2KOOOOr'   Nr]   r^   r0   r1   rG   rR   r&   r'   r(   r   r      sL         
! ! ! !P P P P P Pr'   r   c                      e Zd ZdZdS )r   zD
    Raised when a handshake request or response is malformed.

    Nr!   r&   r'   r(   r   r      r)   r'   r   c                  "    e Zd ZdZd
dZddZd	S )r   zJ
    Raised when a handshake response rejects the WebSocket upgrade.

    r]   r^   r0   r1   c                    || _         d S r3   r`   ra   s     r(   r6   zInvalidStatus.__init__   rb   r'   r7   c                "    d| j         j        dS )Nz+server rejected WebSocket connection: HTTP rd   re   r9   s    r(   r:   zInvalidStatus.__str__   s    W$-:SWWW	
r'   Nrg   rG   rR   r&   r'   r(   r   r      sF         
! ! ! !
 
 
 
 
 
r'   r   c                  $    e Zd ZdZddd	Zdd
ZdS )r   zK
    Raised when an HTTP header doesn't have a valid format or value.

    Nnamer7   value
str | Noner0   r1   c                "    || _         || _        d S r3   rm   rn   r5   rm   rn   s      r(   r6   zInvalidHeader.__init__
      	


r'   c                v    | j         d| j         dS | j         dk    rd| j         dS d| j         d| j          S )Nzmissing z headerrE   zempty zinvalid z	 header: rn   rm   r9   s    r(   r:   zInvalidHeader.__str__  sW    :0di0000Z2.DI....>di>>$*>>>r'   r3   rm   r7   rn   ro   r0   r1   rG   rR   r&   r'   r(   r   r     sK         
    ? ? ? ? ? ?r'   r   c                  $     e Zd ZdZd fd
Z x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.

    rm   r7   errorheaderposr;   r0   r1   c                \    t                                          || d| d|            d S )Nz at z in superr6   )r5   rm   rx   ry   rz   	__class__s        r(   r6   zInvalidHeaderFormat.__init__  s9    %>>S>>f>>?????r'   )
rm   r7   rx   r7   ry   r7   rz   r;   r0   r1   r"   r#   r$   r%   r6   __classcell__r~   s   @r(   r   r     sQ         @ @ @ @ @ @ @ @ @ @r'   r   c                      e Zd ZdZdS )r   z
    Raised when an HTTP header has a wrong value.

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

    Nr!   r&   r'   r(   r   r   #  s           r'   r   c                  $     e Zd ZdZd fdZ xZS )r   zD
    Raised when the Origin header in a request isn't allowed.

    originro   r0   r1   c                L    t                                          d|           d S )NOriginr|   )r5   r   r~   s     r(   r6   zInvalidOrigin.__init__2  s#    6*****r'   )r   ro   r0   r1   r   r   s   @r(   r   r   ,  sG         
+ + + + + + + + + +r'   r   c                      e Zd ZdZdS )r   zF
    Raised when the Upgrade or Connection header isn't correct.

    Nr!   r&   r'   r(   r   r   6  r)   r'   r   c                      e Zd ZdZdS )r   zG
    Raised when negotiating an extension or a subprotocol fails.

    Nr!   r&   r'   r(   r   r   =  r)   r'   r   c                  "    e Zd ZdZd	dZd
dZdS )r   zK
    Raised when a parameter name is repeated in an extension header.

    rm   r7   r0   r1   c                    || _         d S r3   rm   r5   rm   s     r(   r6   zDuplicateParameter.__init__J      			r'   c                    d| j          S )Nzduplicate parameter: r   r9   s    r(   r:   zDuplicateParameter.__str__M  s    2ty222r'   Nrm   r7   r0   r1   rG   rR   r&   r'   r(   r   r   D  sF         
   3 3 3 3 3 3r'   r   c                  "    e Zd ZdZd	dZd
dZdS )r   zJ
    Raised when a parameter name in an extension header is invalid.

    rm   r7   r0   r1   c                    || _         d S r3   r   r   s     r(   r6   zInvalidParameterName.__init__W  r   r'   c                    d| j          S )Nzinvalid parameter name: r   r9   s    r(   r:   zInvalidParameterName.__str__Z  s    5$)555r'   Nr   rG   rR   r&   r'   r(   r   r   Q  sF         
   6 6 6 6 6 6r'   r   c                  "    e Zd ZdZddZdd	Zd
S )r   zK
    Raised when a parameter value in an extension header is invalid.

    rm   r7   rn   ro   r0   r1   c                "    || _         || _        d S r3   rq   rr   s      r(   r6   zInvalidParameterValue.__init__d  rs   r'   c                r    | j         
d| j         S | j         dk    r
d| j         S d| j         d| j          S )Nzmissing value for parameter rE   zempty value for parameter zinvalid value for parameter z: ru   r9   s    r(   r:   zInvalidParameterValue.__str__h  sQ    :=$)===Z2;	;;;K$)KKtzKKKr'   Nrv   rG   rR   r&   r'   r(   r   r   ^  sL         
   L L L L L Lr'   r   c                      e Zd ZdZdS )r   a  
    Raised when receiving or sending a frame that breaks the protocol.

    The Sans-I/O implementation raises this exception when:

    * receiving or sending a frame that contains invalid data;
    * receiving or sending an invalid sequence of frames.

    Nr!   r&   r'   r(   r   r   q  s           r'   r   c                  0    e Zd ZdZ	 	 ddd
ZddZddZdS )r   aU  
    Raised when parsing a frame with a payload that exceeds the maximum size.

    The Sans-I/O layer uses this exception internally. It doesn't bubble up to
    the I/O layer.

    The :meth:`~websockets.extensions.Extension.decode` method of extensions
    must raise :exc:`PayloadTooBig` if decoding a frame would exceed the limit.

    Nsize_or_messageint | None | strmax_size
int | Nonecur_sizer0   r1   c                    t          |t                    r+|J |J t          j        dt                     || _        d S d | _        || _        |J || _        d | _        | 	                    |           d S )NzMPayloadTooBig(message) is deprecated; change to PayloadTooBig(size, max_size))

isinstancer7   r=   r>   r?   messagesizer   r   set_current_size)r5   r   r   r   s       r(   r6   zPayloadTooBig.__init__  s     os++ 	,######M:"  
 (7DLLLDL$3DI'''!)DM(,DM!!(+++++r'   r7   c                    | j         | j         S d}| j        |d| j         dz  }| j        |d| j         dz  }|d| j         dz  }|S )Nzframe zwith z bytes zafter reading zexceeds limit of z bytes)r   r   r   r   )r5   r   s     r(   r:   zPayloadTooBig.__str__  st    <#<Gy$5495555}(BDMBBBB@4=@@@@GNr'   c                N    | j         J || xj        |z  c_        || _         d S d S r3   )r   r   )r5   r   s     r(   r   zPayloadTooBig.set_current_size  s9    }$$$MMX%MM$DMMM  r'   )NN)r   r   r   r   r   r   r0   r1   rG   )r   r   r0   r1   )r"   r#   r$   r%   r6   r:   r   r&   r'   r(   r   r   }  sg        	 	  $#	, , , , ,.
 
 
 
% % % % % %r'   r   c                      e Zd ZdZdS )r   a  
    Raised when sending a frame is forbidden in the current state.

    Specifically, the Sans-I/O layer raises this exception when:

    * sending a data frame to a connection in a state other
      :attr:`~websockets.protocol.State.OPEN`;
    * sending a control frame to a connection in a state other than
      :attr:`~websockets.protocol.State.OPEN` or
      :attr:`~websockets.protocol.State.CLOSING`.

    Nr!   r&   r'   r(   r   r     s           r'   r   c                      e Zd ZdZdS )r   z
    Raised when receiving or sending messages concurrently.

    WebSocket is a connection-oriented protocol. Reads must be serialized; so
    must be writes. However, reading and writing concurrently is possible.

    Nr!   r&   r'   r(   r   r     rJ   r'   r   )r@   http11z.legacy.exceptions)AbortHandshakeInvalidStatusCodeRedirectHandshakeWebSocketProtocolError)deprecated_aliases)(r%   
__future__r   r=   importsr   __all__	Exceptionr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   AssertionErrorr   RuntimeErrorr   rE   r@   r   globalsr&   r'   r(   <module>r      s%  ! !F # " " " " "               <       ?  ?  ?  ?  ? ) ?  ?  ? D    )       ,   ; ; ; ; ;# ; ; ;? ? ? ? ?% ? ? ?    )       $       !       *   
P 
P 
P 
P 
P 
P 
P 
P    %   
 
 
 
 
$ 
 
 
? ? ? ? ?$ ? ? ?&	@ 	@ 	@ 	@ 	@- 	@ 	@ 	@       + + + + +M + + +    ]       '   
3 
3 
3 
3 
3) 
3 
3 
3
6 
6 
6 
6 
6+ 
6 
6 
6L L L L L, L L L&	 	 	 	 	& 	 	 	3% 3% 3% 3% 3%& 3% 3% 3%l    %~       )<            GII /11"6 	 	 	 	 	 	r'   