
    ,h                          d Z ddlZddlZddlZddlmZmZmZmZ ddl	m
Z ddlmZ ddlm
Z
 dZ G d d	e      Z G d
 de      Z G d de      Zdee
ef   deeef   fdZdedee   fdZdefdZdedefdZy)za
wsproto/utilities
~~~~~~~~~~~~~~~~~

Utility functions that do not belong in a separate module.
    N)DictListOptionalUnion)Headers   )Events$   258EAFA5-E914-47DA-95CA-C5AB0DC85B11c                       e Zd Zy)ProtocolErrorN)__name__
__module____qualname__     S/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/wsproto/utilities.pyr   r      s    r   r   c                       e Zd ZdZy)LocalProtocolErrorzIndicates an error due to local/programming errors.

    This is raised when the connection is asked to do something that
    is either incompatible with the state or the websocket standard.

    N)r   r   r   __doc__r   r   r   r   r      s     	r   r   c                   8     e Zd ZdZddedee   ddf fdZ xZS )RemoteProtocolErroram  Indicates an error due to the remote's actions.

    This is raised when processing the bytes from the remote if the
    remote has sent data that is incompatible with the websocket
    standard.

    .. attribute:: event_hint

       This is a suggested wsproto Event to send to the client based
       on the error. It could be None if no hint is available.

    Nmessage
event_hintreturnc                 2    || _         t        | 	  |       y N)r   super__init__)selfr   r   	__class__s      r   r   zRemoteProtocolError.__init__2   s    $!r   r   )	r   r   r   r   strr   r	   r   __classcell__)r   s   @r   r   r   $   s+    " "% "D " "r   r   h11_headersr   c                     i }| D ]&  \  }}|j                  |g       j                  |       ( i }|j                         D ]  \  }}dj                  |      ||<    |S )Ns   , )
setdefaultappenditemsjoin)r"   name_to_valuesnamevaluename_to_normed_valuevaluess         r   normed_header_dictr-   8   ss    
 02N" :e!!$+2259:&,,. 8f%*ZZ%7T"8r   r*   c                     | j                  d      D cg c]!  }|j                  d      j                         # c}S c c}w )N   ,ascii)splitdecodestrip)r*   pieces     r   split_comma_headerr5   K   s1    7<{{47HIeELL!'')IIIs   &=c                  R    t        j                  t        j                  d            S )N   )base64	b64encodeosurandomr   r   r   generate_noncer<   O   s     BJJrN++r   tokenc                     | t         z   }t        j                  |      j                         }t	        j
                  |      S r   )ACCEPT_GUIDhashlibsha1digestr8   r9   )r=   accept_tokens     r   generate_accept_tokenrD   U   s4    ;&L<<-446LL))r   )r   r8   r@   r:   typingr   r   r   r   h11._headersr   
H11Headerseventsr	   r?   	Exceptionr   r   r   bytesr-   r    r5   r<   rD   r   r   r   <module>rK      s      	 . . .   6	I 		 	"- "( E':*=$>  4uCU  &Je JS	 J, ,* *5 *r   