zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
U
[±d ã@sâdZddlZddlZddlZddlmZmZmZmZddl    m
Z ddl m Z ddlm
Z
dZGdd    „d    eƒZGd
d „d eƒZGd d „d eƒZee
e feeefdœdd„Zeeedœdd„Zedœdd„Zeedœdd„ZdS)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@s eZdZdS)Ú ProtocolErrorN)Ú__name__Ú
__module__Ú __qualname__©r r úHd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\wsproto/utilities.pyr    sr    c@seZdZdZdS)ÚLocalProtocolErrorzÄIndicates 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 rrsrcs0eZdZdZdeeeddœ‡fdd„ Z‡ZS)ÚRemoteProtocolErroramIndicates 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Úreturncs||_tƒ |¡dS©N)rÚsuperÚ__init__)Úselfrr©Ú    __class__r rr2szRemoteProtocolError.__init__)N)    r
r r rÚstrrrrÚ __classcell__r r rrr$s r)Ú h11_headersrcCsLi}|D]\}}| |g¡ |¡qi}| ¡D]\}}d |¡||<q0|S)Ns, )Ú
setdefaultÚappendÚitemsÚjoin)rZname_to_valuesÚnameÚvalueZname_to_normed_valueÚvaluesr r rÚnormed_header_dict8s r%)r#rcCsdd„| d¡DƒS)NcSsg|]}| d¡ ¡‘qS)Úascii)ÚdecodeÚstrip)Ú.0Zpiecer r rÚ
<listcomp>Lsz&split_comma_header.<locals>.<listcomp>ó,)Úsplit)r#r r rÚsplit_comma_headerKsr-)rcCst t d¡¡S)Né)Úbase64Ú    b64encodeÚosÚurandomr r r rÚgenerate_nonceOsr3)ÚtokenrcCs |t}t |¡ ¡}t |¡Sr)Ú ACCEPT_GUIDÚhashlibÚsha1Údigestr/r0)r4Z accept_tokenr r rÚgenerate_accept_tokenUsr9)rr/r6r1ÚtypingrrrrZ h11._headersrZ
H11HeadersÚeventsrr5Ú    Exceptionr    rrÚbytesr%rr-r3r9r r r rÚ<module>s