Ë
    Õ±1h¥  ã                  óœ   — d dl mZ d dlZd dlZddlmZmZ ddlmZm	Z	m
Z
 ddlmZmZ ddlmZmZ ddlmZmZ g d	¢Zdd
„Zdd„Zdd„Zdd„Zy)é    )ÚannotationsNé   )ÚHeadersÚMultipleValuesError)ÚInvalidHeaderÚInvalidHeaderValueÚInvalidUpgrade)Úparse_connectionÚparse_upgrade)ÚConnectionOptionÚUpgradeProtocol)Ú
accept_keyÚgenerate_key)Úbuild_requestÚcheck_requestÚbuild_responseÚcheck_responsec                óB   — t        «       }d| d<   d| d<   || d<   d| d<   |S )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     úY/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/websockets/legacy/handshake.pyr   r      s:   € ô ‹.€CØ$€GˆIÑØ%€GˆLÑØ#&€GÐÑ Ø'+€GÐ#Ñ$Ø€Jó    c                óœ  — t        | j                  d«      D �cg c]  }t        |«      ‘Œ c}g «      }t        d„ |D «       «      st	        ddj                  |«      «      ‚t        | j                  d«      D �cg c]  }t        |«      ‘Œ c}g «      }t        |«      dk(  r|d   j                  «       dk(  st	        ddj                  |«      «      ‚	 | d   }	 t        j                  |j                  «       d¬«      }t        |«      dk7  rt#        d|«      ‚	 | d   }|dk7  rt#        d|«      ‚|S c c}w c c}w # t        $ r}t        d«      |‚d	}~wt        $ r}t        dd
«      |‚d	}~ww xY w# t        j                   $ r}t#        d|«      |‚d	}~ww xY w# t        $ r}t        d«      |‚d	}~wt        $ r}t        dd
«      |‚d	}~ww xY w)ab  
    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  óB   K  — | ]  }|j                  «       d k(  –— Œ y­w©ÚupgradeN©Úlower©Ú.0Úvalues     r   ú	<genexpr>z check_request.<locals>.<genexpr>=   ó   è ø€ ÒB¨eˆu�{‰{‹} 	Õ)ÑBùó   ‚ú, 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 UÔ	˜%Õ	 ÒLÈbó*€Jô ÑB°zÔBÔBÜ˜\¨4¯9©9°ZÓ+@ÓAÐAä%(Ø+2¯?©?¸9Ó+EÖF %Œ�uÕ	Ò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   ™D0Á8D5ÃD: Ã%E0 ÄF Ä:	E-ÅEÅE-ÅE(Å(E-Å0FÆFÆFÆ	GÆ!F-Æ-GÆ9GÇGc                ó4   — d| d<   d| d<   t        |«      | d<   y)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                ód  — t        | j                  d«      D �cg c]  }t        |«      ‘Œ c}g «      }t        d„ |D «       «      st	        ddj                  |«      «      ‚t        | j                  d«      D �cg c]  }t        |«      ‘Œ c}g «      }t        |«      dk(  r|d   j                  «       dk(  st	        ddj                  |«      «      ‚	 | d	   }|t        |«      k7  rt        d	|«      ‚y
c c}w c c}w # t        $ r}t        d	«      |‚d
}~wt        $ r}t        d	d«      |‚d
}~ww xY w)aŸ  
    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  óB   K  — | ]  }|j                  «       d k(  –— Œ y­wr"   r$   r&   s     r   r)   z!check_response.<locals>.<genexpr>‰   r*   r+   ú r   r-   r   r   r,   rB   Nr.   )r1   r2   r
   r3   r	   r4   r   r5   r%   r6   r   r   rC   r   )r   r   r(   r<   r#   Ú
s_w_acceptr>   s          r   r   r   u   s-  € ô  *-Ø.5¯o©o¸lÓ.KÖL UÔ	˜%Õ	 ÒLÈbó*€Jô ÑB°zÔBÔBÜ˜\¨3¯8©8°JÓ+?Ó@Ð@ä%(Ø+2¯?©?¸9Ó+EÖF %Œ�uÕ	Ò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/   ™C2Á8C7ÃC< Ã<	D/ÄDÄD/ÄD*Ä*D/)r   r   ÚreturnÚstr)r   r   r   rI   rH   ÚNone)Ú
__future__r   r7   r:   Údatastructuresr   r   Ú
exceptionsr   r   r	   r   r
   r   Útypingr   r   Úutilsr   rC   r   Ú__all__r   r   r   r   © r   r   ú<module>rR      s>   ðÝ "ã Û ç 9ß JÑ Jß 5ß 6ß 6ò Q€óó*=ó@2ô )Er   