� ���g�C��2�ddlmZddlZddlmZddlmZmZddlm Z ej rddlm Z ddl m Z Gd�d e ��Zd d gZejd ��Zejd ��Zejd��Zejd ejeefejeeefd fZGd�de��Zdd�ZGd�d ejeefejeef��ZGd�deeeef��Z Gd�d ejeef��Z!dS)�)� annotationsN)� OrderedDict)�Enum�auto)�RLock)�Protocol)�Selfc��eZdZdd�Zd d�ZdS) �HasGettableStringKeys�return�typing.Iterator[str]c��dS�N���selfs �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/urllib3/_collections.py�keyszHasGettableStringKeys.keys������key�strc��dSrr�rrs r� __getitem__z!HasGettableStringKeys.__getitem__rrN�r r �rrr r)�__name__� __module__� __qualname__rrrrrr r s(������3�3�3�3�3�3�3�3�3�3rr �RecentlyUsedContainer�HTTPHeaderDict�_KT�_VT�_DTc�"�eZdZe��ZdS)� _SentinelN)rrr r� not_passedrrrr'r''s����������J�J�Jrr'� potential�objectr �ValidHTTPHeaderSource | Nonec���t|t��r|St|tj��r1tjtjt t f|��St|tj��r<tjtjtt t f|��St|d��r%t|d��rtjd|��SdS)Nrrr ) � isinstancer"�typing�Mapping�castr�Iterable�tuple�hasattr)r)s r�%ensure_can_construct_http_header_dictr4+s����)�^�,�,���� �I�v�~� .� .� ��{�6�>�#�s�(�3�Y�?�?�?� �I�v�� /� /���{�6�?�5��c��?�;�Y�G�G�G� ��F� #� #��� �=�(I�(I���{�2�I�>�>�>��trc���eZdZUdZded<ded<ded<ded < dd�fd� Zdd�Zd d�Zd!d�Zd"d�Z d#d�Z d$d�Z d%d�Z �xZ S)&r!a� Provides a thread-safe dict-like container which maintains up to ``maxsize`` keys while throwing away the least-recently-used keys beyond ``maxsize``. :param maxsize: Maximum number of recent elements to retain. :param dispose_func: Every time an item is evicted from the container, ``dispose_func(value)`` is called. Callback which will get called ztyping.OrderedDict[_KT, _VT]� _container�int�_maxsize�#typing.Callable[[_VT], None] | None� dispose_funcr�lock� N�maxsizer �Nonec���t�����||_||_t ��|_t ��|_dSr)�super�__init__r8r:rr6rr;)rr=r:� __class__s �rrAzRecentlyUsedContainer.__init__RsD��� ���������� �(���%�-�-����G�G�� � � rrr#r$c��|j5|j�|��}||j|<|cddd��S#1swxYwYdSr)r;r6�pop)rr�items rrz!RecentlyUsedContainer.__getitem__]s��� �Y� � ��?�&�&�s�+�+�D�#'�D�O�C� �� � � � � � � � � � � � ���� � � � � � � �&;�?�?�valuec��d}|j5 ||j�|��f}||j|<nR#t$rE||j|<t |j��|jkr|j�d���}YnwxYwddd��n #1swxYwY|�#|jr|\}}|�|��dSdSdS)NF)�last)r;r6rD�KeyError�lenr8�popitemr:)rrrG� evicted_item�_� evicted_values r� __setitem__z!RecentlyUsedContainer.__setitem__dsH��� � �Y� G� G� G� #�D�O�$7�$7��$<�$<�<� �',����$�$��� G� G� G�(-����$��t��'�'�$�-�7�7�$(�?�#:�#:��#:�#F�#F�L��� G���� G� G� G� G� G� G� G� G� G� G� G���� G� G� G� G�& � #��(9� #�+� �A�}� � � �m� ,� ,� ,� ,� ,� $� #� #� #s2�B�&3�B�A B�?B�B�B�B�Bc��|j5|j�|��}ddd��n #1swxYwY|jr|�|��dSdSr)r;r6rDr:)rrrGs r� __delitem__z!RecentlyUsedContainer.__delitem__}s��� �Y� -� -��O�'�'��,�,�E� -� -� -� -� -� -� -� -� -� -� -���� -� -� -� -� � � %� � � �e� $� $� $� $� $� %� %s �/�3�3c�l�|j5t|j��cddd��S#1swxYwYdSr)r;rKr6rs r�__len__zRecentlyUsedContainer.__len__�s{�� �Y� (� (��t��'�'� (� (� (� (� (� (� (� (� (� (� (� (���� (� (� (� (� (� (s �)�-�-�typing.NoReturnc� �td���)Nz7Iteration over this class is unlikely to be threadsafe.)�NotImplementedErrorrs r�__iter__zRecentlyUsedContainer.__iter__�s��!� E� � � rc��|j5t|j�����}|j���ddd��n #1swxYwY|jr|D]}|�|���dSdSr)r;�listr6�values�clearr:)rr[rGs rr\zRecentlyUsedContainer.clear�s��� �Y� $� $��$�/�0�0�2�2�3�3�F� �O� !� !� #� #� #� $� $� $� $� $� $� $� $� $� $� $���� $� $� $� $� � � )�� )� )���!�!�%�(�(�(�(� )� )� )� )s�AA�A�A�set[_KT]c��|j5t|j�����cddd��S#1swxYwYdSr)r;�setr6rrs rrzRecentlyUsedContainer.keys�s��� �Y� /� /��t��+�+�-�-�.�.� /� /� /� /� /� /� /� /� /� /� /� /���� /� /� /� /� /� /rF)r<N)r=r7r:r9r r>)rr#r r$)rr#rGr$r r>)rr#r r>�r r7)r rU)r r>)r r])rrr �__doc__�__annotations__rArrPrRrTrXr\r� __classcell__�rBs@rr!r!?s�������� � �-�,�,�,��M�M�M�5�5�5�5��K�K�K��<@� � � � � � � �����-�-�-�-�2%�%�%�%�(�(�(�(� � � � � )�)�)�)�/�/�/�/�/�/�/�/rc�>�eZdZUdZded<dd�Zdd �Zdd �Zdd�ZdS)�HTTPHeaderDictItemViewa� HTTPHeaderDict is unusual for a Mapping[str, str] in that it has two modes of address. If we directly try to get an item with a particular name, we will get a string back that is the concatenated version of all the values: >>> d['X-Header-Name'] 'Value1, Value2, Value3' However, if we iterate over an HTTPHeaderDict's items, we will optionally combine these values based on whether combine=True was called when building up the dictionary >>> d = HTTPHeaderDict({"A": "1", "B": "foo"}) >>> d.add("A", "2", combine=True) >>> d.add("B", "bar") >>> list(d.items()) [ ('A', '1, 2'), ('B', 'foo'), ('B', 'bar'), ] This class conforms to the interface required by the MutableMapping ABC while also giving us the nonstandard iteration behavior we want; items with duplicate keys, ordered by time of first insertion. r"�_headers�headersr r>c��||_dSr)rg)rrhs rrAzHTTPHeaderDictItemView.__init__�s ���� � � rr7c�h�tt|j�������Sr)rKrZrg� iteritemsrs rrTzHTTPHeaderDictItemView.__len__�s&���4�� �/�/�1�1�2�2�3�3�3r� typing.Iterator[tuple[str, str]]c�4�|j���Sr)rgrkrs rrXzHTTPHeaderDictItemView.__iter__�s���}�&�&�(�(�(rrEr*�boolc���t|t��r]t|��dkrJ|\}}t|t��r0t|t��r|j�||��SdS)N�F)r-r2rKrrg�_has_value_for_header)rrE� passed_key� passed_vals r� __contains__z#HTTPHeaderDictItemView.__contains__�so�� �d�E� "� "� S�s�4�y�y�A�~�~�%)� "�J� ��*�c�*�*� S�z�*�c�/J�/J� S��}�:�:�:�z�R�R�R��urN)rhr"r r>r`�r rl)rEr*r rn) rrr rarbrArTrXrtrrrrfrf�s~���������8���� � � � �4�4�4�4�)�)�)�)������rrfc�`��eZdZUdZded<d=d>�fd � Zd?d�Zd@d�ZdAd�ZdBd�Z dCdD�fd� Z dEd�Z dEd�Z dFd�Z dGd�ZdAd�Zdd �dHd"�ZdId%�ZejdJd'���ZejdKd*���ZejfdLd,�ZdMd.�ZeZeZeZeZdNd/�ZdOd0�ZdMd1�ZdPd3�ZdPd4�Z dQd6�Z!dRd9�Z"dSd:�Z#dTd;�Z$dTd<�Z%�xZ&S)Ur"ap :param headers: An iterable of field-value pairs. Must not contain multiple field names when compared case-insensitively. :param kwargs: Additional field-value pairs to pass in to ``dict.update``. A ``dict`` like container for storing HTTP Headers. Field names are stored and compared case-insensitively in compliance with RFC 7230. Iteration provides the first case-sensitive key seen for each case-insensitive pair. Using ``__setitem__`` syntax overwrites fields that compare equal case-insensitively in order to maintain ``dict``'s api. For fields that compare equal, instead create a new ``HTTPHeaderDict`` and use ``.add`` in a loop. If multiple fields that are equal case-insensitively are passed to the constructor or ``.update``, the behavior is undefined and some will be lost. >>> headers = HTTPHeaderDict() >>> headers.add('Set-Cookie', 'foo=bar') >>> headers.add('set-cookie', 'baz=quxx') >>> headers['content-length'] = '7' >>> headers['SET-cookie'] 'foo=bar, baz=quxx' >>> headers['Content-Length'] '7' z%typing.MutableMapping[str, list[str]]r6Nrhr+�kwargsrc � ��t�����i|_|�@t|t��r|�|��n|�|��|r|�|��dSdSr)r@rAr6r-r"� _copy_from�extend)rrhrwrBs �rrAzHTTPHeaderDict.__init__�s���� ����������� � ��'�>�2�2� %�����(�(�(�(�� � �G�$�$�$� � � �K�K�� � � � � � � rr�valr r>c��t|t��r|�d��}||g|j|���<dS)N�latin-1)r-�bytes�decoder6�lower�rrr{s rrPzHTTPHeaderDict.__setitem__�sC�� �c�5� !� !� (��*�*�Y�'�'�C�(+�S�z���� � � � �$�$�$rc�z�|j|���}d�|dd���S)N�, ��r6r��joinr�s rrzHTTPHeaderDict.__getitem__s0���o�c�i�i�k�k�*���y�y��Q�R�R��!�!�!rc�:�|j|���=dSr�r6r�rs rrRzHTTPHeaderDict.__delitem__s�� �O�C�I�I�K�K� (� (� (rr*rnc�f�t|t��r|���|jvSdS)NF)r-rr�r6rs rrtzHTTPHeaderDict.__contains__s.�� �c�3� � � 2��9�9�;�;�$�/�1� 1��ur��defaultc�H��t���||��Sr)r@� setdefault)rrr�rBs �rr�zHTTPHeaderDict.setdefault s����w�w�!�!�#�w�/�/�/r�otherc���t|��}|�dSt|��|��}d�|���D��d�|���D��kS)NFc�>�i|]\}}|���|��Sr�r���.0�k�vs r� <dictcomp>z)HTTPHeaderDict.__eq__.<locals>.<dictcomp>s&��;�;�;���A���� � �1�;�;�;rc�>�i|]\}}|���|��Srr�r�s rr�z)HTTPHeaderDict.__eq__.<locals>.<dictcomp>s9��@ �@ �@ �!�Q��A�G�G�I�I�q�@ �@ �@ r)r4�type� itermerged)rr��maybe_constructable�other_as_http_header_dicts r�__eq__zHTTPHeaderDict.__eq__s���C�E�J�J�� � &��5�(2��T� � �3F�(G�(G� %�;�;����):�):�;�;�;�@ �@ �%>�%I�%I�%K�%K�@ �@ �@ � � rc�.�|�|�� Sr)r�)rr�s r�__ne__zHTTPHeaderDict.__ne__s���;�;�u�%�%�%�%rr7c�*�t|j��Sr)rKr6rs rrTzHTTPHeaderDict.__len__s���4�?�#�#�#rr c#�VK�|j���D] }|dV�� dS)Nr)r6r[)r�valss rrXzHTTPHeaderDict.__iter__!s<�����O�*�*�,�,� � �D��q�'�M�M�M�M� � rc�0� ||=dS#t$rYdSwxYwr)rJrs r�discardzHTTPHeaderDict.discard&s4�� ��S� � � ��� � � � �D�D� ���s �� �F)�combiner�c�J�t|t��r|�d��}|���}||g}|j�||��}||urAt |��dksJ�|r|ddz|z|d<dS|�|��dSdS)a�Adds a (name, value) pair, doesn't overwrite the value if it already exists. If this is called with combine=True, instead of adding a new header value as a distinct item during iteration, this will instead append the value to any existing header value with a comma. If no existing header value exists for the key, then the value will simply be added, ignoring the combine parameter. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' >>> list(headers.items()) [('foo', 'bar'), ('foo', 'baz')] >>> headers.add('foo', 'quz', combine=True) >>> list(headers.items()) [('foo', 'bar, baz, quz')] r}rp�����r�N)r-r~rr�r6r�rK�append)rrr{r�� key_lower�new_valsr�s r�addzHTTPHeaderDict.add,s���( �c�5� !� !� (��*�*�Y�'�'�C��I�I�K�K� ���:����)�)�)�X�>�>�� �4� � ��t�9�9��>�>�>�>�� !���8�d�?�S�0��R����� � �C� � � � � � � r�args�ValidHTTPHeaderSourcec��t|��dkr tdt|���d����t|��dkr|dnd}t|t��r2|���D]\}}|�||����nt|t j��r1|���D]\}}|�||���n�t|t j ��r[t j t j tttf|��}|D]\}}|�||���nSt|d��rCt|d��r3|���D]}|�|||���|���D]\}}|�||���dS) z�Generic import function for any type of header-like object. Adapted version of MutableMapping.update in order to insert items with self.add instead of self.__setitem__ r�z/extend() takes at most 1 positional arguments (z given)rrrrN)rK� TypeErrorr-r"rkr�r.r/�itemsr1r0r2rr3r)rr�rwr�rr{rGs rrzzHTTPHeaderDict.extendOs��� �t�9�9�q�=�=��T�#�d�)�)�T�T�T��� ��t�9�9��>�>��Q���r�� �e�^� ,� ,� *�!�O�O�-�-� #� #���S�����c�"�"�"�"� #� ��v�~� .� .� *�!�K�K�M�M� #� #���S�����c�"�"�"�"� #� ��v�� /� /� *��K����c�3�h�� @�%�H�H�E�#� %� %� ��U�����e�$�$�$�$� %� �U�F� #� #� *���}�(E�(E� *� �z�z�|�|� *� *������e�C�j�)�)�)�)� �,�,�.�.� !� !�J�C�� �H�H�S�%� � � � � !� !r� list[str]c��dSrrrs r�getlistzHTTPHeaderDict.getlistps��.1�crr%�list[str] | _DTc��dSrr)rrr�s rr�zHTTPHeaderDict.getlistss��BE�#r�_Sentinel | _DTc�� |j|���}|dd�S#t$r|tjurgcYS|cYSwxYw)zmReturns a list of all the values for the named field. Returns an empty list if the key doesn't exist.r�N)r6r�rJr'r()rrr�r�s rr�zHTTPHeaderDict.getlistvsg�� ��?�3�9�9�;�;�/�D�����8�O��� � � ��)�.�.�.�� � � ��N�N�N�  ���s�+�A �A � A r c�B�gd�}|D]}|�|���|S)z� Remove content-specific header fields before changing the request method to GET or HEAD according to RFC 9110, Section 15.4. )zContent-EncodingzContent-LanguagezContent-Locationz Content-TypezContent-Length�Digestz Last-Modified)r�)r�content_specific_headers�headers r�_prepare_for_method_changez)HTTPHeaderDict._prepare_for_method_change�s?�� $ �$ �$ � �/� !� !�F� �L�L�� � � � �� rc�t�t|��j�dt|������d�S)N�(�))r�r�dictr�rs r�__repr__zHTTPHeaderDict.__repr__�s4���t�*�*�%�B�B��T�_�_�->�->�(?�(?�B�B�B�Brc�x�|D]6}|�|��}|g|�|j|���<�7dSr)r�r6r�)rr�rr{s rryzHTTPHeaderDict._copy_from�sI��� 7� 7�C��-�-��$�$�C�,/�;�#�;�D�O�C�I�I�K�K� (� (� 7� 7rc�^�t|����}|�|��|Sr)r�ry)r�clones r�copyzHTTPHeaderDict.copy�s,����T� � � � �� �������� rrlc#�K�|D]:}|j|���}|dd�D]}|d|fV���;dS)z8Iterate over all header lines, including duplicate ones.r�Nrr�)rrr�r{s rrkzHTTPHeaderDict.iteritems�sf����� #� #�C��?�3�9�9�;�;�/�D��A�B�B�x� #� #���1�g�s�l�"�"�"�"� #� #� #rc#�K�|D]H}|j|���}|dd�|dd���fV��IdS)z:Iterate over all headers, merging duplicate ones together.rr�r�Nr�r�s rr�zHTTPHeaderDict.itermerged�s_����� -� -�C��/�#�)�)�+�+�.�C��a�&�$�)�)�C����G�,�,�,� ,� ,� ,� ,� -� -rrfc� �t|��Sr)rfrs rr�zHTTPHeaderDict.items�s��%�d�+�+�+r� header_name�potential_valuec�`�||vr)||j|���dd�vSdS)Nr�Fr�)rr�r�s rrqz$HTTPHeaderDict._has_value_for_header�s9�� �$� � �"�d�o�k�6G�6G�6I�6I�&J�1�2�2�&N�N� N��urc�`�t|��}|�tS|�|��|Sr)r4�NotImplementedrz)rr�r�s r�__ior__zHTTPHeaderDict.__ior__�s7��D�E�J�J�� � &�!� !� � � �'�(�(�(�� rc��t|��}|�tS|���}|�|��|Sr)r4r�r�rz�rr�r��results r�__or__zHTTPHeaderDict.__or__�sD��D�E�J�J�� � &�!� !�������� � �)�*�*�*�� rc��t|��}|�tSt|��|��}|�|��|Sr)r4r�r�rzr�s r�__ror__zHTTPHeaderDict.__ror__�sL��D�E�J�J�� � &�!� !���d���/�0�0��� � �d����� rr)rhr+rwr)rrr{rr r>r)rrr r>)rr*r rn)r�)rrr�rr r)r�r*r rnr`r)rrr{rr�rnr r>)r�r�rwrr r>)rrr r�)rrr�r%r r�)rrr�r�r r�)r r )r r)r�r"r r>ru)r rf)r�rr�rr rn)r�r*r r")r�r*r r )'rrr rarbrArPrrRrtr�r�r�rTrXr�r�rzr.�overloadr�r'r(r�� getheaders�getallmatchingheaders�iget�get_allr�ryr�rkr�r�rqr�r�r�rcrds@rr"r"�s�����������B6�5�5�5�  �  �  �  �  �  �  �2�2�2�2� "�"�"�"�)�)�)�)����� 0�0�0�0�0�0�0�  �  �  �  �&�&�&�&�$�$�$�$����� ���� :?�!!�!!�!!�!!�!!�!!�F!�!�!�!�B �_�1�1�1��_�1� �_�E�E�E��_�E�4=�3G������$����&�J�#�� �D��G�C�C�C�C�7�7�7�7� ���� #�#�#�#�-�-�-�-� ,�,�,�,����� ���������������r)r)r*r r+)"� __future__rr.� collectionsr�enumrr� threadingr� TYPE_CHECKINGr�typing_extensionsr r �__all__�TypeVarr#r$r%�Unionr/rr1r2r�r'r4�Generic�MutableMappingr!r_rfr"rrr�<module>r�s>��"�"�"�"�"�"� � � � �#�#�#�#�#�#��������������� �� 4� ������&�&�&�&�&�&�4�4�4�4�4��4�4�4� #�$4� 5���f�n�U�����f�n�U�����f�n�U����� �� �N�3��8�� �O�E�#�s�(�O�$������������������(Z/�Z/�Z/�Z/�Z/�F�N�3��8�4�f�6K�C�QT�H�6U�Z/�Z/�Z/�z-�-�-�-�-�S��s�C�x��1�-�-�-�`S�S�S�S�S�V�*�3��8�4�S�S�S�S�Sr
Memory