
    g                         d dl Z ddlmZ ddlmZmZ ddlmZ  G d de      Z	 G d d	e      Z
 G d
 de      Z G d de      Zy)    N   )datastructures)InvalidHandshakeProtocolError)
StatusLikec                       e Zd ZdZy)InvalidMessagezD
    Raised when a handshake request or response is malformed.

    N)__name__
__module____qualname____doc__     Q/var/www/openai/venv/lib/python3.12/site-packages/websockets/legacy/exceptions.pyr	   r	      s    r   r	   c                   D    e Zd ZdZdedej                  ddfdZdefdZ	y)InvalidStatusCodezC
    Raised when a handshake response status code is invalid.

    status_codeheadersreturnNc                      || _         || _        y N)r   r   )selfr   r   s      r   __init__zInvalidStatusCode.__init__   s    &r   c                      d| j                    S )Nz+server rejected WebSocket connection: HTTP )r   r   s    r   __str__zInvalidStatusCode.__str__   s    <T=M=M<NOOr   )
r
   r   r   r   intr   Headersr   strr   r   r   r   r   r      s5    
C .2H2H T P Pr   r   c            	       L    e Zd ZdZ	 d	dedej                  deddfdZde	fdZ
y)
AbortHandshakea  
    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   bodyr   Nc                 z    t        j                  |      | _        t        j                  |      | _        || _        y r   )http
HTTPStatusr"   r   r   r   r#   )r   r"   r   r#   s       r   r   zAbortHandshake.__init__/   s-     oof-%--g6	r   c                 |    d| j                   ddt        | j                         dt        | j                         dS )NzHTTP dz, z
 headers, z bytes)r"   lenr   r#   r   s    r   r   zAbortHandshake.__str__:   s<    DKK?"4<< !499~f&	
r   )r   )r
   r   r   r   r   r   HeadersLikebytesr   r   r   r   r   r   r!   r!       sI    $ 			  ++	 		
 
	
 
r   r!   c                   ,    e Zd ZdZdeddfdZdefdZy)RedirectHandshakezd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    urir   Nc                     || _         y r   r.   )r   r.   s     r   r   zRedirectHandshake.__init__J   s	    r   c                      d| j                    S )Nzredirect to r0   r   s    r   r   zRedirectHandshake.__str__M   s    dhhZ((r   )r
   r   r   r   r   r   r   r   r   r   r-   r-   B   s&    C D ) )r   r-   )r%    r   
exceptionsr   r   WebSocketProtocolErrortypingr   r	   r   r!   r-   r   r   r   <module>r6      sL       % P( P
% 
D)( )r   