Ë
    RPf8(  ã                  óf  — 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	 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/„ d0e«      Z  G d1„ d2ee!«      Z" G d3„ d4e«      Z# G d5„ d6e«      Z$ G d7„ d8e«      Z%e%Z&y)9ay  
: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)Ú
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y)r
   z?
    Base class for all exceptions defined by websockets.

    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úO/var/www/fastapitest/venv/lib/python3.12/site-packages/websockets/exceptions.pyr
   r
   E   ó   „ ò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y)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.

    Nc                ó.   — || _         || _        || _        y ©N©ÚrcvdÚsentÚrcvd_then_sent)Úselfr1   r2   r3   s       r+   Ú__init__zConnectionClosed.__init__[   s   € ð ˆŒ	ØˆŒ	Ø,ˆÕr*   c                ó„  — | j                   €9| j                  €| j                  �J ‚y| 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 r0   ©r4   s    r+   Ú__str__zConnectionClosed.__str__e   sÓ   € Ø�9‰9ÐØ�y‰yÐ Ø×*Ñ*Ð2Ð2Ð2Ø8à×*Ñ*Ð2Ð2Ð2Ø˜tŸy™y˜kÐ)BÐCÐCà�y‰yÐ Ø×*Ñ*Ð2Ð2Ð2Ø" 4§9¡9 +Ð-BÐCÐCà×*Ñ*Ð6Ð6Ð6Ø×&Ò&Ø& t§y¡y k°¸d¿i¹i¸[ÐIÐIà" 4§9¡9 +Ð-=¸d¿i¹i¸[ÐIÐIr*   c                óz   — | j                   €t        j                  j                  S | j                   j                  S r/   )r1   r   Ú	CloseCodeÚABNORMAL_CLOSUREÚcoder7   s    r+   r<   zConnectionClosed.codez   s,   € à�9‰9ÐÜ×#Ñ#×4Ñ4Ð4Ø�y‰y�~‰~Ðr*   c                óH   — | j                   €y| j                   j                  S )NÚ )r1   Úreasonr7   s    r+   r?   zConnectionClosed.reason€   s   € à�9‰9ÐØØ�y‰y×ÑÐr*   r/   )r1   úOptional[frames.Close]r2   r@   r3   zOptional[bool]ÚreturnÚNone©rA   Ústr)rA   Úint)	r%   r&   r'   r(   r5   r8   Úpropertyr<   r?   r)   r*   r+   r   r   L   se   „ ñð$ *.ð	-à$ð-ð %ð-ð 'ð	-ð
 
ó-óJð* òó ðð
 ò ó ñ r*   r   c                  ó   — e Zd ZdZy)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                  ó   — e Zd ZdZy)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   ‘   rH   r*   r   c                  ó   — e Zd ZdZy)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y)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                  ó   — e Zd ZdZy)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y)r   zK
    Raised when an HTTP header doesn't have a valid format or value.

    Nc                ó    — || _         || _        y r/   ©ÚnameÚvalue©r4   rQ   rR   s      r+   r5   zInvalidHeader.__init__¸   ó   € ØˆŒ	Øˆ�
r*   c                ó°   — | j                   €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: ©rR   rQ   r7   s    r+   r8   zInvalidHeader.__str__¼   sY   € Ø�:‰:ÐØ˜dŸi™i˜[¨Ð0Ð0Ø�Z‰Z˜2ÒØ˜DŸI™I˜; gÐ.Ð.à˜dŸi™i˜[¨	°$·*±*°Ð>Ð>r*   r/   ©rQ   rD   rR   úOptional[str]rA   rB   rC   ©r%   r&   r'   r(   r5   r8   r)   r*   r+   r   r   ²   s   „ ñô
ô?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.

    c                ó6   •— t         ‰| �  ||› d|› d|› �«       y )Nz at z in ©Úsuperr5   )r4   rQ   ÚerrorÚheaderÚposÚ	__class__s        €r+   r5   zInvalidHeaderFormat.__init__Í   s#   ø€ Ü‰Ñ˜ % ¨¨S¨E°°f°XÐ>Õ?r*   )
rQ   rD   r^   rD   r_   rD   r`   rE   rA   rB   ©r%   r&   r'   r(   r5   Ú__classcell__©ra   s   @r+   r   r   Å   s   ø„ ñ÷@ñ @r*   r   c                  ó   — e Zd ZdZy)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   Ñ   rL   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.

    c                ó&   •— t         ‰| �  d|«       y )NÚOriginr\   )r4   Úoriginra   s     €r+   r5   zInvalidOrigin.__init__à   s   ø€ Ü‰Ñ˜ 6Õ*r*   )ri   rX   rA   rB   rb   rd   s   @r+   r   r   Ú   s   ø„ ñ÷
+ñ +r*   r   c                  ó   — e Zd ZdZy)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y)r   zJ
    Raised when a handshake response rejects the WebSocket upgrade.

    c                ó   — || _         y r/   )Úresponse)r4   rm   s     r+   r5   zInvalidStatus.__init__ñ   s	   € Ø ˆ�r*   c                ó6   — d| j                   j                  d›�S )Nú+server rejected WebSocket connection: HTTP Úd)rm   Ústatus_coder7   s    r+   r8   zInvalidStatus.__str__ô   s#   € ðØ—M‘M×-Ñ-¨aÐ0ð2ð	
r*   N)rm   zhttp11.ResponserA   rB   rC   rY   r)   r*   r+   r   r   ë   s   „ ñó
!ô
r*   r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zC
    Raised when a handshake response status code is invalid.

    c                ó    — || _         || _        y r/   )rq   Úheaders)r4   rq   rt   s      r+   r5   zInvalidStatusCode.__init__  s   € Ø&ˆÔØˆ�r*   c                ó    — d| j                   › �S )Nro   )rq   r7   s    r+   r8   zInvalidStatusCode.__str__  s   € Ø<¸T×=MÑ=MÐ<NÐOÐOr*   N)rq   rE   rt   zdatastructures.HeadersrA   rB   rC   rY   r)   r*   r+   r   r   û   s   „ ñó
ôPr*   r   c                  ó   — e Zd ZdZy)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y)r   zK
    Raised when a parameter name is repeated in an extension header.

    c                ó   — || _         y r/   ©rQ   ©r4   rQ   s     r+   r5   zDuplicateParameter.__init__  ó	   € Øˆ�	r*   c                ó    — d| j                   › �S )Nzduplicate parameter: ry   r7   s    r+   r8   zDuplicateParameter.__str__  s   € Ø& t§y¡y kÐ2Ð2r*   N©rQ   rD   rA   rB   rC   rY   r)   r*   r+   r   r     s   „ ñó
ô3r*   r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zJ
    Raised when a parameter name in an extension header is invalid.

    c                ó   — || _         y r/   ry   rz   s     r+   r5   zInvalidParameterName.__init__#  r{   r*   c                ó    — d| j                   › �S )Nzinvalid parameter name: ry   r7   s    r+   r8   zInvalidParameterName.__str__&  s   € Ø)¨$¯)©)¨Ð5Ð5r*   Nr}   rC   rY   r)   r*   r+   r   r     s   „ ñó
ô6r*   r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zK
    Raised when a parameter value in an extension header is invalid.

    c                ó    — || _         || _        y r/   rP   rS   s      r+   r5   zInvalidParameterValue.__init__0  rT   r*   c                ó¬   — | j                   €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: rV   r7   s    r+   r8   zInvalidParameterValue.__str__4  sU   € Ø�:‰:ÐØ1°$·)±)°Ð=Ð=Ø�Z‰Z˜2ÒØ/°·	±	¨{Ð;Ð;à1°$·)±)°¸B¸t¿z¹z¸lÐKÐKr*   NrW   rC   rY   r)   r*   r+   r   r   *  s   „ ñó
ôLr*   r   c                  ó2   — e Zd ZdZ	 d	 	 	 	 	 	 	 dd„Zdd„Zy)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.server.WebSocketServerProtocol.process_request`.

    Attributes:
        status (~http.HTTPStatus): HTTP status code.
        headers (Headers): HTTP response headers.
        body (bytes): HTTP response body.
    c                óz   — t        j                  |«      | _        t        j                  |«      | _        || _        y r/   )ÚhttpÚ
HTTPStatusÚstatusr   ÚHeadersrt   Úbody)r4   rˆ   rt   rŠ   s       r+   r5   zAbortHandshake.__init__L  s-   € ô —o‘o fÓ-ˆŒÜ%×-Ñ-¨gÓ6ˆŒØˆ�	r*   c                ó|   — d| j                   d›dt        | j                  «      › dt        | j                  «      › d�S )NzHTTP rp   z, z
 headers, z bytes)rˆ   Úlenrt   rŠ   r7   s    r+   r8   zAbortHandshake.__str__W  s<   € à�D—K‘K �? "Ü�4—<‘<Ó Ð! Ü�4—9‘9‹~Ð˜fð&ð	
r*   N)r*   )rˆ   r	   rt   zdatastructures.HeadersLikerŠ   ÚbytesrA   rB   rC   rY   r)   r*   r+   r   r   =  s<   „ ñð$ ð		àð	ð ,ð	ð ð		ð
 
ó	ô
r*   r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    c                ó   — || _         y r/   ©Úuri)r4   r‘   s     r+   r5   zRedirectHandshake.__init__g  s	   € Øˆ�r*   c                ó    — d| j                   › �S )Nzredirect to r�   r7   s    r+   r8   zRedirectHandshake.__str__j  s   € Ø˜dŸh™h˜ZÐ(Ð(r*   N)r‘   rD   rA   rB   rC   rY   r)   r*   r+   r   r   _  s   „ ñóô)r*   r   c                  ó   — e Zd ZdZy)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   n  s   „ òr*   r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zL
    Raised when connecting to a URI that isn't a valid WebSocket URI.

    c                ó    — || _         || _        y r/   ©r‘   Úmsg)r4   r‘   r—   s      r+   r5   zInvalidURI.__init__  s   € ØˆŒØˆ�r*   c                ó8   — | j                   › d| j                  › �S )Nz isn't a valid URI: r–   r7   s    r+   r8   zInvalidURI.__str__ƒ  s   € Ø—(‘(�Ð/°·±¨zÐ:Ð:r*   N)r‘   rD   r—   rD   rA   rB   rC   rY   r)   r*   r+   r   r   y  s   „ ñó
ô;r*   r   c                  ó   — e Zd ZdZy)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y)r!   z3
    Raised when a frame breaks the protocol.

    Nr$   r)   r*   r+   r!   r!   Ž  r,   r*   r!   )'r(   Ú
__future__r   r†   Útypingr   r>   r   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       sj  ðñõ< #ã Ý ç ,Ñ ,Ý ò€ô:˜ô ô8 Ð)ô 8 ôvÐ,ô ôÐ)ô ôÐ)ô ôÐ$ô ôÐ%ô ô?Ð$ô ?ô&	@˜-ô 	@ô˜ô ô+�Mô +ô�]ô ô
Ð$ô 
ô PÐ(ô PôÐ'ô ô
3Ð)ô 
3ô
6Ð+ô 
6ôLÐ,ô Lô&
Ð%ô 
ôD)Ð(ô )ôÐ% ~ô ô;Ð#ô ;ôÐ&ô ôÐ&ô ð 'Ñ r*   