K i@ddlmZddlZddlZddlZddlmZddlmZddgZ e ejjdd Z e ejjd d Zdd Zej d Zej dZddZddZddZddZy)) annotationsN)Headers) SecurityError read_request read_responseWEBSOCKETS_MAX_NUM_HEADERS128WEBSOCKETS_MAX_LINE_LENGTH8192c&|jdS)zG Decode a bytestring for interpolating into an error message. backslashreplace)errors)decode)values \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/websockets/legacy/http.pydrs <<1< 22s[-!#$%&\'*+.^_`|~0-9a-zA-Z]+s[\x09\x20-\x7e\x80-\xff]*cK t|d{} |jdd\}}}|dk7rtdt ||dk7rtd t ||j d d }t |d{}||fS7|#t$r}td|d}~wwxYw#t$rtdt |dwxYw7Lw) 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 rzinvalid HTTP request line: sGETzunsupported HTTP method: HTTP/1.1unsupported HTTP version: asciisurrogateescape) read_lineEOFErrorsplit ValueErrorrr read_headers)stream request_lineexcmethodraw_pathversionpathheaderss rrr-s8U&v.. T$0$6$6tQ$?!'4QvYK@AA+5aj\BCC ??7$5 6D ((G =#/ UJKQTTU T6q6GHItST)sUCBBBB.ACCCB B+ B&&B++C."CCcvK t|d{} |jdd\}}}|dk7rtdt | t |}d |cxkrd ksntd t |t j|std t ||j}t|d{}|||fS7#t$r}td|d}~wwxYw#t$rtdt |dwxYw#t$rtdt |dwxYw7rw) 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 linerrzinvalid HTTP status line: rrzinvalid HTTP status code: dizunsupported HTTP status code: zinvalid HTTP reason phrase: ) rrrrrint _value_re fullmatchrr) r status_liner"r%raw_status_code raw_reason status_codereasonr's rrr^sc2T%f-- R/:/@/@q/I,*+5aj\BCCV/*  + $ $9!O:L9MNOO   z *7* GHH    F ((G  ''/. TIJPSST R5a n5EFGTQR V5a6H5IJKQUUV)smD9CCCC-D9 DA.D9D7 D9C C* C%%C**D9-"DD9"D44D9cpKt}ttdzD]} t|d{}|dk(r|S |j dd\}}tj|st dt||jd}tj|st d t||jd }|jd d }|||<td 7#t$r}t d|d}~wwxYw#t $rt dt|dwxYww) zo Read HTTP headers from ``stream``. Non-ASCII characters are represented with surrogate escapes. Nz,connection closed while reading HTTP headersr:zinvalid HTTP header line: zinvalid HTTP header name: s zinvalid HTTP header value: rrztoo many HTTP headers)rrangeMAX_NUM_HEADERSrrrrr _token_rer,stripr+rr) r r'_liner"raw_name raw_valuenamers rrrsKiG ?Q& '5 T"6**D 3; & N# O"&**T1"5 Hi""8,9!H+GH HOOF+ ""9-:1Y<.IJ Jw'  *;< )5.344++ TIJPS S T O9!D'CD$ N OsO D6C4C2C4D6DBD62C44 D= D  DD6"D33D6cK|jd{}t|tkDr td|j ds t d|ddS7Bw)z[ Read a single line from ``stream``. CRLF is stripped from the return value. Nz line too longs zline without CRLF)readlinelenMAX_LINE_LENGTHrendswithr)r r:s rrrsW" "D 4y?"O,, == !*++ 9 #sAAAA)rbytesreturnstr)r asyncio.StreamReaderrEztuple[str, Headers])r rGrEztuple[int, str, Headers])r rGrEr)r rGrErD) __future__rasyncioosredatastructuresr exceptionsr__all__r*environgetr6rBrcompiler7r+rrrrrrrSs" $& ? +bjjnn%A5IJbjjnn%A6JK3 BJJ7 8  BJJ4 5 .b1(h%Pr