Your IP : 3.12.71.166


Current Path : /opt/alt/python310/lib64/python3.10/http/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/http/__pycache__/cookiejar.cpython-310.opt-2.pyc

o

6��fg.�@s�	gd�ZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZddl
mZdZdadd�ZdZdZeejj�Ze�d	�Zd
ZdZdd
�ZdZdd�Zgd�Zgd�Z gZ!e D]	Z"e!�#e"�$��q`dhdd�Z%dhdd�Z&ddddd�Z'e�dej(�Z)dd�Z*dd�Z+e�dej(�Z,e�dej-ej(B�Z.e�dej/ej(B�Z0d d!�Z1e�d"ej/ej(B�Z2d#d$�Z3d%d&�Z4e�d'�Z5e�d(�Z6e�d)�Z7e�d*�Z8d+d,�Z9e�d-�Z:d.d/�Z;d0d1�Z<d2d3�Z=e�d4ej(�Z>d5d6�Z?d7d8�Z@d9d:�ZAd;d<�ZBe�d=ej(�ZCd>d?�ZDd@dA�ZEdBdC�ZFdDdE�ZGdFZHe�dG�ZIdHdI�ZJdJdK�ZKdLdM�ZLdNdO�ZMGdPdQ�dQ�ZNGdRdS�dS�ZOGdTdU�dUeO�ZPdVdW�ZQdXdY�ZRGdZd[�d[�ZSGd\d]�d]�ZTGd^d_�d_eU�ZVGd`da�daeT�ZWdbdc�ZXGddde�deeW�ZYGdfdg�dgeW�ZZdS)i)�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|�d�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�5/opt/alt/python310/lib64/python3.10/http/cookiejar.py�_debug,s

rZHTTPOnlyz
#HttpOnly_z#( Netscape)? HTTP Cookie FilezQa filename was not supplied (nor was the CookieJar instance initialised with one)zr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCsJddl}ddl}ddl}|��}|�d|�|��}|jd|dd�dS)Nr	zhttp.cookiejar bug!
%s�)�
stacklevel)�io�warnings�	traceback�StringIO�	print_exc�getvalue�warn)rrr�f�msgrrr�_warn_unhandled_exceptionBs
ri�cCs�|dd�\}}}}}}|tkrTd|krdkrTndSd|kr'dkrTndSd|kr4dkrTndSd|krAdkrTndSd|krQdkrTt|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmQs�����r,)ZMonZTueZWedZThuZFriZSatZSun)ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCsB	|durtj��}ntj�|�}d|j|j|j|j|j|jfS)Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second��tZdtrrr�	time2isoz_s�r5cCsT	|durtj��}ntj�|�}dt|��|jt|jd|j|j	|j
|jfS)Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2r3rrr�
time2netscapers
�r8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsld}|tvr
d}|St�|�}|r4dt|�d��}|�d�r*|dt|�d��}|�d�dkr4|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s	
�
rFc
Cs�t|�}|tjkrdSzt�|���d}Wn/tyEzt|�}Wnty.YYdSwd|kr9dkr@nYdS|}nYdSYnw|durLd}|durRd}|durXd}t|�}t|�}t|�}t|�}|dkr�t�t���d}|d}	|}
|||	}|	|
}	t	|	�dkr�|	dkr�|d}n|d}t
|||||||f�}|dur�|dur�d}|��}t|�}|dur�dS||}|S)Nrr r	i��d�2r9)
rAr-ZMAXYEAR�MONTHS_LOWER�index�lower�
ValueError�time�	localtime�absr,�upperrF)
r0�mon�yr�hrr*r+rCZimonZcur_yrrE�tmpr4rDrrr�	_str2time�sV
����rUzV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$z+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*a�^
    (\d\d?)            # day
       (?:\s+|[-\/])
    (\w+)              # month
        (?:\s+|[-\/])
    (\d+)              # year
    (?:
          (?:\s+|:)    # separator before clock
       (\d\d?):(\d\d)  # hour:min
       (?::(\d\d))?    # optional seconds
    )?                 # optional clock
       \s*
    (?:
       ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
       \s*
    )?
    (?:
       \(\w+\)         # ASCII representation of timezone in parens.
       \s*
    )?$cCs�	t�|�}|r7|��}t�|d���d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|�	�}t
�d|d�}dgd\}}}}}}	}
t�|�}|durc|��\}}}}}}	}
ndSt
||||||	|
�S)	Nrrr	r;����)�STRICT_DATE_REr@�groupsrIrJrKrA�floatr,�lstrip�
WEEKDAY_RE�sub�LOOSE_HTTP_DATE_RErU)�textrE�grQr&r0rRrSr*r+rCrrr�	http2time�s"
�
rca�^
    (\d{4})              # year
       [-\/]?
    (\d\d?)              # numerical month
       [-\/]?
    (\d\d?)              # day
   (?:
         (?:\s+|[-:Tt])  # separator before clock
      (\d\d?):?(\d\d)    # hour:min
      (?::?(\d\d(?:\.\d*)?))?  # optional seconds (and fractional)
   )?                    # optional clock
      \s*
   (?:
      ([-+]?\d\d?:?(:?\d\d)?
       |Z|z)             # timezone  (Z is "zero meridian", i.e. GMT)
      \s*
   )?$c
Csf	|��}dgd\}}}}}}}t�|�}|dur'|��\}}}}}}}}	ndSt|||||||�S)NrY)r]�ISO_DATE_REr@r[rU)
rar0rQrRrSr*r+rCrE�_rrr�iso2time3s
rfcCs,	|�d�\}}|jd|�|j|d�S)Nr	)�span�string)�match�start�endrrr�	unmatchedTsrlz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Cs	g}|D]{}|}g}|ryt�|�}|rSt|�}|�d�}t�|�}|r4t|�}|�d�}t�d|�}nt�|�}|rIt|�}|�d�}|��}nd}|�	||f�n$|�
��d�rl|�
�dd�}|ri|�	|�g}nt�
dd|�\}}	|}|s
|r�|�	|�q|S)Nrz\1�,z^[=\s;]*rX)�HEADER_TOKEN_REr@rlrB�HEADER_QUOTED_VALUE_RE�HEADER_ESCAPE_REr_�HEADER_VALUE_RE�rstrip�appendr]�
startswith�re�subn)
Z
header_values�resultraZ	orig_text�pairsrE�name�valueZnon_junkZ
nr_junk_charsrrr�split_header_words]s@-






� �r{�([\"\\])cCs~	g}|D]4}g}|D]#\}}|dur)t�d|�s#t�d|�}d|}d||f}|�|�q|r9|�d�|��qd�|�S)Nz^\w+$�\\\1z"%s"�%s=%s�; �, )rur@�HEADER_JOIN_ESCAPE_REr_rs�join)Zlists�headersrx�attr�k�vrrr�join_header_words�s�
r�cCs0|�d�r|dd�}|�d�r|dd�}|S)N�"r���)rt�endswith�rarrr�strip_quotes�s


r�cCs�	d}g}|D]s}g}d}t|�d��D]W\}}|��}|�d�\}}	}
|��}|s1|dkr0n<q|	r7|
��nd}
|dkrd|��}||vrG|}|dkrV|
durSt|
�}
d}n|dkrd|
durdtt|
��}
|�||
f�q|rz|su|�d	�|�|�q|S)
N)�expires�domain�path�secure�version�port�max-ageF�;�=r	r�Tr�)r��0)�	enumerate�split�strip�	partitionrKr�rcrs)Z
ns_headersZknown_attrsrwZ	ns_headerrx�version_setZiiZparam�key�sep�val�lcrrr�parse_ns_headers�sB

�r�z\.\d+$cCs<	t�|�rdS|dkrdS|ddks|ddkrdSdS)NFrXr	�.r�T��IPV4_REr@r�rrr�is_HDNs
r�cCsn	|��}|��}||krdSt|�sdS|�|�}|dks"|dkr$dS|�d�s+dSt|dd��s5dSdS)NTFr�r	r�r)rKr��rfindrt)�A�B�irrr�domain_match's

r�cCs	t�|�rdSdS�NFTr�r�rrr�liberal_is_HDNNs
r�cCsb	|��}|��}t|�rt|�s||krdSdS|�d�}|r'|�|�r'dS|s/||kr/dSdS)NTFr�)rKr�rtr�)r�r��initial_dotrrr�user_domain_matchXs
r�z:\d+$cCsD	|��}tj�|�d}|dkr|�dd�}t�d|d�}|��S)NrrXZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer_rK)�request�url�hostrrr�request_hostmsr�cCs6	t|�}}|�d�dkrt�|�s|d}||fS)Nr�r��.local)r��findr�r@)r��erhn�req_hostrrr�eff_request_host}s
r�cCs6	|��}tj�|�}t|j�}|�d�sd|}|S)N�/)r�r�r�Zurlsplit�escape_pathr�rt)r�r��partsr�rrr�request_path�s

r�cCs^|j}|�d�}|dkr+||dd�}zt|�W|Sty*td|�YdSwt}|S)N�:r	rznonnumeric port: '%s')r�r�rArLr�DEFAULT_HTTP_PORT)r�r�r�r�rrr�request_port�s

�
�r�z%/;:@&=+$,!~*'()z%([0-9a-fA-F][0-9a-fA-F])cCsd|�d���S)Nz%%%sr)rBrP)rirrr�uppercase_escaped_char�sr�cCs 	tj�|t�}t�t|�}|S�N)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr_r�)r�rrrr��s	r�cCsR	|�d�}|dkr'||dd�}|�d�}t|�r'|dks#|dkr'd|S|S)Nr�r	rZlocal)r�r�)�hr��brrr�reach�s

r�cCs"	t|�}t|t|j��sdSdS�NTF)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
	r�c@sNeZdZ		ddd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Zdd�Z	dS)rFcCs�|durt|�}|durtt|��}|dur|durtd��||_||_||_||_||_|��|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_t�|�|_dS)NTz-if port is None, port_specified must be false)rAr\rLr�ryrzr��port_specifiedrKr��domain_specified�domain_initial_dotr��path_specifiedr�r��discard�comment�comment_url�rfc2109�copy�_rest)�selfr�ryrzr�r�r�r�r�r�r�r�r�r�r�r��restr�rrr�__init__�s*

zCookie.__init__cCs
||jvSr��r�)r�ryrrr�has_nonstandard_attr$�
zCookie.has_nonstandard_attrNcCs|j�||�Sr�)r��get)r�ry�defaultrrr�get_nonstandard_attr&�zCookie.get_nonstandard_attrcCs||j|<dSr�r�)r�ryrzrrr�set_nonstandard_attr(r�zCookie.set_nonstandard_attrcCs,|durt��}|jdur|j|krdSdSr�)rMr�)r��nowrrr�
is_expired+szCookie.is_expiredcCsX|jdurd}nd|j}|j||j}|jdur#d|j|jf}n|j}d||fS)NrXr�r~z<Cookie %s for %s>)r�r�r�rzry)r��p�limitZ	namevaluerrr�__str__1s

zCookie.__str__cCslg}dD]}t||�}|�d|t|�f�q|�dt|j��|�dt|j��d|jjd�|�fS)N)r�ryrzr�r�r�r�r�r�r�r�r�r�r�r�r~zrest=%sz
rfc2109=%sz%s(%s)r�)�getattrrs�reprr�r��	__class__�__name__r�)r�rryr�rrr�__repr__;s
zCookie.__repr__)Fr�)
r��
__module__�__qualname__r�r�r�r�r�r�r�rrrrr�s
�*


rc@s.eZdZ	dd�Zdd�Zdd�Zdd�Zd	S)
rcC�	t��r���NotImplementedError�r��cookier�rrr�set_okSszCookiePolicy.set_okcCr�r�r�r�rrr�	return_ok\�zCookiePolicy.return_okcC�	dS�NTr)r�r�r�rrr�domain_return_ok`�zCookiePolicy.domain_return_okcCr�r�r)r�r�r�rrr�path_return_oker�zCookiePolicy.path_return_okN)r�r�r�r�r�r�r�rrrrrJs	rc
@s�eZdZ	dZdZdZdZeeBZdddddddddedddf
d	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�ZdS)7rrrrVr	NTF)ZhttpsZwsscCsx	||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|dur,t|�|_nd|_|dur7t|�}||_
dS)Nr)�netscape�rfc2965�rfc2109_as_netscape�hide_cookie2�
strict_domain�strict_rfc2965_unverifiable�strict_ns_unverifiable�strict_ns_domain�strict_ns_set_initial_dollar�strict_ns_set_path�secure_protocols�tuple�_blocked_domains�_allowed_domains)r��blocked_domains�allowed_domainsr�r�r�r�r�r�r�rrrrrrrr�us$

zDefaultCookiePolicy.__init__cC�	|jSr�)r�r�rrrr�r�z#DefaultCookiePolicy.blocked_domainscCs	t|�|_dSr�)rr)r�rrrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs |jD]
}t||�r
dSqdSr�)rr�)r�r�Zblocked_domainrrr�
is_blocked�s


�zDefaultCookiePolicy.is_blockedcCr	r�)rr
rrrr�r�z#DefaultCookiePolicy.allowed_domainscCs	|dur	t|�}||_dSr�)rr)r�rrrr�set_allowed_domains�s
z'DefaultCookiePolicy.set_allowed_domainscCs.|jdurdS|jD]
}t||�rdSq
dSr�)rr�)r�r�Zallowed_domainrrr�is_not_allowed�s


�z"DefaultCookiePolicy.is_not_allowedcC�B	td|j|j�dD]}d|}t||�}|||�sdSqdS)N� - checking cookie %s=%s)r��
verifiabilityryr�r�r�Zset_ok_FT�rryrzr��r�r�r��nZfn_name�fnrrrr��s

�zDefaultCookiePolicy.set_okcCsZ|jdurtd|j|j�dS|jdkr|jstd�dS|jdkr+|js+td�dSdS)Nz0   Set-Cookie2 without version attribute (%s=%s)Fr	�$   RFC 2965 cookies are switched off�$   Netscape cookies are switched offT)r�rryrzr�r�r�rrr�set_ok_version�s
�z"DefaultCookiePolicy.set_ok_versioncC�J|jr#t|�r#|jdkr|jrtd�dS|jdkr#|jr#td�dSdS�Nr	z>   third-party RFC 2965 cookie during unverifiable transactionFz>   third-party Netscape cookie during unverifiable transactionT�Zunverifiabler�r�r�rr�r�rrr�set_ok_verifiability��z(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr|jr|j�d�rtd|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�rryrtrr�rrr�set_ok_name�s
�zDefaultCookiePolicy.set_ok_namecCsL|jr$t|�}|jdks|jdkr$|jr$|�|j|�s$td|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�rr�r�r)r�r�r��req_pathrrr�set_ok_path�s
��zDefaultCookiePolicy.set_ok_pathc
Cs�|�|j�rtd|j�dS|�|j�rtd|j�dS|jr�t|�\}}|j}|jre|�d�dkre|�d�}|�dd|�}|dkre||dd�}||d|�}	|	�	�dvret
|�dkretd	|�dS|�d�rq|dd�}
n|}
|
�d�dk}|s�|d
kr�td|�dS|j
dkr�|�|�s�|�d�s�d|�|�s�td||�dS|j
dks�|j|j@r�t||�s�td
||�dS|j
dks�|j|j@r�|dt
|��}|�d�dkr�t�|�s�td||�dSdS)N�"   domain %s is in user block-listF�&   domain %s is not in user allow-listr�rr	r)�coZacZcomZeduZorgZnetZgovZmilrAZaeroZbiz�catZcoop�infoZjobsZmobiZmuseumryZproZtravelZeuz&   country-code second level domain %sr�z/   non-local domain %s contains no embedded dotzO   effective request-host %s (even with added initial dot) does not end with %sz5   effective request-host %s does not domain-match %sz.   host prefix %s for domain %s contains a dotT)rr�rrr�r�r��countr�rK�lenrtr�r�r�r�DomainRFC2965Matchr��DomainStrictNoDotsr�r@)
r�r�r�r�r�r�r��jZtldZsldZundotted_domainZ
embedded_dotsZhost_prefixrrr�
set_ok_domain�st


�

���

�
�

���z!DefaultCookiePolicy.set_ok_domainc	Cs�|jrBt|�}|durd}nt|�}|j�d�D] }zt|�Wnty0td|�YdSw||kr8dSqtd||j�dSdS)N�80rmz   bad port %s (not numeric)Fz$   request port (%s) not found in %sT)r�r��strr�r�rArLr�r�r�r�Zreq_portr�rrr�set_ok_port3s*
���zDefaultCookiePolicy.set_ok_portcCr)Nr)r�rr�r�r�r�Z
return_ok_FTrrrrrr�Hs

�zDefaultCookiePolicy.return_okcCs<|jdkr|jstd�dS|jdkr|jstd�dSdS)Nr	rFrT)r�r�rr�r�rrr�return_ok_versionZsz%DefaultCookiePolicy.return_ok_versioncCrrrr�rrr�return_ok_verifiabilitycrz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jvrtd�dSdS)Nz(   secure cookie with non-secure requestFT)r��typerrr�rrr�return_ok_secureosz$DefaultCookiePolicy.return_ok_securecCs|�|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowrr�rrr�return_ok_expiresusz%DefaultCookiePolicy.return_ok_expirescCsP|jr&t|�}|dur
d}|j�d�D]	}||krdSqtd||j�dSdS)Nr-rmz0   request port %s does not match cookie port %sFT)r�r�r�rr/rrr�return_ok_port{s��z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r|�d�sd|}n|}|jdkr/|j|j@r/|js/||kr/td�dS|jdkrAt||�sAtd||�dS|jdkrUd|�	|�sUtd||�dSdS)Nr�r	zQ   cookie with unspecified domain does not string-compare equal to request domainFzQ   effective request-host name %s does not domain-match RFC 2965 cookie domain %sz;   request-host %s does not match Netscape cookie domain %sT)
r�r�rtr�r�DomainStrictNonDomainr�rr�r�)r�r�r�r�r�r��	dotdomainrrr�return_ok_domain�s0


����z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|�d�sd|}|�d�sd|}|r$|�d�s$d|}n|}|�|�s2|�|�s2dS|�|�r>td|�dS|�|�rJtd|�dSdS)Nr�Fr"r#T)r�rtr�rrr)r�r�r�r�r�r9rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCsbtd|�t|�}t|�}||krdS|�|�r)|�d�s'|||d�dkr)dStd||�dS)Nz- checking cookie path=%sTr�rz  %s does not path-match %sF)rr�r(rtr�)r�r�r�r Zpathlenrrrr��s

�z"DefaultCookiePolicy.path_return_ok)r�r�r�r*r8r)Z
DomainLiberalZDomainStrictr�rrrrr
rr�rrrr!r,r0r�r1r2r4r6r7r:r�r�rrrrrksR
�#	;	rcCst|���}t|j|�Sr�)�sorted�keys�mapr�)Zadictr<rrr�vals_sorted_by_key�sr>c	csX�	t|�}|D]!}d}z|jWn	tyYn
wd}t|�EdH|s)|VqdSr�)r>�items�AttributeError�
deepvalues)�mapping�values�objrrrrA�s �
���rAc@�eZdZdS)�AbsentN�r�r�r�rrrrrF��rFc@s�eZdZ	e�d�Ze�d�Ze�d�Ze�d�Ze�d�Z	e�dej
�Zd2dd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd3d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Z dS)4rz\Wr|z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|durt�}||_t��|_i|_dSr�)r�_policy�
_threading�RLock�
_cookies_lock�_cookies�r��policyrrrr��s


zCookieJar.__init__cCs
||_dSr�)rIrNrrr�
set_policy�r�zCookieJar.set_policycCs�g}|j�||�sgStd|�|j|}|��D]*}|j�||�s#q||}|��D]}|j�||�s9td�q+td�|�|�q+q|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	rIr�rrMr<r�rCr�rs)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s"

�zCookieJar._cookies_for_domaincCs,	g}|j��D]}|�|�||��q|Sr�)rMr<�extendrR)r�r�rQr�rrr�_cookies_for_requests
zCookieJar._cookies_for_requestc	Cs8	|jdd�dd�d}g}|D]�}|j}|s$d}|dkr$|�d|�|jdur=|j�|j�r=|dkr=|j�d|j�}n|j}|jdurL|�|j�n
|�d	|j|f�|dkr�|j	re|�d
|j
�|j�d�r�|j}|j
s||�d�r||dd�}|�d
|�|jdur�d}|jr�|d|j}|�|�q|S)NcS�
t|j�Sr�)r(r�)�arrr�<lambda> s
z)CookieJar._cookie_attrs.<locals>.<lambda>T)r��reverseFr	z$Version=%sr}r~z
$Path="%s"r�rz$Domain="%s"z$Portz="%s")�sortr�rsrz�non_word_rer@�quote_rer_ryr�r�r�rtr�r�r�)	r�rQr��attrsr�r�rzr�r�rrr�
_cookie_attrssH	
�
�

�zCookieJar._cookie_attrscCs�	td�|j��zKtt���|j_|_|�|�}|�|�}|r0|�	d�s0|�
dd�|��|jjrO|jj
sO|�	d�sO|D]}|jdkrN|�
dd�nq?W|j��n|j��w|��dS)N�add_cookie_headerrrZCookie2rz$Version="1")rrL�acquirerArMrIr5rTr]Z
has_headerZadd_unredirected_headerr�r�r�r��release�clear_expired_cookies)r�r�rQr\r�rrrr^Qs.




��
��zCookieJar.add_cookie_headerc
Csv	g}d}d}|D]�}|d\}}d}d}	i}
i}|dd�D]�\}}
|��}||vs/||vr1|}||vr;|
dur;d}
||
vr@q|dkrT|
durPtd�d}	n\|
��}
|d	krd|r[q|
durdtd
�q|dkr�d}zt|
�}
Wnty�td�d}	Yn,wd	}|j|
}
||vs�||vr�|
dur�|d
vr�td|�d}	n
|
|
|<q|
||<q|	r�q	|�|||
|f�q	|S)N)r�r�)r�r�r�r�r�r�r��
commenturlr	FrTr�z%   missing value for domain attributer�zM   missing or invalid value for expires attribute: treating as session cookier�z?   missing or invalid (non-numeric) value for max-age attribute)r�r�rbz!   missing value for %s attribute)rKrrArLr5rs)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsryrzZmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuplesrsj
�	


z#CookieJar._normalized_cookie_tuplescCs|\}}}}|�dt�}|�dt�}|�dt�}	|�dt�}
|�dd�}|dur9zt|�}Wn
ty8YdSw|�dd�}|�dd�}
|�d	d�}|�d
d�}|tur`|dkr`d}t|�}n*d}t|�}|�d
�}|dkr�|dkrz|d|�}n|d|d�}t|�dkr�d
}|tu}d}|r�t|�	d��}|tur�t
|�\}}|}n	|�	d�s�d|}d}|	tur�|	dur�t|�}	nd}t�
dd|	�}	nd}	|
tur�d}
d}
n!|
|jkr�z	|�|||�Wn	ty�Ynwtd|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rbrXTr�r�r	rr�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r�rFrArLr�r�r�r(�boolrtr�r�rur_r5�clear�KeyErrorrr)r��tupr�ryrzrgr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�_cookie_from_cookie_tuple�s��




���z#CookieJar._cookie_from_cookie_tuplecCs6|�|�}g}|D]}|�||�}|r|�|�q	|Sr�)rhrmrs)r�rcr�rdrQrlr�rrr�_cookies_from_attrs_set/s
�z!CookieJar._cookies_from_attrs_setcCsHt|jdd�}|dur|jj}|D]}|jdkr!d|_|r!d|_qdS)Nr�rTr	)r�rIr�r�r�)r�rQZ
rfc2109_as_nsr�rrr�_process_rfc2109_cookies8s

��z"CookieJar._process_rfc2109_cookiesc
Cs0	|��}|�dg�}|�dg�}tt���|j_|_|jj}|jj}|s(|r4|s,|r4|s0|r4|s6|s6gSz
|�t	|�|�}Wnt
yNt�g}Ynw|r�|r�z
|�t|�|�}	Wnt
ykt�g}	Ynw|�
|	�|r�i}
|D]}d|
|j|j|jf<qw|
fdd�}t||	�}	|	r�|�|	�|S)NzSet-Cookie2z
Set-CookiecSs|j|j|jf}||vSr�)r�r�ry)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965qsz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)r&Zget_allrArMrIr5r�r�rnr{�	Exceptionrr�ror�r�ry�filterrS)
r��responser�r�Zrfc2965_hdrsZns_hdrsr�r�rQZ
ns_cookiesrpr�rqrrr�make_cookiesDs`����������


zCookieJar.make_cookiescCsh	|j��z'tt���|j_|_|j�||�r&|�|�W|j��dSW|j��dS|j��wr�)	rLr_rArMrIr5r��
set_cookier`r�rrr�set_cookie_if_ok{s
�zCookieJar.set_cookie_if_okcCsv	|j}|j��z+|j|vri||j<||j}|j|vr#i||j<||j}|||j<W|j��dS|j��wr�)rMrLr_r�r�ryr`)r�r��cZc2Zc3rrrrv�s


zCookieJar.set_cookiecCsl	td|���|j��z"|�||�D]}|j�||�r'td|�|�|�qW|j��dS|j��w)Nzextract_cookies: %sz setting cookie: %s)	rr&rLr_rurIr�rvr`)r�rtr�r�rrr�extract_cookies�s


��zCookieJar.extract_cookiescCs|	|dur|dus
|durtd��|j|||=dS|dur/|dur'td��|j||=dS|dur9|j|=dSi|_dS)Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLrM)r�r�r�ryrrrrj�s ��
zCookieJar.clearcCsN	|j��z|D]}|jr|�|j|j|j�q	W|j��dS|j��wr�)rLr_r�rjr�r�ryr`)r�r�rrr�clear_session_cookies�s
��zCookieJar.clear_session_cookiescCsZ	|j��z t��}|D]}|�|�r|�|j|j|j�q
W|j��dS|j��wr�)	rLr_rMr�rjr�r�ryr`)r�r�r�rrrra�s
	
��zCookieJar.clear_expired_cookiescCrUr�)rArMr
rrr�__iter__�r�zCookieJar.__iter__cCs	d}|D]}|d}q|S)Nr	rr)r�r�r�rrr�__len__�szCookieJar.__len__cC�2g}|D]	}|�t|��qd|jjd�|�fS�Nz<%s[%s]>r�)rsr�r�r�r��r��rr�rrrr���zCookieJar.__repr__cCr}r~)rsr.r�r�r�rrrrr��r�zCookieJar.__str__r�)NNN)!r�r�r�ru�compilerZr[Zstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�rPrRrTr]r^rhrmrnrorurwrvryrjrzrar{r|r�r�rrrrr�s:





;!a\	7

rc@rE)rNrGrrrrr�rHrc@s:eZdZ	ddd�Zddd�Zddd�Z		dd	d
�ZdS)
rNFcCs4	t�||�|durt�|�}||_t|�|_dSr�)rr��os�fspath�filenameri�	delayload)r�r�r�rOrrrr��s
zFileCookieJar.__init__cCr�r�r�)r�r��ignore_discard�ignore_expiresrrr�saver�zFileCookieJar.savecCsb	|dur|jdur|j}ntt��t|��}|�||||�Wd�dS1s*wYdSr�)r�rL�MISSING_FILENAME_TEXT�open�_really_load�r�r�r�r�rrrr�loads
"�zFileCookieJar.loadcCs�	|dur|jdur|j}ntt��|j��z&t�|j�}i|_z	|�|||�Wnt	y5||_�wW|j�
�dS|j�
�wr�)r�rLr�rLr_r�ZdeepcopyrMr��OSErrorr`)r�r�r�r�Z	old_staterrr�reverts 
��zFileCookieJar.revert)NFN�NFF)r�r�r�r�r�r�r�rrrrr�s


	�rcCs"	|j|jfd|jfd|jfg}|jdur|�d|jf�|jr%|�d�|jr-|�d�|jr5|�d�|j	r=|�d�|j
rL|�dtt|j
��f�|j
rT|�d	�|jr_|�d
|jf�|jrj|�d|jf�t|j���}|D]}|�|t|j|�f�qs|�dt|j�f�t|g�S)
Nr�r�r�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)r�Nr�rbr�)ryrzr�r�r�rsr�r�r�r�r�r5r\r�r�r�r;r�r<r.r�r�)r�r�r<r�rrr�lwp_cookie_str,s*
��
r�c@s*eZdZ	d
dd�Zddd�Zdd	�ZdS)rTcCsV	t��}g}|D]}|s|jrq	|s|�|�rq	|�dt|��q	d�|dg�S)NzSet-Cookie3: %s�
rX)rMr�r�rsr�r�)r�r�r�r�r�r�rrr�
as_lwp_strUs
zLWPCookieJar.as_lwp_strNFcCsn|dur|jdur
|j}ntt��t|d��}|�d�|�|�||��Wd�dS1s0wYdS)N�wz#LWP-Cookies-2.0
)r�rLr�r��writer�r�rrrr�es
"�zLWPCookieJar.savecCs
|��}|j�|�sd|}t|��t��}d}d}	d}
z�	|��}|dkr)WdS|�|�s/q|t|�d���}t|g�D]�}|d\}
}i}i}|	D]}d||<qL|dd�D]5\}}|durf|�	�}nd}||
vsp||	vrr|}||	vr�|dur|d	}|||<qY||
vr�|||<qY|||<qY|j
}|d
�}|d�}|dur�t|�}|dur�d	}|d�}|�d
�}t|d�|
||d�|d�|||d�|d�|d�|d�|||d�|d�|�}|s�|j
r�q>|s�|�|�r�q>|�|�q>qty��t�yt�td||f��w)Nz5%r does not look like a Set-Cookie3 (LWP) format filezSet-Cookie3:)r�r�r�r�r�)r�r�r�r�r�r�rbrrXr	FTr�r�r�r�r�r�r�r�r�r�r�r�rbz&invalid Set-Cookie3 format file %r: %r)�readliner�r@rrMrtr(r�r{rKr�rfrr�r�rvr�rrr)r�rr�r�r��magicrr��headerrerf�line�dataryrzrgr�r�r�r�r�r�r�r�r�rxrrrr�qs��







�

�5��zLWPCookieJar._really_load)TTr�)r�r�r�r�r�r�rrrrrHs


rc@s eZdZ	dd�Zddd�ZdS)rcCsjt��}t�|���std|��z�	|��}i}|dkr WdS|�t�r1d|t<|tt�d�}|�	d�r<|dd�}|�
��d�sI|�
�dkrJq|�d�\}}	}
}}}
}|dk}|	dk}	|
dkrf|}
d}|�d	�}d
}|dkrud}d}td|
|dd
||	||
d
|||dd|�}|s�|j
r�q|s�|�|�r�q|�|�qty��ty�t�td
||f��w)Nz4%r does not look like a Netscape format cookies filerrXr�r�)�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %r)rM�NETSCAPE_MAGIC_RGXrir�rrt�HTTPONLY_PREFIX�
HTTPONLY_ATTRr(r�r�r�rr�r�rvr�rrr)r�rr�r�r�r�r�r�r�r�r�r�r�ryrzr�r�rxrrrr��sp��
�
�


�9��zMozillaCookieJar._really_loadNFc

Cs&|dur|jdur
|j}ntt��t|d��s}|�t�t��}|D]^}|j}|s-|jr-q"|s5|�	|�r5q"|j
r;d}nd}|�d�rEd}	nd}	|jdurRt
|j�}
nd}
|jdur_d}|j}n|j}|j}|�t�rnt|}|�d�||	|j||
||g�d�q"Wd�dS1s�wYdS)Nr�r�ZFALSEr�rXr�r�)r�rLr�r�r��NETSCAPE_HEADER_TEXTrMr�r�r�r�rtr�r.rzryr�r�r�r�r�)
r�r�r�r�rr�r�r�r�r�r�ryrzrrrr�)sF




����"�zMozillaCookieJar.saver�)r�r�r�r�r�rrrrr�sIrr�)[�__all__r�r�r-rurMZurllib.parser�Zurllib.requestZ	threadingrJZhttp.clientZhttpZcalendarr
rrrr�r�r.ZclientZ	HTTP_PORTr�r�r�r�r�rr%r,r6r7rIr(rsrKr5r8r>r�r?rFrUrZ�Ir^�Xr`rcrdrfrlrnrorqrpr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr>rArFrr�rrr�rrrrrr�<module>s�	


8��
�8
�!




UD'


#b!b7x

?>