403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/websockets/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/websockets/__pycache__/headers.cpython-311.pyc
�

�=Xc�>��x�ddlmZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZmZmZgd�Zed��ZdPd�ZdQd�Zejd��ZdRd�Zejd��ZdSd�Zejd��Zejd��Z dSd�Z!ejd��Z"ejd��Z#dTd!�Z$dUd%�Z%dVd'�Z&dWd)�Z'ejd*��Z(dXd,�Z)dYd.�Z*dZd0�Z+d[d2�Z,d\d4�Z-e-Z.d]d9�Z/d^d<�Z0e0Z1d_d>�Z2d`d@�Z3e3Z4dadC�Z5e5Z6dbdE�Z7dcdG�Z8ejdH��Z9dSdI�Z:dddJ�Z;dedL�Z<dfdO�Z=dS)g�)�annotationsN)�Callable�List�Optional�Sequence�Tuple�TypeVar�cast�)�
exceptions)�ConnectionOption�ExtensionHeader�
ExtensionName�ExtensionParameter�Subprotocol�UpgradeProtocol)�
build_host�parse_connection�
parse_upgrade�parse_extension�build_extension�parse_subprotocol�build_subprotocol�validate_subprotocols�build_www_authenticate_basic�parse_authorization_basic�build_authorization_basic�T�host�str�port�int�secure�bool�returnc��	tj|��}|jdkrd|�d�}n#t$rYnwxYw||rdndkr|�d|��}|S)z#
    Build a ``Host`` header.

    ��[�]i��P�:)�	ipaddress�
ip_address�version�
ValueError)rr!r#�addresss    �4/usr/lib/python3/dist-packages/websockets/headers.pyrr&s�����&�t�,�,���?�a����t�;�;�;�D���
�
�
�
���
�����v�%���2�&�&���������Ks�(�
5�5�header�pos�
Optional[str]c�<�|t|��krdn||S)z�
    Return the next character from ``header`` at the given position.

    Return :obj:`None` at the end of ``header``.

    We never need to peek more than one character ahead.

    N)�len)r2r3s  r1�
peek_aheadr7Bs"���#�f�+�+�%�%�4�4�6�#�;�6�z[\t ]*c�h�t�||��}|�J�|���S)z�
    Parse optional whitespace from ``header`` at the given position.

    Return the new position.

    The whitespace itself isn't returned because it isn't significant.

    )�_OWS_re�match�end)r2r3r;s   r1�	parse_OWSr=Qs1��
�M�M�&�#�&�&�E������9�9�;�;�r8z[-!#$%&\'*+.^_`|~0-9a-zA-Z]+�header_name�Tuple[str, int]c��t�||��}|�tj|d||���|���|���fS)z�
    Parse a token from ``header`` at the given position.

    Return the token value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    Nzexpected token)�	_token_rer;r�InvalidHeaderFormat�groupr<�r2r3r>r;s    r1�parse_tokenrEcsP��
�O�O�F�C�(�(�E��}��,�[�:J�F�TW�X�X�X��;�;�=�=�%�)�)�+�+�%�%r8zC"(?:[\x09\x20-\x21\x23-\x5b\x5d-\x7e]|\\[\x09\x20-\x7e\x80-\xff])*"z\\([\x09\x20-\x7e\x80-\xff])c��t�||��}|�tj|d||���t�d|���dd���|���fS)z�
    Parse a quoted string from ``header`` at the given position.

    Return the unquoted value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    Nzexpected quoted stringz\1r���)�_quoted_string_rer;rrB�_unquote_re�subrCr<rDs    r1�parse_quoted_stringrK{sq��
�#�#�F�C�0�0�E��}��,��1�6�3�
�
�	
��?�?�5�%�+�+�-�-��"��"5�6�6��	�	���C�Cr8z[\x09\x20-\x7e\x80-\xff]*z([\x22\x5c])�valuec��t�|��}|�td���dt�d|��zdzS)zh
    Format ``value`` as a quoted string.

    This is the reverse of :func:`parse_quoted_string`.

    Nz-invalid characters for quoted-string encoding�"z\\\1)�_quotable_re�	fullmatchr/�	_quote_rerJ)rLr;s  r1�build_quoted_stringrR�sI��
�"�"�5�)�)�E��}��H�I�I�I�����w��.�.�.��4�4r8�
parse_item�(Callable[[str, int, str], Tuple[T, int]]�List[T]c�\�t||��dkr't||dz��}t||��dk�'g}	||||��\}}|�|��t||��}|t|��krn�t||��dkrt||dz��}nt	j|d||���t||��dkr't||dz��}t||��dk�'|t|��krn��|t|��ksJ�|S)a�
    Parse a comma-separated list from ``header`` at the given position.

    This is appropriate for parsing values with the following grammar:

        1#item

    ``parse_item`` parses one item.

    ``header`` is assumed not to start or end with whitespace.

    (This function is designed for parsing an entire header value and
    :func:`~websockets.http.read_headers` strips whitespace from values.)

    Return a list of items.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    �,rTzexpected comma)r7r=�appendr6rrB)rSr2r3r>�items�items      r1�
parse_listr[�sb��>�V�S�
!�
!�S�
(�
(����a��(�(���V�S�
!�
!�S�
(�
(�
�E���J�v�s�K�8�8�	��c�
���T�������$�$���#�f�+�+�����f�c�"�"�c�)�)��F�C�!�G�,�,�C�C��0��-�v�s���
�
���%�%��,�,��F�C�!�G�,�,�C����%�%��,�,��#�f�+�+����1�8�#�f�+�+������Lr8�Tuple[ConnectionOption, int]c�X�t|||��\}}tt|��|fS)z�
    Parse a Connection option from ``header`` at the given position.

    Return the protocol value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    )rEr
r
�r2r3r>rZs    r1�parse_connection_optionr_�s/���F�C��5�5�I�D�#�� �$�'�'��,�,r8�List[ConnectionOption]c�0�tt|dd��S)z�
    Parse a ``Connection`` header.

    Return a list of HTTP connection options.

    Args
        header: value of the ``Connection`` header.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    r�
Connection)r[r_�r2s r1rr�s���-�v�q�,�G�G�Gr8z>[-!#$%&\'*+.^_`|~0-9a-zA-Z]+(?:/[-!#$%&\'*+.^_`|~0-9a-zA-Z]+)?�Tuple[UpgradeProtocol, int]c���t�||��}|�tj|d||���t	t
|�����|���fS)z�
    Parse an Upgrade protocol from ``header`` at the given position.

    Return the protocol value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    Nzexpected protocol)�_protocol_rer;rrBr
rrCr<rDs    r1�parse_upgrade_protocolrg	sd��
���v�s�+�+�E��}��,��,�f�c�
�
�	
��������/�/������<�<r8�List[UpgradeProtocol]c�0�tt|dd��S)z�
    Parse an ``Upgrade`` header.

    Return a list of HTTP protocols.

    Args:
        header: value of the ``Upgrade`` header.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    r�Upgrade)r[rgrcs r1rrs���,�f�a��C�C�Cr8�Tuple[ExtensionParameter, int]c��t|||��\}}t||��}d}t||��dkr�t||dz��}t||��dkrH|}t|||��\}}t�|���t
j|d||���nt|||��\}}t||��}||f|fS)z�
    Parse a single extension parameter from ``header`` at the given position.

    Return a ``(name, value)`` pair and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    N�=rrNzinvalid quoted header content)rEr=r7rKrArPrrB)r2r3r>�namerL�
pos_befores      r1�parse_extension_item_paramrp-s����F�C��5�5�I�D�#�
�F�C�
 �
 �C��E��&�#���#�%�%����a��(�(���f�c�"�"�c�)�)��J�,�V�S�+�F�F�J�E�3��"�"�5�)�)�1� �4��!@�&�*����2�
%�V�S�+�>�>�J�E�3����$�$���%�=�#��r8�Tuple[ExtensionHeader, int]c�H�t|||��\}}t||��}g}t||��dkrPt||dz��}t|||��\}}|�|��t||��dk�Ptt|��|f|fS)a
    Parse an extension definition from ``header`` at the given position.

    Return an ``(extension name, parameters)`` pair, where ``parameters`` is a
    list of ``(name, value)`` pairs, and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    �;r)rEr=r7rprXr
r)r2r3r>rn�
parameters�	parameters      r1�parse_extension_itemrvQs����F�C��5�5�I�D�#�
�F�C�
 �
 �C��J�
�V�S�
!�
!�S�
(�
(����a��(�(��3�F�C��M�M��	�3����)�$�$�$��V�S�
!�
!�S�
(�
(�
���%�%�z�2�C�7�7r8�List[ExtensionHeader]c�0�tt|dd��S)a�
    Parse a ``Sec-WebSocket-Extensions`` header.

    Return a list of WebSocket extensions and their parameters in this format::

        [
            (
                'extension name',
                [
                    ('parameter name', 'parameter value'),
                    ....
                ]
            ),
            ...
        ]

    Parameter values are :obj:`None` when no value is provided.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    rzSec-WebSocket-Extensions)r[rvrcs r1rrjs��.�*�F�A�7Q�R�R�Rr8rnrrt�List[ExtensionParameter]c�n�d�tt|��gd�|D��z��S)zc
    Build an extension definition.

    This is the reverse of :func:`parse_extension_item`.

    z; c�*�g|]\}}|�|n|�d|����S)Nrm�)�.0rnrLs   r1�
<listcomp>z(build_extension_item.<locals>.<listcomp>�sD��
�
�
���e��M�D�D�$�'8�'8��'8�'8�
�
�
r8)�joinr
r )rnrts  r1�build_extension_itemr��sK���9�9�	
�c�4����
�
� *�
�
�
�	
���r8�
extensions�Sequence[ExtensionHeader]c�@�d�d�|D����S)zl
    Build a ``Sec-WebSocket-Extensions`` header.

    This is the reverse of :func:`parse_extension`.

    �, c3�<K�|]\}}t||��V��dS)N)r�)r}rnrts   r1�	<genexpr>z"build_extension.<locals>.<genexpr>�sB������3C�4���T�:�.�.������r8�r)r�s r1rr�s6���9�9���GQ������r8�Tuple[Subprotocol, int]c�X�t|||��\}}tt|��|fS)z�
    Parse a subprotocol from ``header`` at the given position.

    Return the subprotocol value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    )rEr
rr^s    r1�parse_subprotocol_itemr��s.���F�C��5�5�I�D�#���T�"�"�C�'�'r8�List[Subprotocol]c�0�tt|dd��S)z�
    Parse a ``Sec-WebSocket-Protocol`` header.

    Return a list of WebSocket subprotocols.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    rzSec-WebSocket-Protocol)r[r�rcs r1rr�s���,�f�a�9Q�R�R�Rr8�subprotocols�Sequence[Subprotocol]c�,�d�|��S)zl
    Build a ``Sec-WebSocket-Protocol`` header.

    This is the reverse of :func:`parse_subprotocol`.

    r�r�)r�s r1rr�s���9�9�\�"�"�"r8�Nonec��t|t��std���t|t��rtd���|D].}t�|��st
d|������/dS)zT
    Validate that ``subprotocols`` is suitable for :func:`build_subprotocol`.

    zsubprotocols must be a listz&subprotocols must be a list, not a strzinvalid subprotocol: N)�
isinstancer�	TypeErrorr rArPr/)r��subprotocols  r1rr�s���
�l�H�-�-�7��5�6�6�6��,��$�$�B��@�A�A�A�#�D�D���"�"�;�/�/�	D��B�[�B�B�C�C�C�	D�D�Dr8�realmc�N�t|��}td��}d|�d|��S)z�
    Build a ``WWW-Authenticate`` header for HTTP Basic Auth.

    Args:
        realm: identifier of the protection space.

    zUTF-8zBasic realm=z
, charset=)rR)r��charsets  r1rr�s4��
 ��&�&�E�!�'�*�*�G�4�%�4�4�7�4�4�4r8z[A-Za-z0-9-._~+/]+=*c��t�||��}|�tj|d||���|���|���fS)z�
    Parse a token68 from ``header`` at the given position.

    Return the token value and the new position.

    Raises:
        InvalidHeaderFormat: on invalid inputs.

    Nzexpected token68)�_token68_rer;rrBrCr<rDs    r1�
parse_token68r��sZ��
���f�c�*�*�E��}��,��+�V�S�
�
�	
��;�;�=�=�%�)�)�+�+�%�%r8c�Z�|t|��krtj|d||���dS)z8
    Check that parsing reached the end of header.

    z
trailing dataN)r6rrB)r2r3r>s   r1�	parse_endr�s5��
�S��[�[����,�[�/�6�SV�W�W�W��r8�Tuple[str, str]c��t|dd��\}}|���dkrtjdd|�����t	||��dkrtjdd||���|dz
}t
||d��\}}t||d��	tj	|�
�������}n)#tj
$rtjdd��d	�wxYw	|�d
d��\}}n$#t$rtjdd��d	�wxYw||fS)a!
    Parse an ``Authorization`` header for HTTP Basic Auth.

    Return a ``(username, password)`` tuple.

    Args:
        header: value of the ``Authorization`` header.

    Raises:
        InvalidHeaderFormat: on invalid inputs.
        InvalidHeaderValue: on unsupported inputs.

    r�
Authorization�basiczunsupported scheme: � zexpected space after schemerz#expected base64-encoded credentialsNr+z&expected username:password credentials)rE�lowerr�InvalidHeaderValuer7rBr�r��base64�	b64decode�encode�decode�binascii�Error�splitr/)r2�schemer3�basic_credentials�	user_pass�username�passwords       r1rrs��� �f�a��9�9�K�F�C�
�|�|�~�~�� � ��+��+�6�+�+�
�
�	
��&�#���#�%�%��,��:�F�C�
�
�	
��1�H�C�*�6�3��H�H���s�
�f�c�?�+�+�+���$�%6�%=�%=�%?�%?�@�@�G�G�I�I�	�	���>�����+��1�
�
��	�����
�&�_�_�S�!�4�4���(�(�������+��4�
�
��	������X��s�8C�&C:�>D�!D9r�r�c��d|vsJ�|�d|��}tj|��������}d|zS)z�
    Build an ``Authorization`` header for HTTP Basic Auth.

    This is the reverse of :func:`parse_authorization_basic`.

    r+zBasic )r��	b64encoder�r�)r�r�r�r�s    r1rr@s]���h������(�(�h�(�(�I��(��)9�)9�);�);�<�<�C�C�E�E���'�'�'r8)rr r!r"r#r$r%r )r2r r3r"r%r4)r2r r3r"r%r")r2r r3r"r>r r%r?)rLr r%r )
rSrTr2r r3r"r>r r%rU)r2r r3r"r>r r%r\)r2r r%r`)r2r r3r"r>r r%rd)r2r r%rh)r2r r3r"r>r r%rk)r2r r3r"r>r r%rq)r2r r%rw)rnrrtryr%r )r�r�r%r )r2r r3r"r>r r%r�)r2r r%r�)r�r�r%r )r�r�r%r�)r�r r%r )r2r r3r"r>r r%r�)r2r r%r�)r�r r�r r%r )>�
__future__rr�r�r,�re�typingrrrrrr	r
�rr
rrrrr�__all__rrr7�compiler:r=rArErHrIrKrOrQrRr[r_rrfrgrrprvr�parse_extension_listr�r�build_extension_listr�r�parse_subprotocol_listr�build_subprotocol_listrrr�r�r�rrr|r8r1�<module>r�s���"�"�"�"�"�"�
�
�
�
���������	�	�	�	�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K����������������������������G�C�L�L������8	7�	7�	7�	7��"�*�Y�
�
������
�B�J�6�7�7�	�
&�
&�
&�
&� �B�J�J����
�b�j�8�9�9��D�D�D�D�$�r�z�6�7�7��
�B�J��'�'�	�
5�
5�
5�
5�A�A�A�A�H
-�
-�
-�
-� 
H�
H�
H�
H� �r�z�E����
=�=�=�=�(
D�
D�
D�
D� !�!�!�!�H8�8�8�8�2S�S�S�S�4'������&	�	�	�	�'��
(�
(�
(�
(� 
S�
S�
S�
S�+��#�#�#�#�+��D�D�D�D�5�5�5�5��b�j�0�1�1��&�&�&�&�$X�X�X�X�-�-�-�-�`(�(�(�(�(�(r8

Youez - 2016 - github.com/yon3zu
LinuXploit