a
    њh                     @   sh   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d deZ
G dd	 d	eZG d
d deZdS )    N   )datastructures)InvalidHandshakeInvalidMessageProtocolError)
StatusLikec                   @   s2   e Zd ZdZeejddddZedddZ	dS )	InvalidStatusCodezC
    Raised when a handshake response status code is invalid.

    N)status_codeheadersreturnc                 C   s   || _ || _d S N)r	   r
   )selfr	   r
    r   W/wd/webapps/venvs/v2025_4um/lib/python3.9/site-packages/websockets/legacy/exceptions.py__init__   s    zInvalidStatusCode.__init__r   c                 C   s   d| j  S )Nz+server rejected WebSocket connection: HTTP )r	   r   r   r   r   __str__   s    zInvalidStatusCode.__str__)
__name__
__module____qualname____doc__intr   Headersr   strr   r   r   r   r   r      s   r   c                   @   s6   e Zd ZdZd
eejeddddZe	ddd	Z
dS )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.
        N)statusr
   bodyr   c                 C   s"   t || _t|| _|| _d S r   )http
HTTPStatusr   r   r   r
   r   )r   r   r
   r   r   r   r   r   *   s    zAbortHandshake.__init__r   c                 C   s(   d| j ddt| j dt| j dS )NzHTTP dz, z
 headers, z bytes)r   lenr
   r   r   r   r   r   r   5   s    &zAbortHandshake.__str__)r   )r   r   r   r   r   r   ZHeadersLikebytesr   r   r   r   r   r   r   r      s    r   c                   @   s.   e Zd ZdZeddddZedddZdS )	RedirectHandshakezd
    Raised when a handshake gets redirected.

    This exception is an implementation detail.

    N)urir   c                 C   s
   || _ d S r   r%   )r   r%   r   r   r   r   C   s    zRedirectHandshake.__init__r   c                 C   s   d| j  S )Nzredirect to r&   r   r   r   r   r   F   s    zRedirectHandshake.__str__)r   r   r   r   r   r   r   r   r   r   r   r$   ;   s   r$   )r    r   
exceptionsr   r   r   ZWebSocketProtocolErrortypingr   r   r   r$   r   r   r   r   <module>   s    