�
<��g� � �B � d dl mZ d dlZd dlZd dlZddlmZ ddlmZ ddgZ e
ej � dd � � � � Z
e
ej � d
d� � � � Zdd�Z ej d� � Z ej d� � Zdd�Zdd�Zdd�Zd d�ZdS )!� )�annotationsN� )�Headers)�
SecurityError�read_request�
read_response�WEBSOCKETS_MAX_NUM_HEADERS�128�WEBSOCKETS_MAX_LINE_LENGTH�8192�value�bytes�return�strc �. � | � d�� � S )zG
Decode a bytestring for interpolating into an error message.
�backslashreplace)�errors)�decode)r
s �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/websockets/legacy/http.py�dr s � �
�<�<�1�<�2�2�2� s [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s [\x09\x20-\x7e\x80-\xff]*�stream�asyncio.StreamReader�tuple[str, Headers]c � �� K � t | � � � d{V ��}n"# t $ r}t d� � |�d}~ww xY w |� dd� � \ }}}n.# t $ r! t dt |� � � �� � d�w xY w|dk rt dt |� � � �� � �|dk rt d t |� � � �� � �|� d
d� � }t
| � � � d{V ��}||fS )a�
Read an HTTP/1.1 GET request and return ``(path, headers)``.
``path`` isn't URL-decoded or validated in any way.
``path`` and ``headers`` are expected to contain only ASCII characters.
Other characters are represented with surrogate escapes.
:func:`read_request` 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 ``stream`` after this coroutine returns.
Args:
stream: Input to read the request from.
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� r zinvalid HTTP request line: s GETzunsupported HTTP method: � HTTP/1.1�unsupported HTTP version: �ascii�surrogateescape)� read_line�EOFError�split�
ValueErrorr r �read_headers)r �request_line�exc�method�raw_path�version�path�headerss r r r - sS � � � �8U�&�v�.�.�.�.�.�.�.�.����� U� U� U��J�K�K�QT�T�����U����T�$0�$6�$6�t�Q�$?�$?�!���'�'��� T� T� T��H�q����H�H�I�I�t�S�T���� �����@�Q�v�Y�Y�@�@�A�A�A��+����B�a��j�j�B�B�C�C�C��?�?�7�$5�6�6�D� ��(�(�(�(�(�(�(�(�G���=�s � �
9�4�9�A �+B�tuple[int, str, Headers]c � �� K � t | � � � d{V ��}n"# t $ r}t d� � |�d}~ww xY w |� dd� � \ }}}n.# t $ r! t dt |� � � �� � d�w xY w|dk rt dt |� � � �� � � t |� � }n.# t $ r! t dt |� � � �� � d�w xY wd |cxk rd
k s!n t dt |� � � �� � �t � |� � st dt |� � � �� � �|� � � }t | � � � d{V ��}|||fS )
a�
Read an HTTP/1.1 response and return ``(status_code, reason, headers)``.
``reason`` and ``headers`` are expected to contain only ASCII characters.
Other characters are represented with surrogate escapes.
:func:`read_request` doesn't attempt to read the response body because
WebSocket handshake responses don't have one. If the response contains a
body, it may be read from ``stream`` after this coroutine returns.
Args:
stream: Input to read the response from.
Raises:
EOFError: If the connection is closed without a full HTTP response.
SecurityError: If the response exceeds a security limit.
ValueError: If the response isn't well formatted.
Nz0connection closed while reading HTTP status liner r zinvalid HTTP status line: r r zinvalid HTTP status code: �d i� zunsupported HTTP status code: zinvalid HTTP reason phrase: )
r! r"