� K�g /��J�dZddlmZddlZddlZddlZddlZddlmZ ddl Z n#e $r ddl Z n #e $rdZ YnwxYwYnwxYw ddl Z n #e $rdZ YnwxYwGd�d��Z Gd�d e ��ZGd �d e ��ZGd �d e ��ZGd�de ��ZGd�de ��ZGd�de ��ZGd�d��ZGd�d��ZGd�d��ZGd�d��Zeeeeed�Ze �e�d��e �e�d��dSdS)zq Handlers for Content-Encoding. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding �)� annotationsN�)� DecodingErrorc��eZdZdd�Zdd�ZdS) �ContentDecoder�data�bytes�returnc��t����N��NotImplementedError��selfrs �_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/httpx/_decoders.py�decodezContentDecoder.decode%���!�#�#�#�c��t���r r �rs r�flushzContentDecoder.flush(rrN�rr r r �r r )�__name__� __module__� __qualname__rr�rrrr$s<������$�$�$�$�$�$�$�$�$�$rrc�"�eZdZdZdd�Zd d�ZdS) �IdentityDecoderz Handle unencoded data. rr r c��|Sr rrs rrzIdentityDecoder.decode1s��� rc��dS�Nrrrs rrzIdentityDecoder.flush4s���srNrr)rrr�__doc__rrrrrrr,sF�����������������rrc�*�eZdZdZd d�Zd d�Zd d�Zd S) �DeflateDecoderzZ Handle 'deflate' decoding. See: https://stackoverflow.com/questions/1838699 r �Nonec�D�d|_tj��|_dS�NT)� first_attempt�zlib� decompressobj� decompressorrs r�__init__zDeflateDecoder.__init__?s!��!��� �.�0�0����rrr c�<�|j}d|_ |j�|��S#tj$rb}|r>tjtj ��|_|�|��cYd}~Stt|����|�d}~wwxYw�NF) r)r,� decompressr*�errorr+� MAX_WBITSrr�str)rr�was_first_attempt�excs rrzDeflateDecoder.decodeCs��� �.��"��� 3��$�/�/��5�5� 5���z� 3� 3� 3� � )�$(�$6����$G�$G��!��{�{�4�(�(�(�(�(�(�(�(���C���)�)�s� 2�����  3���s �*�B�:B�3B�9B�Bc�� |j���S#tj$r"}t t |����|�d}~wwxYwr �r,rr*r1rr3�rr5s rrzDeflateDecoder.flushN�S�� 3��$�*�*�,�,� ,���z� 3� 3� 3���C���)�)�s� 2����� 3������A �A�A N�r r&rr�rrrr#r-rrrrrr%r%8sZ�������� 1�1�1�1� 3� 3� 3� 3�3�3�3�3�3�3rr%c�*�eZdZdZd d�Zd d�Zd d�Zd S) � GZipDecoderzW Handle 'gzip' decoding. See: https://stackoverflow.com/questions/1838699 r r&c�R�tjtjdz��|_dS)N�)r*r+r2r,rs rr-zGZipDecoder.__init__\s"�� �.�t�~��/B�C�C����rrr c�� |j�|��S#tj$r"}t t |����|�d}~wwxYwr )r,r0r*r1rr3�rrr5s rrzGZipDecoder.decode_sU�� 3��$�/�/��5�5� 5���z� 3� 3� 3���C���)�)�s� 2����� 3���s��A �A�A c�� |j���S#tj$r"}t t |����|�d}~wwxYwr r7r8s rrzGZipDecoder.flusher9r:Nr;rrr<rrrr>r>Us^�������� D�D�D�D�3�3�3�3� 3�3�3�3�3�3rr>c�*�eZdZdZd d�Zd d�Zd d�Zd S) � BrotliDecoderaT Handle 'brotli' decoding. Requires `pip install brotlipy`. See: https://brotlipy.readthedocs.io/ or `pip install brotli`. See https://github.com/google/brotli Supports both 'brotlipy' and 'Brotli' packages since they share an import name. The top branches are for 'brotlipy' and bottom branches for 'Brotli' r r&c���t�td��d�tj��|_d|_|t |jd��r|jj|_dS|jj|_dS)Nz�Using 'BrotliDecoder', but neither of the 'brotlicffi' or 'brotli' packages have been installed. Make sure to install httpx using `pip install httpx[brotli]`.Fr0) �brotli� ImportError� Decompressorr,� seen_data�hasattrr0� _decompress�processrs rr-zBrotliDecoder.__init__vs��� �>��P����  � #�/�1�1������ �9� �4�$�l� 3� 3� 9�#�0�;�D� � � � $�0�8�D� � � rrr c��|sdSd|_ |�|��S#tj$r"}t t |����|�d}~wwxYw�NrT)rJrLrGr1rr3rBs rrzBrotliDecoder.decode�sf��� ��3���� 3��#�#�D�)�)� )���|� 3� 3� 3���C���)�)�s� 2����� 3���s�"�A�A�Ac���|jsdS t|jd��r|j���dS#tj$r"}t t|����|�d}~wwxYw)Nr�finish)rJrKr,rQrGr1rr3r8s rrzBrotliDecoder.flush�s~���~� ��3� 3��t�(�(�3�3� +� �!�(�(�*�*�*��3���|� 3� 3� 3���C���)�)�s� 2����� 3���s�.;�A,� A'�'A,Nr;rrr<rrrrErElsZ��������9�9�9�9�$3�3�3�3� 3� 3� 3� 3� 3� 3rrEc�*�eZdZdZd d�Zd d�Zd d�Zd S) �ZStandardDecoderz� Handle 'zstd' RFC 8878 decoding. Requires `pip install zstandard`. Can be installed as a dependency of httpx using `pip install httpx[zstd]`. r r&c��t�td��d�tj�����|_d|_dS)NzXUsing 'ZStandardDecoder', ...Make sure to install httpx using `pip install httpx[zstd]`.F)� zstandardrH�ZstdDecompressorr+r,rJrs rr-zZStandardDecoder.__init__�sO�� � ��N���� � &�6�8�8�F�F�H�H�������rrr c�\�t�J�d|_tj��} |�|j�|����|jjr�|jjr{|jj}tj ��� ��|_|�|j�|����|jjr |jj�{n4#tj $r"}tt|����|�d}~wwxYw|���Sr()rUrJ�io�BytesIO�writer,r0�eof� unused_datarVr+� ZstdErrorrr3�getvalue)rr�outputr\r5s rrzZStandardDecoder.decode�s���$�$�$��������� 3� �L�L��*�5�5�d�;�;� <� <� <��#�'� H�D�,=�,I� H�"�/�;� �$-�$>�$@�$@�$N�$N�$P�$P��!�� � �T�.�9�9�+�F�F�G�G�G��#�'� H�D�,=�,I� H����"� 3� 3� 3���C���)�)�s� 2����� 3������� � � s�CC&�&D�5D�Dc��|jsdS|j���}|jjst d���t |��S)NrzZstandard data is incomplete)rJr,rr[rr )r�rets rrzZStandardDecoder.flush�sO���~� ��3���%�%�'�'��� �$� @�� >�?�?� ?��S�z�z�rNr;rrr<rrrrSrS�sZ������������ !� !� !� !������rrSc�*�eZdZdZd d�Zd d �Zdd �Zd S)� MultiDecoderzE Handle the case where multiple encodings have been applied. �children�typing.Sequence[ContentDecoder]r r&c�H�tt|����|_dS)zm 'children' should be a sequence of decoders in the order in which each was applied. N)�list�reversedrd)rrds rr-zMultiDecoder.__init__�s�� �X�h�/�/�0�0�� � � rrr c�D�|jD]}|�|��}�|Sr )rdr�rr�childs rrzMultiDecoder.decode�s+���]� &� &�E��<�<��%�%�D�D�� rc�r�d}|jD],}|�|��|���z}�-|Sr")rdrrrjs rrzMultiDecoder.flush�s=�����]� 6� 6�E��<�<��%�%�� � � � �5�D�D�� rN)rdrer r&rrr<rrrrcrc�sZ��������1�1�1�1����� �����rrcc�,�eZdZdZd dd�Zdd �Zdd �ZdS)� ByteChunkerz> Handles returning byte content in fixed-size chunks. N� chunk_size� int | Noner r&c�D�tj��|_||_dSr )rXrY�_buffer� _chunk_size�rros rr-zByteChunker.__init__�s���z�|�|�� �%����r�contentr � list[bytes]c�����j�|r|gngS�j�|���j����jkr��j������fd�t dt ����j��D��}t |d���jkr5�j�d���j���|S�j�d���j�|d���j���|dd�SgS)Nc�4��g|]}�||�jz���Sr�rs��.0�ir�values ��r� <listcomp>z&ByteChunker.decode.<locals>.<listcomp>��;��������a�!�d�.�.�.�/���rr������ rsrrrZ�tellr^�range�len�seek�truncate�rru�chunksr}s` @rrzByteChunker.decode��E���� � � #� '�/�G�9�9�R� /� � ���7�#�#�#� �<� � � � �$�"2� 2� 2��L�)�)�+�+�E�������q�#�e�*�*�d�.>�?�?����F��6�"�:���$�"2�2�2�� �!�!�!�$�$�$�� �%�%�'�'�'�� �� �!�!�!�$�$�$�� �"�"�6�"�:�.�.�.�� �%�%�'�'�'��c�r�c�{�"��Irc��|j���}|j�d��|j���|r|gngS�Nr�rrr^r�r��rr}s rrzByteChunker.flush�P��� �%�%�'�'�� � ���!���� � �������'��w�w�R�'rr �rorpr r&)rur r rv)r rvr<rrrrnrn��_��������&�&�&�&�&�����.(�(�(�(�(�(rrnc�,�eZdZdZd dd�Zdd �Zdd �ZdS)� TextChunkerz> Handles returning text content in fixed-size chunks. Nrorpr r&c�D�tj��|_||_dSr )rX�StringIOrrrsrts rr-zTextChunker.__init__s���{�}�}�� �%����rrur3� list[str]c�����j�|r|gngS�j�|���j����jkr��j������fd�t dt ����j��D��}t |d���jkr5�j�d���j���|S�j�d���j�|d���j���|dd�SgS)Nc�4��g|]}�||�jz���Srryrzs ��rr~z&TextChunker.decode.<locals>.<listcomp>rrrr�r�r�s` @rrzTextChunker.decoder�rc��|j���}|j�d��|j���|r|gngSr�r�r�s rrzTextChunker.flush+r�rr r�)rur3r r��r r�r<rrrr�r� r�rr�c�,�eZdZdZd dd�Zdd �Zdd �Zd S)� TextDecoderz8 Handles incrementally decoding bytes into text �utf-8�encodingr3r r&c�L�tj|��d���|_dS)N�replace)�errors)�codecs�getincrementaldecoder�decoder)rr�s rr-zTextDecoder.__init__7s%��=�v�3�H�=�=�Y�O�O�O�� � � rrr c�6�|j�|��Sr �r�rrs rrzTextDecoder.decode:s���|�"�"�4�(�(�(rc�8�|j�dd��SrOr�rs rrzTextDecoder.flush=s���|�"�"�3��-�-�-rN)r�)r�r3r r&)rr r r3)r r3r<rrrr�r�2sd��������P�P�P�P�P�)�)�)�)�.�.�.�.�.�.rr�c�*�eZdZdZd d�Zd d�Zd d �Zd S)� LineDecoderz� Handles incrementally reading lines from text. Has the same behaviour as the stdllib splitlines, but handling the input iteratively. r r&c�"�g|_d|_dSr/)�buffer� trailing_crrs rr-zLineDecoder.__init__Is��!#�� �!&����r�textr3r�c���d}|jr d|z}d|_|�d��rd|_|dd�}|sgS|d|v}|���}t|��dkr$|s"|j�|d��gS|jr6d�|j��|dzg|dd�z}g|_|s|���g|_|S) Nu …

� FTr�rr�)r��endswith� splitlinesr�r��append�join�pop)rr�� NEWLINE_CHARS�trailing_newline�liness rrzLineDecoder.decodeMs ��B� � � � %��$�;�D�$�D� � �=�=�� � � �#�D� �����9�D�� ��I���8�}�4�����!�!�� �u�:�:��?�?�#3�?� �K� � �u�Q�x� (� (� (��I� �;� ��W�W�T�[�)�)�E�!�H�4�5��a�b�b� �A�E��D�K�� (�!�9�9�;�;�-�D�K�� rc�x�|js |jsgSd�|j��g}g|_d|_|S)Nr�F)r�r�r�)rr�s rrzLineDecoder.flushssE���{� �4�#3� ��I������%�%�&���� � ���� rNr;)r�r3r r�r�r<rrrr�r�As[��������'�'�'�'�$�$�$�$�L�����rr�)�identity�gzip�deflate�br�zstdr�r�)r#� __future__rr�rX�typingr*� _exceptionsrrGrH� brotlicffirUrrr%r>rErSrcrnr�r�r��SUPPORTED_DECODERSr�rrr�<module>r�s"���� #�"�"�"�"�"� � � � � � � � � � � � � � � � �&�&�&�&�&�&� ��M�M�M�M������� $�#�#�#�#�� �������������� ����������������I�I�I�����$�$�$�$�$�$�$�$� � � � � �n� � � �3�3�3�3�3�^�3�3�3�:3�3�3�3�3�.�3�3�3�.23�23�23�23�23�N�23�23�23�j'�'�'�'�'�~�'�'�'�T�����>����2$(�$(�$(�$(�$(�$(�$(�$(�N$(�$(�$(�$(�$(�$(�$(�$(�N .� .� .� .� .� .� .� .�9�9�9�9�9�9�9�9�z � �� � � ��� �>����4� � � � �����6�"�"�"�"�"��s;�%�A�0�A�:�A�:�A�A�A � A�A
Memory