관리-도구
편집 파일: cookies.cpython-311.pyc
� ���h+�=�K���������������������������d�Z�ddlZddlZddlZg�d�Zdj��������Zdj��������Zdj��������Z�G�d��de ������������Z ej��������ej��������z���d z���Z e d z���Zd���e�ed�������������������������e�eee������������������������z ��D���������������Ze����������������������ed ������������d�ed������������di��������������ej��������d�ej��������e ������������z��������������j��������Zd��Z�ej��������d������������Z�ej��������d������������Zd��Zg�d�Zg�d�Zdeefd�Z�G�d��de ������������Z!dZ"e"dz���Z#�ej��������de"z���dz���e#z���dz���ej$��������ej%��������z��������������Z&�G�d ��d!e ������������Z'�G�d"��d#e'������������Z(dS�)$a. �� Here's a sample session to show how to use this module. At the moment, this is the only documentation. The Basics ---------- Importing is easy... >>> from http import cookies Most of the time you start by creating a cookie. >>> C = cookies.SimpleCookie() Once you've created your Cookie, you can add values just as if it were a dictionary. >>> C = cookies.SimpleCookie() >>> C["fig"] = "newton" >>> C["sugar"] = "wafer" >>> C.output() 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer' Notice that the printable representation of a Cookie is the appropriate format for a Set-Cookie: header. This is the default behavior. You can change the header and printed attributes by using the .output() function >>> C = cookies.SimpleCookie() >>> C["rocky"] = "road" >>> C["rocky"]["path"] = "/cookie" >>> print(C.output(header="Cookie:")) Cookie: rocky=road; Path=/cookie >>> print(C.output(attrs=[], header="Cookie:")) Cookie: rocky=road The load() method of a Cookie extracts cookies from a string. In a CGI script, you would use this method to extract the cookies from the HTTP_COOKIE environment variable. >>> C = cookies.SimpleCookie() >>> C.load("chips=ahoy; vienna=finger") >>> C.output() 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger' The load() method is darn-tootin smart about identifying cookies within a string. Escaped quotation marks, nested semicolons, and other such trickeries do not confuse it. >>> C = cookies.SimpleCookie() >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') >>> print(C) Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" Each element of the Cookie also supports all of the RFC 2109 Cookie attributes. Here's an example which sets the Path attribute. >>> C = cookies.SimpleCookie() >>> C["oreo"] = "doublestuff" >>> C["oreo"]["path"] = "/" >>> print(C) Set-Cookie: oreo=doublestuff; Path=/ Each dictionary element has a 'value' attribute, which gives you back the value associated with the key. >>> C = cookies.SimpleCookie() >>> C["twix"] = "none for you" >>> C["twix"].value 'none for you' The SimpleCookie expects that all values should be standard strings. Just to be sure, SimpleCookie invokes the str() builtin to convert the value to a string, when the values are set dictionary-style. >>> C = cookies.SimpleCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value '7' >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number=7\r\nSet-Cookie: string=seven' Finis. �����N)�CookieError� BaseCookie�SimpleCookie��z; � c�������������������������e�Zd�ZdS�)r���N)�__name__� __module__�__qualname__��������3/opt/alt/python311/lib64/python3.11/http/cookies.pyr���r�������s���������������Dr ���r���z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}c�����������������������i�|�]}|d�|z���� S�)z\%03or���)�.0�ns��� r���� <dictcomp>r�������s4�������J��J��J����(�Q�,��J��J��Jr ��������"�\"�\z\\z[%s]+c������������������h�����|��t����������|�������������r|�S�d|����������������������t����������������������z���dz���S�)z�Quote a string for use in a cookie header. If the string does not need to be double-quoted, then just return the string. Otherwise, surround the string in doublequotes and quote (with a \) special characters. Nr���)� _is_legal_key� translate�_Translator��strs��� r����_quoter�������s6��������{�m�C�(�(�{�� ��S�]�]�;�/�/�/�#�5�5r ���z\\[0-3][0-7][0-7]z[\\].c����������� �������j����|��t����������|�������������dk�����r|�S�|�d���������dk����s|�d���������dk����r|�S�|�dd����������}�d}t����������|�������������}g�}d|cxk����r|k������rIn��nEt�������������������������������|�|������������}t�������������������������������|�|������������}|s |s|���������������������|�|d������������������������n�dx}}|r|���������������������d������������}|r|���������������������d������������}|rI|r||k�����rA|���������������������|�||�����������������������|���������������������|�|dz�������������������������|dz���}n`|���������������������|�||�����������������������|���������������������t ����������t����������|�|dz���|dz�������������d�������������������������������������|dz���}d|cxk����r|k�������Cn�t����������|������������S�)N����r���r������������������) �len� _OctalPatt�search� _QuotePatt�append�start�chr�int� _nulljoin)r����ir����res�o_match�q_match�j�ks��� r����_unquoter3�������s��������{�c�#�h�h��l�l�� � �1�v��}�}��B��3���� ���a��d�)�C�� �A��C���A� �C� �q�*�*�*�*�1�*�*�*�*�*��#�#�C��+�+���#�#�C��+�+���� �w�� ��J�J�s�1�2�2�w������ ��A��� !�� � �a� � �A��� !�� � �a� � �A��� �G�� �q�1�u�u��J�J�s�1�Q�3�x� � � ��J�J�s�1�Q�3�x� � � ��A��A�A��J�J�s�1�Q�3�x� � � ��J�J�s�3�s�1�Q�3�q��s�7�|�Q�/�/�0�0�1�1�1��A��A�'��q�*�*�*�*�1�*�*�*�*�(��S�>�>�r ���)�Mon�Tue�Wed�Thu�Fri�Sat�Sun) N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc����������� ������������ddl�m}m�}��|��������������}�|||�z���������������\ ��}}}} } }}} }d||���������|||���������|| | |fz��S�)Nr���)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)rI���rH���)�future�weekdayname� monthnamerH���rI����now�year�month�day�hh�mm�ss�wd�y�zs��� r����_getdaterW�������su������!�!�!�!�!�!�!�!� �$�&�&�C�-3�V�C�&�L�-A�-A�*�D�%��b�"�b�"�a��0���O�S�)�E�"2�D�"�b�"�E�F��Fr ���c������������ ������������e�Zd�ZdZdddddddd d d� Zdd hZd��Zed����������������Zed����������������Z ed����������������Z d��Zd!d�Zd��Z ej��������Zd��Zd��Zd��Zd��Zd��Zd��Zd"d�ZeZd��Zd!d�Zd!d �Z�eej��������������������ZdS�)#�MorselaC��A class to hold ONE (key, value) pair. In a cookie, each such pair may have several attributes, so this class is used to keep the attributes associated with the appropriate key,value pair. This class also includes a coded_value attribute, which is used to hold the network representation of the value. �expires�Path�Comment�DomainzMax-Age�Secure�HttpOnly�Version�SameSite) rZ����path�comment�domain�max-age�secure�httponly�version�samesiterf���rg���c������������������|�����d�x|�_���������x|�_��������|�_��������|�j��������D�]}t�������������������������������|�|d��������������d�S�)Nr���)�_key�_value�_coded_value� _reserved�dict�__setitem__)�self�keys��� r����__init__zMorsel.__init__!��sP������6:�:�� �:�D�K�$�"3���>�� ,�� ,�C����T�3��+�+�+�+� ,�� ,r ���c�����������������������|�j���������S��N)rk����rq���s��� r���rr���z Morsel.key)��s �������y�r ���c�����������������������|�j���������S�ru���)rl���rv���s��� r����valuezMorsel.value-��s �������{�r ���c�����������������������|�j���������S�ru���)rm���rv���s��� r����coded_valuezMorsel.coded_value1��s������� � r ���c�����������������������|������������������������������������}||�j��������vrt����������d|���������������t�������������������������������|�||�������������d�S��NzInvalid attribute )�lowerrn���r���ro���rp���)rq����K�Vs��� r���rp���zMorsel.__setitem__5��sO������ �G�G�I�I���D�N�"�"��+���;�<�<�<�����q�!�$�$�$�$�$r ���Nc�����������������������|������������������������������������}||�j��������vrt����������d|���������������t�������������������������������|�||������������S�r|���)r}���rn���r���ro���� setdefault)rq���rr����vals��� r���r����zMorsel.setdefault;��sG�������i�i�k�k���d�n�$�$��+���=�>�>�>����t�S�#�.�.�.r ���c������������������������t����������|t����������������������st����������S�t�������������������������������|�|������������o/|�j��������|j��������k����o|�j��������|j��������k����o|�j��������|j��������k����S�ru���)� isinstancerY����NotImplementedro����__eq__rl���rk���rm����rq����morsels��� r���r����z Morsel.__eq__A��sg�������&�&�)�)�� "�!�!����D�&�)�)��9���v�}�,�9�� �V�[�(�9���!�V�%8�8� :r ���c�����������������������t������������������������}t�������������������������������||��������������|j�����������������������������|�j���������������������|S�ru���)rY���ro����update�__dict__r����s��� r����copyzMorsel.copyK��s<�������������F�D�!�!�!�����t�}�-�-�-�� r ���c�����������������������i�}t����������|�����������������������������������������������D�]9\��}}|�����������������������������������}||�j��������vrt ����������d|���������������|||<����:t��������������������������������|�|�������������d�S�r|���)ro����itemsr}���rn���r���r����)rq����values�datarr���r����s��� r���r����z Morsel.updateQ��s����������V���*�*�,�,�� �� �H�C���)�)�+�+�C��$�.�(�(�!�k�C�C�"A�B�B�B��D��I�I����D�$�����r ���c������������������8�����|������������������������������������|�j��������v�S�ru���)r}���rn���)rq���r~���s��� r���� isReservedKeyzMorsel.isReservedKeyZ��s�������w�w�y�y�D�N�*�*r ���c������������������������|������������������������������������|�j��������v�rt����������d|���������������t����������|������������st����������d|���������������||�_��������||�_��������||�_��������d�S�)NzAttempt to set a reserved key zIllegal key )r}���rn���r���r���rk���rl���rm���)rq���rr���r����� coded_vals��� r����setz Morsel.set]��so�������9�9�;�;�$�.�(�(��+�C�C�I�J�J�J��S�!�!�� 9��+�#�#�7�8�8�8���� ����%����r ���c������������������,�����|�j���������|�j��������|�j��������d�S�)N)rr���rx���rz����rk���rl���rm���rv���s��� r����__getstate__zMorsel.__getstate__h��s!�������9��[��,� �� �� r ���c������������������T�����|d���������|�_���������|d���������|�_��������|d���������|�_��������d�S�)Nrr���rx���rz���r����)rq����states��� r����__setstate__zMorsel.__setstate__o��s+�������%�L�� ��G�n���!�-�0����r ����Set-Cookie:c������������������6�����|�d|�����������������������|��������������S�)Nr���)�OutputString)rq����attrs�headers��� r����outputz Morsel.outputt��s"������ �&�&�$�"3�"3�E�":�":�":�;�;r ���c������������������L�����d|�j���������j���������d|�������������������������������������d�S�)N�<�: �>)� __class__r ���r����rv���s��� r����__repr__zMorsel.__repr__y��s,��������!�^�4�4�4�d�6G�6G�6I�6I�6I�6I�J�Jr ���c������������������Z�����d|�����������������������|���������������������������������dd������������z��S�)Nz� <script type="text/javascript"> <!-- begin hiding document.cookie = "%s"; // end hiding --> </script> r���r���)r�����replace)rq���r����s��� r���� js_outputzMorsel.js_output|��s4��������� � ��'�'�/�/��U�;�;� =�� =r ���c����������������������g�}|j���������}�||�j���������d|�j�����������������������|�|�j��������}t ����������|������������������������������������������������}|D��]\��}}|dk����r� ||vr�|dk����r>t ����������|t����������������������r)�||�j��������|����������dt����������|����������������������������V|dk����r1t ����������|t����������������������r�|d|�j��������|���������|fz�����������������|dk����r>t ����������|t����������������������r)�||�j��������|����������dt����������|�����������������������������||�j��������v�r'|r#�|t����������|�j��������|�������������������������������������||�j��������|����������d|�����������������t����������|������������S�)N�=r���rZ���re���z%s=%drc���) r(���rr���rz���rn����sortedr����r����r+���rW���r���r����_flags�_semispacejoin)rq���r�����resultr(���r����rr���rx���s��� r���r����zMorsel.OutputString���s������������� ��$�(�(�(�D�$4�$4�5�6�6�6���=��N�E��t�z�z�|�|�$�$���� ?�� ?�J�C����{�{���%�����i���J�u�c�$:�$:����$�.��"5�"5�"5�x�����G�H�H�H�H�� �!�!�j���&<�&<�!���w�$�.��"5�u�!=�=�>�>�>�>�� �!�!�j���&<�&<�!���$�.��"5�"5�"5�v�e�}�}�}�E�F�F�F�F����#�#���5��F�3�t�~�c�2�3�3�4�4�4����$�.��"5�"5�"5�u�u�=�>�>�>�>���f�%�%�%r ���ru���)Nr����)r ���r ���r����__doc__rn���r����rs����propertyrr���rx���rz���rp���r����r�����object�__ne__r����r����r����r����r����r����r�����__str__r����r����r�����classmethod�types�GenericAlias�__class_getitem__r���r ���r���rY���rY�������s�����������������*���������� �� �I��� � #�F�,��,��,��������X���������X����!��!���X�!�%��%��%�/��/��/��/�:��:��:���]�F������ �� �� �+��+��+� &�� &�� &� �� �� �1��1��1� <��<��<��<���G�K��K��K�=��=��=��=�&��&��&��&�B�$��E�$6�7�7���r ���rY���z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z� \s* # Optional whitespace at start of cookie (?P<key> # Start of group 'key' [a ��]+? # Any word of at least one letter ) # End of group 'key' ( # Optional group: there may not be a value. \s*=\s* # Equal Sign (?P<val> # Start of group 'val' "(?:[^\\"]|\\.)*" # Any doublequoted string | # or \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr | # or [a-��]* # Any word or empty string ) # End of group 'val' )? # End of optional value group \s* # Any number of spaces. (\s+|;|$) # Ending either at space, semicolon, or EOS. c��������������������\�����e�Zd�ZdZd��Zd��Zdd�Zd��Zd��Zdd �Z e Z d��Zdd�Zd ��Z efd�ZdS�)r���z'A container class for a set of Morsels.c������������������ �����||fS�)a ��real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies. r����rq���r����s��� r����value_decodezBaseCookie.value_decode���s ��������C�x�r ���c������������������(�����t����������|������������}||fS�)z�real_value, coded_value = value_encode(VALUE) Called prior to setting a cookie's value from the dictionary representation. The VALUE is the value being assigned. Override this function to modify the behavior of cookies. r����rq���r�����strvals��� r����value_encodezBaseCookie.value_encode���s��������S�����v�~�r ���Nc������������������8�����|r|�����������������������|�������������d�S�d�S�ru���)�load)rq����inputs��� r���rs���zBaseCookie.__init__���s,�������� ��I�I�e������ �� r ���c�����������������������|�����������������������|t������������������������������������}|���������������������|||�������������t�������������������������������|�||�������������dS�)z+Private method for setting a cookie's valueN)�getrY���r����ro���rp���)rq���rr���� real_valuerz����Ms��� r����__setzBaseCookie.__set���sM�������H�H�S�&�(�(�#�#�� ���c�:�{�+�+�+�����s�A�&�&�&�&�&r ���c������������������������t����������|t����������������������rt�������������������������������|�||�������������dS�|����������������������|������������\��}}|����������������������|||�������������dS�)zDictionary style assignment.N)r����rY���ro���rp���r�����_BaseCookie__set)rq���rr���rx����rval�cvals��� r���rp���zBaseCookie.__setitem__���se�������e�V�$�$�� (����T�3��.�.�.�.�.��*�*�5�1�1�J�D�$��J�J�s�D�$�'�'�'�'�'r ���r����� c������������������������g�}t����������|������������������������������������������������}|D�].\��}}|���������������������|���������������������||��������������������������/|���������������������|������������S�)z"Return a string suitable for HTTP.)r����r����r(���r�����join)rq���r����r�����sepr����r����rr���rx���s��� r���r����zBaseCookie.output���sd���������t�z�z�|�|�$�$���� 7�� 7�J�C���M�M�%�,�,�u�f�5�5�6�6�6�6��x�x����r ���c������������������������g�}t����������|������������������������������������������������}|D�]1\��}}|���������������������|�dt����������|j������������������������������������2d|�j��������j���������dt����������|�������������d�S�)Nr����r����r����r����)r����r����r(����reprrx���r����r ���� _spacejoin)rq����lr����rr���rx���s��� r���r����zBaseCookie.__repr__���s���������t�z�z�|�|�$�$���� 9�� 9�J�C�� �H�H����T�%�+�%6�%6�%6�7�8�8�8�8� 9�!�^�4�4�4�j��m�m�m�m�D�Dr ���c������������������������g�}t����������|������������������������������������������������}|D�]-\��}}|���������������������|���������������������|��������������������������.t ����������|������������S�)z(Return a string suitable for JavaScript.)r����r����r(���r����r,���)rq���r����r����r����rr���rx���s��� r���r����zBaseCookie.js_output��s^���������t�z�z�|�|�$�$���� 2�� 2�J�C���M�M�%�/�/�%�0�0�1�1�1�1��� � � r ���c�����������������������t����������|t����������������������r|����������������������|�������������n|�����������������������������������D�] \��}}||�|<����dS�)z�Load cookies from a string (presumably HTTP_COOKIE) or from a dictionary. Loading cookies from a dictionary 'd' is equivalent to calling: map(Cookie.__setitem__, d.keys(), d.values()) N)r����r����_BaseCookie__parse_stringr����)rq����rawdatarr���rx���s��� r���r����zBaseCookie.load ��sZ��������g�s�#�#�� "�����(�(�(�(��&�m�m�o�o�� "�� "� ��U�!��S� � ��r ���c����������������������d}t����������|������������}g�}d}d}d}d|cxk����r|k������rVn��nR|���������������������||������������} | s�n8| ���������������������d������������| ���������������������d������������}} | ���������������������d������������}| d���������dk����r$|s�z|���������������������|| dd�����������|f�������������n�| �����������������������������������t����������j��������v�rg|sd�S�|�;| �����������������������������������t����������j��������v�r|���������������������|| df�������������nZd�S�|���������������������|| t����������|������������f�������������n2|�.|���������������������|| |�� ��������������������|������������f�������������d}nd�S�d|cxk����r|k�������Pn�d�}|D�]B\��} } }| |k����r |�J��||| <����| |k����sJ��|\��}}|����������������������| ||�������������|�| ���������}�Cd�S�) Nr���Fr!���r���rr���r�����$T)r$����match�group�endr(���r}���rY���rn���r����r3���r����r����)rq���r����pattr-���r����parsed_items�morsel_seen�TYPE_ATTRIBUTE� TYPE_KEYVALUEr����rr���rx���r�����tpr����r����s��� r����__parse_stringzBaseCookie.__parse_string��s-����� ����H�H��������� � ��1�j�j�j�j�q�j�j�j�j�j��J�J�s�A�&�&�E��� �����U�+�+�U�[�[��-?�-?��C�� � �!���A��1�v��}�}�"������#�#�^�S����W�e�$D�E�E�E�E������� 0�0�0�"����F��=��y�y�{�{�f�m�3�3�$�+�+�^�S�$�,G�H�H�H�H���� �'�'���h�u�o�o�(N�O�O�O�O��"��#�#�]�C��9J�9J�5�9Q�9Q�$R�S�S�S�"������E��1�j�j�j�j�q�j�j�j�j�J� ��*�� �� �N�B��U��^�#�#��}�}�}���#����]�*�*�*�*�"� ��d�� � �3��d�+�+�+���I��� �� r ���ru���)Nr����r����)r ���r ���r���r����r����r����rs���r����rp���r����r����r����r����r�����_CookiePatternr����r���r ���r���r���r������s���������������1�1������������������'��'��'�(��(��(� �� �� �� ���G�E��E��E�!��!��!��!�������(6��:��:��:��:��:��:r ���r���c�������������������������e�Zd�ZdZd��Zd��ZdS�)r���z� SimpleCookie supports strings as cookie values. When setting the value using the dictionary assignment notation, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings. c������������������$�����t����������|������������|fS�ru���)r3���r����s��� r���r����zSimpleCookie.value_decode_��s��������}�}�c�!�!r ���c������������������B�����t����������|������������}|t����������|������������fS�ru���)r���r���r����s��� r���r����zSimpleCookie.value_encodeb��s�������S�����v�f�~�~�%�%r ���N)r ���r ���r���r����r����r����r���r ���r���r���r���X��s<�����������������"��"��"�&��&��&��&��&r ���r���))r�����re�stringr�����__all__r����r,���r����r����� Exceptionr���� ascii_letters�digits�_LegalChars�_UnescapedCharsr�����range�map�ordr���r�����compile�escape� fullmatchr���r���r%���r'���r3����_weekdayname� _monthnamerW���ro���rY����_LegalKeyChars�_LegalValueChars�ASCII�VERBOSEr����r���r���r���r ���r����<module>r�������s�����NX��X�z� � � � �� � � � ������ 7� 7� 7���G� ���� �X� � �� �� �� �� �)�� �� �� �"��"�V�]�2�5G�G����/��J��J���E�E�#�J�J���#�#�c�c�#��.G�.G�*H�*H�H�J��J��J���������C��H�H�e��C��I�I�v�������� ��� �7�Y�R�Y�{�%;�%;�;�<�<�F� � 6�� 6�� 6���R�Z�,� -� -� � �R�Z�� !� !� �)��)��)�d�A�@�@��8��8��8� ���<�:��F��F��F��F�i8��i8��i8��i8��i8�T��i8��i8��i8�j�B��!�G�+������� ���� � ������"� ��B�J� �# �� ��.I��I��I��I��I���I��I��I�X&��&��&��&��&�:��&��&��&��&��&r ���