ó
    ÖÁ“i¥  ã                  ó¤   • S SK Jr  S SKrS SKrSSKJrJr  SSKJrJ	r	J
r
  SSKJrJr  SSKJrJr  SSKJrJr  / S	QrSS
 jrSS jrSS jrSS jrg)é    )ÚannotationsNé   )ÚHeadersÚMultipleValuesError)ÚInvalidHeaderÚInvalidHeaderValueÚInvalidUpgrade)Úparse_connectionÚparse_upgrade)ÚConnectionOptionÚUpgradeProtocol)Ú
accept_keyÚgenerate_key)Úbuild_requestÚcheck_requestÚbuild_responseÚcheck_responsec                ó@   • [        5       nSU S'   SU S'   XS'   SU S'   U$ )zÓ
Build a handshake request to send to the server.

Update request headers passed in argument.

Args:
    headers: Handshake request headers.

Returns:
    ``key`` that must be passed to :func:`check_response`.

Ú	websocketÚUpgradeÚ
ConnectionúSec-WebSocket-KeyÚ13úSec-WebSocket-Version)r   ©ÚheadersÚkeys     ÚX/home/mande/repo/quber/.venv/lib/python3.13/site-packages/websockets/legacy/handshake.pyr   r      s8   € ô ‹.€CØ$€GˆIÑØ%€GˆLÑØ#&ÐÑ Ø'+€GÐ#Ñ$Ø€Jó    c                óÀ  • [        U R                  S5       Vs/ s H  n[        U5      PM     sn/ 5      n[        S U 5       5      (       d  [	        SSR                  U5      5      e[        U R                  S5       Vs/ s H  n[        U5      PM     sn/ 5      n[        U5      S:X  a  US   R                  5       S:X  d  [	        SSR                  U5      5      e U S   n [        R                  " UR                  5       SS9n[        U5      S:w  a  [#        SU5      e U S   nUS:w  a  [#        SU5      eU$ s  snf s  snf ! [         a  n[        S5      UeS	nAf[         a  n[        SS
5      UeS	nAff = f! [        R                    a  n[#        SU5      UeS	nAff = f! [         a  n[        S5      UeS	nAf[         a  n[        SS
5      UeS	nAff = f)a.  
Check a handshake request received from the client.

This function doesn't verify that the request is an HTTP/1.1 or higher GET
request and doesn't perform ``Host`` and ``Origin`` checks. These controls
are usually performed earlier in the HTTP request handling code. They're
the responsibility of the caller.

Args:
    headers: Handshake request headers.

Returns:
    ``key`` that must be passed to :func:`build_response`.

Raises:
    InvalidHandshake: If the handshake request is invalid.
        Then, the server must return a 400 Bad Request error.

r   c              3  óF   #   • U  H  oR                  5       S :H  v •  M     g7f©ÚupgradeN©Úlower©Ú.0Úvalues     r   Ú	<genexpr>Ú check_request.<locals>.<genexpr>=   ó   é € ÐB²z¨e�{‰{‹} 	Ö)²zùó   ‚!ú, r   é   r   r   r   Númultiple valuesT)Úvalidateé   r   r   )ÚsumÚget_allr
   Úanyr	   Újoinr   Úlenr%   ÚKeyErrorr   r   Úbase64Ú	b64decodeÚencodeÚbinasciiÚErrorr   )r   r(   Ú
connectionr#   Ús_w_keyÚexcÚraw_keyÚs_w_versions           r   r   r   %   sç  € ô( *-Ø.5¯o©o¸lÔ.KÓLÒ.K UÔ	˜%Ö	 Ñ.KÑLÈbó*€Jô ÑB±zÓB×BÑBÜ˜\¨4¯9©9°ZÓ+@ÓAÐAä%(Ø+2¯?©?¸9Ô+EÓFÒ+E %Œ�uÖ	Ñ+EÑFÈó&€Gô �‹L˜AÓ '¨!¡*×"2Ñ"2Ó"4¸Ó"CÜ˜Y¨¯	©	°'Ó(:Ó;Ð;ðMØÐ-Ñ.ˆðHÜ×"Ò" 7§>¡>Ó#3¸dÑCˆô ˆ7ƒ|�rÓÜ Ð!4°gÓ>Ð>ðQØÐ5Ñ6ˆð �dÓÜ Ð!8¸+ÓFÐFà€NùòQ 	Mùò 	Gøô ó :ÜÐ/Ó0°cÐ9ûÜó MÜÐ/Ð1BÓCÈÐLûðMûô
 �>‰>ó HÜ Ð!4°gÓ>ÀCÐGûðHûô ó >ÜÐ3Ó4¸#Ð=ûÜó QÜÐ3Ð5FÓGÈSÐPûðQúsk   ™D=Â EÃE Ã%#E? Ä$F( Å
E<ÅEÅE<Å*E7Å7E<Å?F%ÆF Æ F%Æ(
GÆ2F>Æ>GÇGÇGc                ó4   • SU S'   SU S'   [        U5      U S'   g)z½
Build a handshake response to send to the client.

Update response headers passed in argument.

Args:
    headers: Handshake response headers.
    key: Returned by :func:`check_request`.

r   r   r   úSec-WebSocket-AcceptN)Úacceptr   s     r   r   r   e   s'   € ð %€GˆIÑØ%€GˆLÑÜ&,¨S£k€GÐ"Ò#r   c                ó„  • [        U R                  S5       Vs/ s H  n[        U5      PM     sn/ 5      n[        S U 5       5      (       d  [	        SSR                  U5      5      e[        U R                  S5       Vs/ s H  n[        U5      PM     sn/ 5      n[        U5      S:X  a  US   R                  5       S:X  d  [	        SSR                  U5      5      e U S	   nU[        U5      :w  a  [        S	U5      eg
s  snf s  snf ! [         a  n[        S	5      UeS
nAf[         a  n[        S	S5      UeS
nAff = f)aw  
Check a handshake response received from the server.

This function doesn't verify that the response is an HTTP/1.1 or higher
response with a 101 status code. These controls are the responsibility of
the caller.

Args:
    headers: Handshake response headers.
    key: Returned by :func:`build_request`.

Raises:
    InvalidHandshake: If the handshake response is invalid.

r   c              3  óF   #   • U  H  oR                  5       S :H  v •  M     g7fr"   r$   r&   s     r   r)   Ú!check_response.<locals>.<genexpr>‰   r+   r,   Ú r   r.   r   r   r-   rC   Nr/   )r2   r3   r
   r4   r	   r5   r   r6   r%   r7   r   r   rD   r   )r   r   r(   r=   r#   Ú
s_w_acceptr?   s          r   r   r   u   s<  € ô  *-Ø.5¯o©o¸lÔ.KÓLÒ.K UÔ	˜%Ö	 Ñ.KÑLÈbó*€Jô ÑB±zÓB×BÑBÜ˜\¨3¯8©8°JÓ+?Ó@Ð@ä%(Ø+2¯?©?¸9Ô+EÓFÒ+E %Œ�uÖ	Ñ+EÑFÈó&€Gô �‹L˜AÓ '¨!¡*×"2Ñ"2Ó"4¸Ó"CÜ˜Y¨¯	©	°'Ó(:Ó;Ð;ðPØÐ3Ñ4ˆ
ð ”V˜C“[Ó Ü Ð!7¸ÓDÐDð !ùò/ 	Mùò 	Gøô ó =ÜÐ2Ó3¸Ð<ûÜó PÜÐ2Ð4EÓFÈCÐOûðPús/   ™D Â DÃD
 Ä

D?ÄD Ä D?Ä-D:Ä:D?)r   r   ÚreturnÚstr)r   r   r   rK   rJ   ÚNone)Ú
__future__r   r8   r;   Údatastructuresr   r   Ú
exceptionsr   r   r	   r   r
   r   Útypingr   r   Úutilsr   rD   r   Ú__all__r   r   r   r   © r   r   Ú<module>rT      s>   ðÝ "ã Û ç 9ß JÑ Jß 5ß 6ß 6ò Q€ôô*=ô@2õ )Er   