� <��gM:����ddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZgd �Zd jej�Zej�d d e�d e����Zej�dd e�d e����Zeej�dd����Zeej�dd����Zeej�dd����Zd-d�Zejd��Zejd��Z ej!Gd�d����Z"ej!Gd�d����Z#d.d#�Z$d/d%�Z%d0d,�Z&dS)1�)� annotationsN)� Generator)�Callable�)�Headers)� SecurityError)�version)�SERVER� USER_AGENT�Request�Responsez{}.{}�WEBSOCKETS_USER_AGENTzPython/z websockets/�WEBSOCKETS_SERVER�WEBSOCKETS_MAX_NUM_HEADERS�128�WEBSOCKETS_MAX_LINE_LENGTH�8192�WEBSOCKETS_MAX_BODY_SIZE� 1_048_576�value�bytes�return�strc�.�|�d���S)zG Decode a bytestring for interpolating into an error message. �backslashreplace��errors)�decode)rs �a/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/websockets/http11.py�dr 2s�� �<�<�1�<� 2� 2�2�s[-!#$%&\'*+.^_`|~0-9a-zA-Z]+s[\x09\x20-\x7e\x80-\xff]*c�n�eZdZUdZded<ded<dZded<edd ���Zedd���Z dd�Z dS)r z� WebSocket handshake request. Attributes: path: Request path, including optional query. headers: Request headers. r�pathr�headersN�Exception | None� _exceptionrc�D�tjdt��|jS)NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc instead��warnings�warn�DeprecationWarningr&��selfs r� exceptionzRequest.exception^s&��� � W� � � � ���r!� read_line�-Callable[[int], Generator[None, None, bytes]]�Generator[None, None, Request]c#�ZK� t|��Ed{V��}n"#t$r}td��|�d}~wwxYw |�dd��\}}}n.#t$r!tdt |������d�wxYw|dkrtdt |�������|dkrtd t |�������|�d d ��}t |��Ed{V��}d |vrtd ���d|vrtd���|||��S)a� Parse a WebSocket handshake request. This is a generator-based coroutine. The request path isn't URL-decoded or validated in any way. The request path and headers are expected to contain only ASCII characters. Other characters are represented with surrogate escapes. :meth:`parse` doesn't attempt to read the request body because WebSocket handshake requests don't have one. If the request contains a body, it may be read from the data stream after :meth:`parse` returns. Args: read_line: Generator-based coroutine that reads a LF-terminated line or raises an exception if there isn't enough data Raises: EOFError: If the connection is closed without a full HTTP request. SecurityError: If the request exceeds a security limit. ValueError: If the request isn't well formatted. Nz1connection closed while reading HTTP request line� �zinvalid HTTP request line: �HTTP/1.1�)unsupported protocol; expected HTTP/1.1: sGETz+unsupported HTTP method; expected GET; got �ascii�surrogateescape�Transfer-Encodingz!transfer codings aren't supported�Content-Lengthzunsupported request body)� parse_line�EOFError�split� ValueErrorr r� parse_headers�NotImplementedError) �clsr/� request_line�exc�method�raw_path�protocolr#r$s r�parsez Request.parsefs�����F Y�&0��&;�&;�;�;�;�;�;�;�L�L��� Y� Y� Y��N�O�O�UX� X����� Y���� X�)5�);�);�D�!�)D�)D� &�F�H�h�h��� X� X� X��L�1�\�?�?�L�L�M�M�SW� W� X���� �{� "� "��M�A�l�O�O�M�M��� � �V� � ��V�1�V�9�9�V�V�W�W� W����w�(9�:�:��*�9�5�5�5�5�5�5�5�5�� �'� )� )�%�&I�J�J� J� �w� &� &��7�8�8� 8��s�4��!�!�!s�� 9�4�9�A�+Brc�x�d|j�d����}||j���z }|S)z; Serialize a WebSocket handshake request. zGET z HTTP/1.1 )r#�encoder$� serialize)r-�requests rrJzRequest.serialize�s?��2���1�1�1�8�8�:�:���4�<�)�)�+�+�+���r!�rr%)r/r0rr1�rr) �__name__� __module__� __qualname__�__doc__�__annotations__r&�propertyr.� classmethodrGrJ�r!rr r Ns�����������I�I�I�����$(�J�'�'�'�'� �����X���="�="�="��[�="�~ � � � � � r!r c��eZdZUdZded<ded<ded<dZd ed <d Zd ed <edd���Ze ddd���Z dd�Z d S)r z� WebSocket handshake response. Attributes: status_code: Response code. reason_phrase: Response reason. headers: Response headers. body: Response body. �int� status_coder� reason_phraserr$r!r�bodyNr%r&rc�D�tjdt��|jS)NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr(r,s rr.zResponse.exception�s(��� � 7� � � � � ��r!Tr/r0� read_exact� read_to_eof� include_body�bool�Generator[None, None, Response]c#�PK� t|��Ed{V��}n"#t$r}td��|�d}~wwxYw |�dd��\}}} n.#t$r!tdt |������d�wxYw|dkrtdt |������� t |��} n.#t$r!tdt |������d�wxYwd | cxkrd ks!ntd t |�������t �| ��std t | �������| �d d��} t|��Ed{V��} |rt| | |||��Ed{V��} nd} || | | | ��S)a� Parse a WebSocket handshake response. This is a generator-based coroutine. The reason phrase and headers are expected to contain only ASCII characters. Other characters are represented with surrogate escapes. Args: read_line: Generator-based coroutine that reads a LF-terminated line or raises an exception if there isn't enough data. read_exact: Generator-based coroutine that reads the requested bytes or raises an exception if there isn't enough data. read_to_eof: Generator-based coroutine that reads until the end of the stream. Raises: EOFError: If the connection is closed without a full HTTP response. SecurityError: If the response exceeds a security limit. LookupError: If the response isn't well formatted. ValueError: If the response isn't well formatted. Nz0connection closed while reading HTTP status liner3r4zinvalid HTTP status line: r5r6z+invalid status code; expected integer; got �diXu-invalid status code; expected 100–599; got zinvalid HTTP reason phrase: r7r8r!) r;r<r=r>r rW� _value_re� fullmatchrr?� read_body)rAr/r\r]r^� status_linerCrF�raw_status_code� raw_reasonrX�reasonr$rZs rrGzResponse.parse�s[����B X�%/� �%:�%:�:�:�:�:�:�:�K�K��� X� X� X��M�N�N�TW� W����� X���� V�4?�4E�4E�d�A�4N�4N� 1�H�o�z�z��� V� V� V��J�!�K�.�.�J�J�K�K�QU� U� V���� �{� "� "��L�A�k�N�N�L�L��� � ��o�.�.�K�K��� � � ��R�a��>P�>P�R�R���� � �����k�'�'�'�'�C�'�'�'�'��T��/�@R�@R�T�T��� ��"�"�:�.�.� M��K�A�j�M�M�K�K�L�L� L��"�"�7�,=�>�>��*�9�5�5�5�5�5�5�5�5�� � �'��W�i��[���������D�D��D��s�;����6�6�6s'�� 9�4�9�A�+B�,B<�<+C'c��d|j�d|j�d����}||j���z }||jz }|S)z< Serialize a WebSocket handshake response. z HTTP/1.1 � z )rXrYrIr$rJrZ)r-�responses rrJzResponse.serializesX��K�t�/�J�J�$�2D�J�J�J�Q�Q�S�S���D�L�*�*�,�,�,���D�I����r!rL)T) r/r0r\r0r]r0r^r_rr`rM) rNrOrPrQrRrZr&rSr.rTrGrJrUr!rr r �s�������� � ��������������D�����#'�J�'�'�'�'� �����X��� "� D7�D7�D7�D7��[�D7�L � � � � � r!r r/r0�Generator[None, None, bytes]c#��K� |t��Ed{V��}n#t$rtd���wxYw|�d��st d���|dd�S)ao Parse a single line. CRLF is stripped from the return value. Args: read_line: Generator-based coroutine that reads a LF-terminated line or raises an exception if there isn't enough data. Raises: EOFError: If the connection is closed without a CRLF. SecurityError: If the response exceeds a security limit. Nz line too long� zline without CRLF�����)�MAX_LINE_LENGTH� RuntimeErrorr�endswithr<)r/�lines rr;r;#s�����"-�#�)�O�4�4�4�4�4�4�4�4���� �-�-�-��O�,�,�,�-���� �=�=�� !� !�,��*�+�+�+� ����9�s��5�Generator[None, None, Headers]c#�K�t��}ttdz��D�]E} t|��Ed{V��}n"#t$r}t d��|�d}~wwxYw|dkr�n |�dd��\}}n.#t $r!t dt|������d�wxYwt� |��st dt|�������|� d��}t� |��st d t|�������|� d ��}|� d d ��}|||<��Gtd ���|S) a� Parse HTTP headers. Non-ASCII characters are represented with surrogate escapes. Args: read_line: Generator-based coroutine that reads a LF-terminated line or raises an exception if there isn't enough data. Raises: EOFError: If the connection is closed without complete headers. SecurityError: If the request exceeds a security limit. ValueError: If the request isn't well formatted. rNz,connection closed while reading HTTP headersr!�:zinvalid HTTP header line: zinvalid HTTP header name: s zinvalid HTTP header value: r7r8ztoo many HTTP headers)r�range�MAX_NUM_HEADERSr;r<r=r>r � _token_rerd�striprcrr) r/r$�_rtrC�raw_name� raw_value�namers rr?r?>s�����,�i�i�G� �?�Q�&� '� '�5�5�� T�(��3�3�3�3�3�3�3�3�D�D��� T� T� T��I�J�J�PS� S����� T���� �3�;�;� �E� O�"&�*�*�T�1�"5�"5� �H�i�i��� O� O� O��C�!�D�'�'�C�C�D�D�$� N� O�����"�"�8�,�,� I��G�!�H�+�+�G�G�H�H� H��O�O�F�+�+� ��"�"�9�-�-� K��I�1�Y�<�<�I�I�J�J� J����w�'�'��� � ��*;�<�<����� � ��3�4�4�4� �Ns#�A� A!� A�A!�.B�+B3rXrWr$rr\r]c#�<K�d|cxkrdksn|dks|dkrdS|�d��x}��.|dkrtd|�d ����d} t|��Ed{V��}|�d d ��d }t |��dkr)|�d���} t d| �d����t|d��} | d krnwt |��| ztkr#t d| �dt |���d����||| ��Ed{V��z }|d��Ed{V��dkrtd�����t|��Ed{V��|S|�d��x} �dt | ��dkrt d| �d����t| ��} | tkrt d| �d����|| ��Ed{V��S |t��Ed{V��S#t$rt dt�d����wxYw)Nrb����i0r!r9�chunkedztransfer coding z isn't supportedT�;rr�rrzchunk too large: 0xz bytes�zchunk too large: z bytes after r4rozchunk without CRLFr:�zbody too large: zbody too large: over ) �getr@r;r=�lenrrrW� MAX_BODY_SIZEr>r?rr) rXr$r/r\r]�codingrZ�chunk_size_line�raw_chunk_size�str_chunk_size� chunk_size�raw_content_length�content_lengths rrereqs����� �k�����C�����;�#�#5�#5���9K�9K��s��K�K� 3�4�4� 4�&� A� �Y� � �%�&Q��&Q�&Q�&Q�R�R� R��� 7�)3�I�)>�)>�>�>�>�>�>�>�O�,�2�2�4��;�;�A�>�N��>�"�"�R�'�'�!/�!6�!6�>P�!6�!Q�!Q��#�$P�.�$P�$P�$P�Q�Q�Q��^�R�0�0�J��Q�����4�y�y�:�%� �5�5�#�R� �R�R��T���R�R�R���� �z�z�*�5�5�5�5�5�5�5�5� 5�D�%�:�a�=�=�(�(�(�(�(�(�W�4�4� �!5�6�6�6�! 7�$!��+�+�+�+�+�+�+�+�+�� � '� � �,<� =� =� =� � J� �!� "� "�R� '� '�� M�3E� M� M� M�N�N� N��/�0�0�� �M� )� )�� I�>� I� I� I�J�J� J�%�:�n�5�5�5�5�5�5�5�5�6� O�*�{�=�9�9�9�9�9�9�9�9� :��� O� O� O�� M� � M� M� M�N�N� N� O���s �"G8�8#H)rrrr)r/r0rrm)r/r0rru) rXrWr$rr/r0r\r0r]r0rrm)'� __future__r� dataclasses�os�re�sysr)�collections.abcr�typingr�datastructuresr� exceptionsrr �websockets_version�__all__�format� version_info�PYTHON_VERSION�environr�r r rWryrqr�r �compilerzrc� dataclassr r r;r?rerUr!r�<module>r�s���"�"�"�"�"�"����� � � � � � � � � � � � �����%�%�%�%�%�%�������#�#�#�#�#�#�%�%�%�%�%�%�2�2�2�2�2�2� � � �� ����!1�2���Z�^�^��>�n�>�>�*<�>�>��� � �����>�n�>�>�*<�>�>� � �� �#�b�j�n�n�%A�5�I�I�J�J���#�b�j�n�n�%A�6�J�J�K�K����B�J�N�N�#=�{�K�K�L�L� �3�3�3�3� �B�J�7� 8� 8� � �B�J�4� 5� 5� � ��`�`�`�`�`�`�`���`�F ��m�m�m�m�m�m�m���m�`����60�0�0�0�f:O�:O�:O�:O�:O�:Or!
Memory