ok
Direktori : /proc/thread-self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/ |
Current File : //proc/thread-self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/cookies.cpython-39.pyc |
a ���eP � @ sZ d Z ddlZddlZddlZg d�ZdjZdjZdjZG dd� de �Z ejej d Z e d Zdd� eed ��eeee�� D �Ze�ed�ded�di� e�de�e � �jZdd� Ze�d�Ze�d�Zdd� Zg d�Zg d�Zdeefdd�ZG dd� de �Z!dZ"e"d Z#e�d!e" d" e# d# ej$ej%B �Z&G d$d%� d%e �Z'G d&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 @ s e Zd ZdS )r N)�__name__� __module__�__qualname__� r r �1/opt/alt/python39/lib64/python3.9/http/cookies.pyr � s r z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}c C s i | ]}|d | �qS )z\%03or )�.0�nr r r � <dictcomp>� s �r � �"�\"�\z\\z[%s]+c C s* | du st | �r| S d| �t� d S dS )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��strr r r �_quote� s r z\\[0-3][0-7][0-7]z[\\].c C sN | d u st | �dk r| S | d dks0| d dkr4| S | dd� } d}t | �}g }d| krf|k �rFn n�t�| |�}t�| |�}|s�|s�|�| |d � � �qFd }}|r�|�d�}|r�|�d�}|�r|r�||k �r|�| ||� � |�| |d � |d }qP|�| ||� � |�tt| |d |d � d��� |d }qPt|�S )N� r r ���� � � ) �len� _OctalPatt�search� _QuotePatt�append�start�chr�int� _nulljoin)r �ir �resZo_matchZq_match�j�kr r r �_unquote� s6 $ r+ )ZMonZTueZWedZThuZFriZSatZSun) NZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc C sR ddl m}m } |� }||| �\ }}}} } }}} }d|| ||| || | |f S )Nr )�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r- r, )ZfutureZweekdaynameZ monthnamer, r- ZnowZyearZmonthZdayZhhZmmZssZwd�y�zr r r �_getdate� s �r0 c @ s� e Zd ZdZdddddddd d d� Zdd hZdd� Zedd� �Zedd� �Z edd� �Z dd� Zd2dd�Zdd� Z ejZdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd3d*d+�ZeZd,d-� Zd4d.d/�Zd5d0d1�Zeej�ZdS )6�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�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite) r2 �path�commentZdomain�max-age�secure�httponly�versionZsamesiter8 r9 c C s0 d | _ | _| _| jD ]}t�| |d� qd S )Nr )�_key�_value�_coded_value� _reserved�dict�__setitem__)�self�keyr r r �__init__! s zMorsel.__init__c C s | j S �N)r; �rA r r r rB ) s z Morsel.keyc C s | j S rD )r<