
    &thA'                       d Z ddlmZ ddlZddlmZ ddlmZmZ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 d0 d1ee           Z! G d2 d3e          Z" G d4 d5e          Z# G d6 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)Optional   )datastructuresframeshttp11)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__     i/var/www/html/mycamper/aliexpress-site/backend/venv/lib/python3.11/site-packages/websockets/exceptions.pyr	   r	   D              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
   aG  
    Raised when trying to interact with a closed connection.

    Attributes:
        rcvd (Optional[Close]): if a close frame was received, its code and
            reason are available in ``rcvd.code`` and ``rcvd.reason``.
        sent (Optional[Close]): if a close frame was sent, its code and reason
            are available in ``sent.code`` and ``sent.reason``.
        rcvd_then_sent (Optional[bool]): 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Optional[frames.Close]sentrcvd_then_sentOptional[bool]returnNonec                0    || _         || _        || _        d S Nr-   r/   r0   )selfr-   r/   r0   s       r*   __init__zConnectionClosed.__init__Z   s      		,r)   strc                    | j         &| j        | j        J dS | j        J d| j         dS | j        | j        J d| j          dS | j        J | 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 r6   r7   s    r*   __str__zConnectionClosed.__str__d   s    9y *22288*222CtyCCCCy *222C49CCCC*666& JItyIIdiIIII49IIdiIIIr)   intc                ,    | j         dn| j         j        S )Ni  )r-   coder;   s    r*   r?   zConnectionClosed.codey   s    y(ttdin<r)   c                ,    | j         dn| j         j        S )N )r-   reasonr;   s    r*   rB   zConnectionClosed.reason}   s    Y&rrDI,<<r)   r5   )r-   r.   r/   r.   r0   r1   r2   r3   r2   r9   )r2   r=   )	r$   r%   r&   r'   r8   r<   propertyr?   rB   r(   r)   r*   r
   r
   K   s         $ *.	- - - - -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 with an error.

    A close 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      s           r)   r   c                      e Zd ZdZdS )r   z
    Like :exc:`ConnectionClosed`, when the connection terminated properly.

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

    Nr#   r(   r)   r*   r   r                 r)   r   c                      e Zd ZdZdS )r   zK
    Raised during the handshake when the WebSocket connection fails.

    Nr#   r(   r)   r*   r   r      r+   r)   r   c                      e Zd ZdZdS )r   zs
    Raised when a handshake request or response breaks a security rule.

    Security limits are hard coded.

    Nr#   r(   r)   r*   r   r      rG   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d	Zdd
ZdS )r   zJ
    Raised when a HTTP header doesn't have a valid format or value.

    Nnamer9   valueOptional[str]r2   r3   c                "    || _         || _        d S r5   rL   rM   r7   rL   rM   s      r*   r8   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 headerrA   zempty zinvalid z	 header: rM   rL   r;   s    r*   r<   zInvalidHeader.__str__   sW    :0di0000Z2.DI....>di>>$*>>>r)   r5   rL   r9   rM   rN   r2   r3   rC   r$   r%   r&   r'   r8   r<   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 a HTTP header cannot be parsed.

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

    rL   r9   errorheaderposr=   r2   r3   c                \    t                                          || d| d|            d S )Nz at z in superr8   )r7   rL   rX   rY   rZ   	__class__s        r*   r8   zInvalidHeaderFormat.__init__   s9    %>>S>>f>>?????r)   )
rL   r9   rX   r9   rY   r9   rZ   r=   r2   r3   r$   r%   r&   r'   r8   __classcell__r^   s   @r*   r   r      sQ         @ @ @ @ @ @ @ @ @ @r)   r   c                      e Zd ZdZdS )r   z~
    Raised when a 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      rG   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.

    originrN   r2   r3   c                L    t                                          d|           d S )NOriginr\   )r7   rd   r^   s     r*   r8   zInvalidOrigin.__init__   s#    6*****r)   )rd   rN   r2   r3   r_   ra   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      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.

    responsehttp11.Responser2   r3   c                    || _         d S r5   )ri   )r7   ri   s     r*   r8   zInvalidStatus.__init__   s     r)   r9   c                "    d| j         j        dS )N+server rejected WebSocket connection: HTTP d)ri   status_coder;   s    r*   r<   zInvalidStatus.__str__   s!    2M-12 2	
r)   N)ri   rj   r2   r3   rC   rV   r(   r)   r*   r   r      sF         
! ! ! !
 
 
 
 
 
r)   r   c                  "    e Zd ZdZddZdd
ZdS )r   zC
    Raised when a handshake response status code is invalid.

    ro   r=   headersdatastructures.Headersr2   r3   c                "    || _         || _        d S r5   )ro   rq   )r7   ro   rq   s      r*   r8   zInvalidStatusCode.__init__   s    &r)   r9   c                    d| j          S )Nrm   )ro   r;   s    r*   r<   zInvalidStatusCode.__str__   s    OT=MOOOr)   N)ro   r=   rq   rr   r2   r3   rC   rV   r(   r)   r*   r   r      sL         
   P P P P P Pr)   r   c                      e Zd ZdZdS )r   z6
    Raised when negotiating an extension 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.

    rL   r9   r2   r3   c                    || _         d S r5   rL   r7   rL   s     r*   r8   zDuplicateParameter.__init__      			r)   c                    d| j          S )Nzduplicate parameter: rx   r;   s    r*   r<   zDuplicateParameter.__str__  s    2ty222r)   NrL   r9   r2   r3   rC   rV   r(   r)   r*   r   r   
  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.

    rL   r9   r2   r3   c                    || _         d S r5   rx   ry   s     r*   r8   zInvalidParameterName.__init__  rz   r)   c                    d| j          S )Nzinvalid parameter name: rx   r;   s    r*   r<   zInvalidParameterName.__str__   s    5$)555r)   Nr|   rC   rV   r(   r)   r*   r   r     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.

    rL   r9   rM   rN   r2   r3   c                "    || _         || _        d S r5   rP   rQ   s      r*   r8   zInvalidParameterValue.__init__*  rR   r)   c                r    | j         
d| j         S | j         dk    r
d| j         S d| j         d| j          S )Nzmissing value for parameter rA   zempty value for parameter zinvalid value for parameter z: rT   r;   s    r*   r<   zInvalidParameterValue.__str__.  sQ    :=$)===Z2;	;;;K$)KKtzKKKr)   NrU   rC   rV   r(   r)   r*   r   r   $  sL         
   L L L L L Lr)   r   c                  &    e Zd ZdZ	 dddZddZdS )r   a  
    Raised to abort the handshake on purpose and return a HTTP response.

    This exception is an implementation detail.

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

    Attributes:
        status (~http.HTTPStatus): HTTP status code.
        headers (Headers): HTTP response headers.
        body (bytes): HTTP response body.
    r)   statushttp.HTTPStatusrq   datastructures.HeadersLikebodybytesr2   r3   c                T    || _         t          j        |          | _        || _        d S r5   )r   r   Headersrq   r   )r7   r   rq   r   s       r*   r8   zAbortHandshake.__init__F  s(     %-g66			r)   r9   c                n    d| j         ddt          | j                   dt          | j                   dS )NzHTTP rn   z, z
 headers, z bytes)r   lenrq   r   r;   s    r*   r<   zAbortHandshake.__str__P  sN    &DK% & &4<  & &49~~& & &	
r)   N)r)   )r   r   rq   r   r   r   r2   r3   rC   rV   r(   r)   r*   r   r   7  sP         $ 	    
 
 
 
 
 
r)   r   c                  "    e Zd ZdZd	dZd
dZdS )r   zd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    urir9   r2   r3   c                    || _         d S r5   r   )r7   r   s     r*   r8   zRedirectHandshake.__init__`  s    r)   c                    d| j          S )Nzredirect to r   r;   s    r*   r<   zRedirectHandshake.__str__c  s    (dh(((r)   N)r   r9   r2   r3   rC   rV   r(   r)   r*   r   r   X  sF            ) ) ) ) ) )r)   r   c                      e Zd ZdZdS )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   g  s           r)   r   c                  "    e Zd ZdZd
dZddZd	S )r   zM
    Raised when connecting to an URI that isn't a valid WebSocket URI.

    r   r9   msgr2   r3   c                "    || _         || _        d S r5   r   r   )r7   r   r   s      r*   r8   zInvalidURI.__init__x  s    r)   c                $    | j          d| j         S )Nz isn't a valid URI: r   r;   s    r*   r<   zInvalidURI.__str__|  s    (:::::r)   N)r   r9   r   r9   r2   r3   rC   rV   r(   r)   r*   r   r   r  sF         
   ; ; ; ; ; ;r)   r   c                      e Zd ZdZdS )r   zS
    Raised when receiving a frame with a payload exceeding the maximum size.

    Nr#   r(   r)   r*   r   r     r+   r)   r   c                      e Zd ZdZdS )r    z3
    Raised when a frame breaks the protocol.

    Nr#   r(   r)   r*   r    r      r+   r)   r    )&r'   
__future__r   httptypingr   rA   r   r   r   __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*   <module>r      s   < # " " " " "        , , , , , , , , , ,  :       4= 4= 4= 4= 4=) 4= 4= 4=n    ,       )       )       $       %   ? ? ? ? ?$ ? ? ?&	@ 	@ 	@ 	@ 	@- 	@ 	@ 	@       + + + + +M + + +    ]   
 
 
 
 
$ 
 
 
 P P P P P( P P P    '   
3 
3 
3 
3 
3) 
3 
3 
3
6 
6 
6 
6 
6+ 
6 
6 
6L L L L L, L L L&
 
 
 
 
% 
 
 
B) ) ) ) )( ) ) )    %~   ; ; ; ; ;# ; ; ;    &       &    '   r)   