AlkantarClanX12

Your IP : 3.144.6.29


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/cookiejar.cpython-39.opt-2.pyc

a

R�f#,�@s�gd�ZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZddl
mZdZdadd�Zeejj�ZdZdd	�Zd
Zdd�Zgd
�Zgd�ZgZeD]Ze�e���q�dddd�Z dedd�Z!ddddd�Z"e�#dej$�Z%dd�Z&dd�Z'e�#dej$�Z(e�#dej)ej$B�Z*e�#dej+ej$B�Z,dd�Z-e�#dej+ej$B�Z.dd �Z/d!d"�Z0e�#d#�Z1e�#d$�Z2e�#d%�Z3e�#d&�Z4d'd(�Z5e�#d)�Z6d*d+�Z7d,d-�Z8d.d/�Z9e�#d0ej$�Z:d1d2�Z;d3d4�Z<d5d6�Z=d7d8�Z>e�#d9ej$�Z?d:d;�Z@d<d=�ZAd>d?�ZBd@dA�ZCdBZDe�#dC�ZEdDdE�ZFdFdG�ZGdHdI�ZHdJdK�ZIGdLdM�dM�ZJGdNdO�dO�ZKGdPdQ�dQeK�ZLdRdS�ZMdTdU�ZNGdVdW�dW�ZOGdXdY�dY�ZPGdZd[�d[eQ�ZRGd\d]�d]eP�ZSd^d_�ZTGd`da�daeS�ZUGdbdc�dceS�ZVdS)f)�Cookie�	CookieJar�CookiePolicy�DefaultCookiePolicy�
FileCookieJar�LWPCookieJar�	LoadError�MozillaCookieJar�N)�timegmFcGs(tsdStsddl}|�d�atj|�S)Nr	zhttp.cookiejar)�debug�logger�loggingZ	getLogger)�argsr
�r�3/opt/alt/python39/lib64/python3.9/http/cookiejar.py�_debug,s
rzQa filename was not supplied (nor was the CookieJar instance initialised with one)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_exception:s
ri�cCs�|dd�\}}}}}}|tkr�d|kr4dkr�nnhd|krLdkr�nnPd|krddkr�nn8d|kr|dkr�nn d|kr�dkr�nnt|�SdSdS)	N����r	��;�=)�
EPOCH_YEARr
)�tt�year�monthZmday�hour�min�secrrr�_timegmIs 8��
��
��
r,)ZMonZTueZWedZThuZFriZSatZSun)ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|durtj��}ntj�|�}d|j|j|j|j|j|jfS)Nz%04d-%02d-%02d %02d:%02d:%02dZ)	�datetime�utcnow�utcfromtimestampr'r(�dayr)�minute�second��tZdtrrr�	time2isozWs�r5cCsR|durtj��}ntj�|�}dt|��|jt|jd|j|j	|j
|jfS)Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr)r-r.r/�DAYSZweekdayr0�MONTHSr(r'r)r1r2r3rrr�
time2netscapejs�r8)ZGMT�UTCZUT�Zz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tvrd}nTt�|�}|rfdt|�d��}|�d�rR|dt|�d��}|�d�dkrf|}|S)Nr	ir��<r�-)�	UTC_ZONES�TIMEZONE_RE�search�int�group)�tz�offset�mrrr�offset_from_tz_string�s

rFc
Cs�t|�}|tjkrdSzt�|���d}WnZty�zt|�}Wnty\YYdS0d|krrdkr|nn|}nYdSYn0|dur�d}|dur�d}|dur�d}t|�}t|�}t|�}t|�}|dk�r2t�t���d}|d}	|}
|||	}|	|
}	t	|	�dk�r2|	dk�r*|d}n|d}t
|||||||f�}|du�r�|du�r`d}|��}t|�}|du�r~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�sN





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�|�}|rl|��}t�|d���d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|�	�}t
�d|d�}dgd\}}}}}}	}
t�|�}|dur�|��\}}}}}}	}
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
Csd|��}dgd\}}}}}}}t�|�}|durL|��\}}}}}}}}	ndSt|||||||�S)NrY)r]�ISO_DATE_REr@r[rU)
rar0rQrRrSr*r+rCrE�_rrr�iso2time+s

rfcCs*|�d�\}}|jd|�|j|d�S)Nr	)�span�string)�match�start�endrrr�	unmatchedLsrlz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c
Csg}|D]�}|}g}|r�t�|�}|r�t|�}|�d�}t�|�}|rft|�}|�d�}t�d|�}n.t�|�}|r�t|�}|�d�}|��}nd}|�	||f�q|�
��d�r�|�
�dd�}|r�|�	|�g}qt�
dd|�\}}	|}q|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_wordsUs:.






r{�([\"\\])cCs|g}|D]h}g}|D]F\}}|durPt�d|�sDt�d|�}d|}d||f}|�|�q|r|�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]�}g}d}t|�d��D]�\}}|��}|�d�\}}	}
|��}|sb|dkr&q�nq&|	rn|
��nd}
|dkr�|��}||vr�|}|dkr�|
dur�t|
�}
d}n|dkr�|
dur�tt|
��}
|�||
f�q&|r|s�|�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�s>
r�z\.\d+$cCs:t�|�rdS|dkrdS|ddks2|ddkr6dSdS)NFrXr	�.r�T��IPV4_REr@r�rrr�is_HDNs
r�cCsl|��}|��}||krdSt|�s(dS|�|�}|dksB|dkrFdS|�d�sTdSt|dd��shdSdS)NTFr�r	r�r)rKr��rfindrt)�A�B�irrr�domain_matchs

r�cCst�|�rdSdS�NFTr�r�rrr�liberal_is_HDNFs
r�cCs`|��}|��}t|�r t|�s0||kr,dSdS|�d�}|rL|�|�rLdS|s\||kr\dSdS)NTFr�)rKr�rtr�)r�r��initial_dotrrr�user_domain_matchPs
r�z:\d+$cCsB|��}tj�|�d}|dkr,|�dd�}t�d|d�}|��S)NrrXZHost)�get_full_url�urllib�parseZurlparseZ
get_header�cut_port_rer_rK)�request�url�hostrrr�request_hostesr�cCs4t|�}}|�d�dkr,t�|�s,|d}||fS)Nr�r��.local)r��findr�r@)r��erhn�req_hostrrr�eff_request_hostusr�cCs4|��}tj�|�}t|j�}|�d�s0d|}|S)N�/)r�r�r�Zurlsplit�escape_pathr�rt)r�r��partsr�rrr�request_path�s

r�cCs^|j}|�d�}|dkrV||dd�}zt|�WqZtyRtd|�YdS0nt}|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�cCstj�|t�}t�t|�}|S�N)r�r�Zquote�HTTP_PATH_SAFE�ESCAPED_CHAR_REr_r�)r�rrrr��s
r�cCsP|�d�}|dkrL||dd�}|�d�}t|�rL|dksD|dkrLd|S|S)Nr�r	rZlocal)r�r�)�hr��brrr�reach�s

r�cCs$t|�}t|t|j��sdSdSdS�NTF)r�r�r�Zorigin_req_host)r�r�rrr�is_third_party�s
r�c@sJeZdZddd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Zdd�Z	dS)rFcCs�|durt|�}|dur$tt|��}|dur<|dur<td��||_||_||_||_||_|��|_	||_
||_|	|_|
|_
||_||_|
|_||_||_||_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_attrszCookie.has_nonstandard_attrNcCs|j�||�Sr�)r��get)r�ry�defaultrrr�get_nonstandard_attrszCookie.get_nonstandard_attrcCs||j|<dSr�r�)r�ryrzrrr�set_nonstandard_attr szCookie.set_nonstandard_attrcCs,|durt��}|jdur(|j|kr(dSdSr�)rMr�)r��nowrrr�
is_expired#szCookie.is_expiredcCsX|jdurd}n
d|j}|j||j}|jdurFd|j|jf}n|j}d||fS)NrXr�r~z<Cookie %s for %s>)r�r�r�rzry)r��p�limitZ	namevaluerrr�__str__)s

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__3s
zCookie.__repr__)F)N)N)
r��
__module__�__qualname__r�r�r�r�r�r�r�rrrrr�s�
*


rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs
t��dSr���NotImplementedError�r��cookier�rrr�set_okKszCookiePolicy.set_okcCs
t��dSr�r�r�rrr�	return_okTszCookiePolicy.return_okcCsdS�NTr)r�r�r�rrr�domain_return_okXszCookiePolicy.domain_return_okcCsdSr�r)r�r�r�rrr�path_return_ok]szCookiePolicy.path_return_okN)r�r�r�r�r�r�r�rrrrrBs		rc
@s�eZdZdZdZdZdZeeBZdddddddddedddf
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)ZhttpsZwsscCsv||_||_||_||_||_||_|	|_|
|_||_||_	|
|_
|durVt|�|_nd|_|durlt|�}||_
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�r�r�r�r�rrrr�ms"zDefaultCookiePolicy.__init__cCs|jSr�)r��r�rrrr�sz#DefaultCookiePolicy.blocked_domainscCst|�|_dSr�)r�r�)r�rrrr�set_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs |jD]}t||�rdSqdSr�)r�r�)r�r�Zblocked_domainrrr�
is_blocked�s

zDefaultCookiePolicy.is_blockedcCs|jSr�)rrrrrr�sz#DefaultCookiePolicy.allowed_domainscCs|durt|�}||_dSr�)r�r)r�rrrr�set_allowed_domains�sz'DefaultCookiePolicy.set_allowed_domainscCs.|jdurdS|jD]}t||�rdSqdSr�)rr�)r�r�Zallowed_domainrrr�is_not_allowed�s


z"DefaultCookiePolicy.is_not_allowedcCs@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:|js:td�dS|jdkrV|jsVtd�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_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�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�sz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|j�d�r,td|j�dSdS)Nr	�$z'   illegal name (starts with '$'): '%s'FT)r�r�ryrtrr�rrr�set_ok_name�s
�zDefaultCookiePolicy.set_ok_namecCsL|jrHt|�}|jdks(|jdkrH|jrH|�|j|�sHtd|j|�dSdS)Nr	z7   path attribute %s is not a prefix of request path %sFT)r�r�r�r�r�r�r)r�r�r��req_pathrrr�set_ok_path�s
����zDefaultCookiePolicy.set_ok_pathc
Cs�|�|j�rtd|j�dS|�|j�r8td|j�dS|j�r�t|�\}}|j}|jr�|�d�dkr�|�d�}|�dd|�}|dkr�||dd�}||d|�}	|	�	�dvr�t
|�dkr�td	|�dS|�d�r�|dd�}
n|}
|
�d�dk}|�s|d
k�rtd|�dS|j
dk�rX|�|��sX|�d��sXd|�|��sXtd||�dS|j
dk�sr|j|j@�r�t||��s�td
||�dS|j
dk�s�|j|j@�r�|dt
|��}|�d�dk�r�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)rr�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�sv

�

����
��
���z!DefaultCookiePolicy.set_ok_domainc	Cs�|jr�t|�}|durd}nt|�}|j�d�D]>}zt|�Wn ty`td|�YdS0||kr0q�q0td||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_port+s$

�zDefaultCookiePolicy.set_ok_portcCs@td|j|j�dD]&}d|}t||�}|||�sdSqdS)Nr)r�r	r�r�r�r�Z
return_ok_FTr
rrrrr�@s	

zDefaultCookiePolicy.return_okcCs<|jdkr|jstd�dS|jdkr8|js8td�dSdS)Nr	rFrT)r�r�rr�r�rrr�return_ok_versionRsz%DefaultCookiePolicy.return_ok_versioncCsJ|jrFt|�rF|jdkr*|jr*td�dS|jdkrF|jrFtd�dSdSrrr�rrr�return_ok_verifiability[sz+DefaultCookiePolicy.return_ok_verifiabilitycCs"|jr|j|jvrtd�dSdS)Nz(   secure cookie with non-secure requestFT)r��typer�rr�rrr�return_ok_securegsz$DefaultCookiePolicy.return_ok_securecCs|�|j�rtd�dSdS)Nz   cookie expiredFT)r��_nowrr�rrr�return_ok_expiresmsz%DefaultCookiePolicy.return_ok_expirescCsN|jrJt|�}|durd}|j�d�D]}||kr&qJq&td||j�dSdS)Nr#rmz0   request port %s does not match cookie port %sFT)r�r�r�rr%rrr�return_ok_portss�z"DefaultCookiePolicy.return_ok_portcCs�t|�\}}|j}|r*|�d�s*d|}n|}|jdkr^|j|j@r^|js^||kr^td�dS|jdkr�t||�s�td||�dS|jdkr�d|�	|�s�td||�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�s2


�����z$DefaultCookiePolicy.return_ok_domaincCs�t|�\}}|�d�sd|}|�d�s0d|}|rH|�d�sHd|}n|}|�|�sd|�|�sddS|�|�r|td|�dS|�|�r�td|�dSdS)Nr�FrrT)r�rtr�rrr)r�r�r�r�r�r/rrrr��s"






z$DefaultCookiePolicy.domain_return_okcCsbtd|�t|�}t|�}||kr&dS|�|�rR|�d�sN|||d�dkrRdStd||�dS)Nz- checking cookie path=%sTr�rz  %s does not path-match %sF)rr�rrtr�)r�r�r�rZpathlenrrrr��s

��z"DefaultCookiePolicy.path_return_ok)r�r�r�r r.rZ
DomainLiberalZDomainStrictr�rrrrrrr�rrrrr"r&r�r'r(r*r,r-r0r�r�rrrrrcsN�
#	;	rcCst|���}t|j|�Sr�)�sorted�keys�mapr�)Zadictr2rrr�vals_sorted_by_key�sr4c	csTt|�}|D]B}d}z
|jWnty0Yn0d}t|�EdH|s|VqdSr�)r4�items�AttributeError�
deepvalues)�mapping�values�objrrrr7�s
r7c@seZdZdS)�AbsentN�r�r�r�rrrrr;��r;c@s�eZdZe�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�)r>rCrrr�
set_policy�szCookieJar.set_policycCs�g}|j�||�sgStd|�|j|}|��D]T}|j�||�sFq2||}|��D].}|j�||�srtd�qVtd�|�|�qVq2|S)Nz!Checking %s for cookies to returnz   not returning cookiez   it's a match)	r>r�rrBr2r�r9r�rs)r�r�r��cookiesZcookies_by_pathr�Zcookies_by_namer�rrr�_cookies_for_domain�s 

zCookieJar._cookies_for_domaincCs*g}|j��D]}|�|�||��q|Sr�)rBr2�extendrG)r�r�rFr�rrr�_cookies_for_requestszCookieJar._cookies_for_requestc	Cs<|jdd�dd�d}g}|D�]}|j}|sHd}|dkrH|�d|�|jdurz|j�|j�rz|dkrz|j�d|j�}n|j}|jdur�|�|j�n|�d	|j|f�|dkr|j	r�|�d
|j
�|j�d��r|j}|j
s�|�d�r�|dd�}|�d
|�|jdurd}|j�r,|d|j}|�|�q|S)NcSs
t|j�Sr�)rr�)�arrr�<lambda>r=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�rFr��attrsr�r�rzr�r�rrr�
_cookie_attrssF


��
�
zCookieJar._cookie_attrscCs�td�|j��z�tt���|j_|_|�|�}|�|�}|r^|�	d�s^|�
dd�|��|jjr�|jj
s�|�	d�s�|D]}|jdkr||�
dd�q�q|W|j��n|j��0|��dS)N�add_cookie_headerrrZCookie2rz$Version="1")rrA�acquirerArMr>r+rIrQZ
has_headerZadd_unredirected_headerr�r�r�r��release�clear_expired_cookies)r�r�rFrPr�rrrrRIs(




��
zCookieJar.add_cookie_headerc
Cs�g}d}d}|D�]x}|d\}}d}d}	i}
i}|dd�D�].\}}
|��}||vs`||vrd|}||vrx|
durxd}
||
vr�q>|dkr�|
dur�td�d}	�qp|
��}
|d	kr�|r�q>|
dur�td
�q>|dk�rd}zt|
�}
Wn(t�ytd�d}	Y�qpYn0d	}|j|
}
||v�s2||v�rf|
du�r\|d
v�r\td|�d}	�qp|
|
|<q>|
||<q>|	�rxq|�|||
|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�rVz!   missing value for %s attribute)rKrrArLr+rs)r��	attrs_set�
cookie_tuples�
boolean_attrs�value_attrsZcookie_attrsryrzZmax_age_setZ
bad_cookie�standardr�r�r�r�rrr�_normalized_cookie_tuplesjsh





�

z#CookieJar._normalized_cookie_tuplescCs"|\}}}}|�dt�}|�dt�}|�dt�}	|�dt�}
|�dd�}|durrzt|�}WntypYdS0|�dd�}|�dd�}
|�d	d�}|�d
d�}|tur�|dkr�d}t|�}nXd}t|�}|�d
�}|dk�r|dkr�|d|�}n|d|d�}t|�dk�rd
}|tu}d}|�r8t|�	d��}|tu�rTt
|�\}}|}n|�	d��shd|}d}|	tu�r�|	du�r�t|�}	nd}t�
dd|	�}	nd}	|
tu�r�d}
d}
nF|
|jk�r�z|�|||�Wnt�y�Yn0td|||�dSt||||	||||||||
|
|||�S)Nr�r�r�r�r�r�Fr�r�rVrXTr�r�r	rr�z\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r�r;rArLr�r�r�r�boolrtr�r�rur_r+�clear�KeyErrorrr)r��tupr�ryrzr[r�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�)r\rars)r�rWr�rXrFr`r�rrr�_cookies_from_attrs_set's
z!CookieJar._cookies_from_attrs_setcCsHt|jdd�}|dur |jj}|D]}|jdkr$d|_|r$d|_q$dS)Nr�rTr	)r�r>r�r�r�)r�rFZ
rfc2109_as_nsr�rrr�_process_rfc2109_cookies0s

z"CookieJar._process_rfc2109_cookiesc
Cs6|��}|�dg�}|�dg�}tt���|j_|_|jj}|jj}|sN|rf|sV|rf|s^|rf|sj|sjgSz|�t	|�|�}Wnt
y�t�g}Yn0|�r2|�r2z|�t|�|�}	Wnt
y�t�g}	Yn0|�
|	�|�r"i}
|D]}d|
|j|j|jf<q�|
fdd�}t||	�}	|	�r2|�|	�|S)NzSet-Cookie2z
Set-CookiecSs|j|j|jf}||vSr�)r�r�ry)Z	ns_cookie�lookupr�rrr�no_matching_rfc2965isz3CookieJar.make_cookies.<locals>.no_matching_rfc2965)rZget_allrArMr>r+r�r�rbr{�	Exceptionrr�rcr�r�ry�filterrH)
r��responser�r�Zrfc2965_hdrsZns_hdrsr�r�rFZ
ns_cookiesrdr�rerrr�make_cookies<sZ�������
�



zCookieJar.make_cookiescCsX|j��z<tt���|j_|_|j�||�r:|�|�W|j��n|j��0dSr�)	rArSrArMr>r+r��
set_cookierTr�rrr�set_cookie_if_okss
zCookieJar.set_cookie_if_okcCsv|j}|j��zT|j|vr&i||j<||j}|j|vrDi||j<||j}|||j<W|j��n|j��0dSr�)rBrArSr�r�ryrT)r�r��cZc2Zc3rrrrj�s


zCookieJar.set_cookiecCsltd|���|j��zB|�||�D]&}|j�||�r&td|�|�|�q&W|j��n|j��0dS)Nzextract_cookies: %sz setting cookie: %s)	rrrArSrir>r�rjrT)r�rhr�r�rrr�extract_cookies�s

zCookieJar.extract_cookiescCst|dur2|dus|dur td��|j|||=n>|durX|durJtd��|j||=n|durj|j|=ni|_dS)Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rLrB)r�r�r�ryrrrr^�s��
zCookieJar.clearcCsN|j��z2|D]}|jr|�|j|j|j�qW|j��n|j��0dSr�)rArSr�r^r�r�ryrT)r�r�rrr�clear_session_cookies�s
zCookieJar.clear_session_cookiescCsZ|j��z>t��}|D]"}|�|�r|�|j|j|j�qW|j��n|j��0dSr�)	rArSrMr�r^r�r�ryrT)r�r�r�rrrrU�s


zCookieJar.clear_expired_cookiescCs
t|j�Sr�)r7rBrrrr�__iter__�szCookieJar.__iter__cCsd}|D]}|d}q|S)Nr	rr)r�r�r�rrr�__len__�szCookieJar.__len__cCs2g}|D]}|�t|��qd|jjd�|�fS�Nz<%s[%s]>r�)rsr�r�r�r��r��rr�rrrr��szCookieJar.__repr__cCs2g}|D]}|�t|��qd|jjd�|�fSrq)rsr$r�r�r�rrrrrr��szCookieJar.__str__)N)NNN)!r�r�r�ru�compilerNrOZstrict_domain_reZ	domain_reZdots_re�ASCII�magic_rer�rErGrIrQrRr\rarbrcrirkrjrmr^rnrUrorpr�r�rrrrr�s6





;!a\	7


rc@seZdZdS)rNr<rrrrr�r=rc@s4eZdZddd�Zddd�Zd
dd�Zdd	d
�ZdS)rNFcCs2t�||�|durt�|�}||_t|�|_dSr�)rr��os�fspath�filenamer]�	delayload)r�ryrzrDrrrr��s

zFileCookieJar.__init__cCs
t��dSr�r�)r�ry�ignore_discard�ignore_expiresrrr�save�szFileCookieJar.savecCs^|dur"|jdur|j}ntt��t|�� }|�||||�Wd�n1sP0YdSr�)ryrL�MISSING_FILENAME_TEXT�open�_really_load�r�ryr{r|rrrr�loads

zFileCookieJar.loadcCs�|dur"|jdur|j}ntt��|j��zNt�|j�}i|_z|�|||�Wnt	yl||_�Yn0W|j�
�n|j�
�0dSr�)ryrLr~rArSr�ZdeepcopyrBr��OSErrorrT)r�ryr{r|Z	old_staterrr�revert	s

zFileCookieJar.revert)NFN)NFF)NFF)NFF)r�r�r�r�r}r�r�rrrrr�s


	�rcCs |j|jfd|jfd|jfg}|jdur8|�d|jf�|jrH|�d�|jrX|�d�|jrh|�d�|j	rx|�d�|j
r�|�dtt|j
��f�|j
r�|�d	�|jr�|�d
|jf�|jr�|�d|jf�t|j���}|D]}|�|t|j|�f�q�|�dt|j�f�t|g�S)
Nr�r�r�)�	path_specN)�	port_specN)�
domain_dotN)r�Nr�)r�Nr�rVr�)ryrzr�r�r�rsr�r�r�r�r�r5r\r�r�r�r1r�r2r$r�r�)r�r�r2r�rrr�lwp_cookie_str$s(
��r�c@s(eZdZd
dd�Zddd�Zdd	�ZdS)rTcCsTt��}g}|D]2}|s |jr q|s0|�|�r0q|�dt|��qd�|dg�S)NzSet-Cookie3: %s�
rX)rMr�r�rsr�r�)r�r{r|r�rsr�rrr�
as_lwp_strMs
zLWPCookieJar.as_lwp_strNFcCsl|dur"|jdur|j}ntt��t|d��,}|�d�|�|�||��Wd�n1s^0YdS)N�wz#LWP-Cookies-2.0
)ryrLr~r�writer�r�rrrr}]s
zLWPCookieJar.savecCs,|��}|j�|�s$d|}t|��t��}d}d}	d}
�z�|��}|dkrP�q�|�|�s\q<|t|�d���}t|g�D�]f}|d\}
}i}i}|	D]}d||<q�|dd�D]n\}}|dur�|�	�}nd}||
vs�||	vr�|}||	v�r|dur�d	}|||<q�||
v�r|||<q�|||<q�|j
}|d
�}|d�}|du�rJt|�}|du�rXd	}|d�}|�d
�}t|d�|
||d�|d�|||d�|d�|d�|d�|||d�|d�|�}|�s�|j
�r�qz|�s�|�|��r�qz|�|�qzq<Wn>t�y��Yn*t�y&t�td||f��Yn0dS)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�rVrXr	FrTr�r�r�r�r�r�r�r�r�r�r�r�rVz&invalid Set-Cookie3 format file %r: %r)�readlinervr@rrMrtrr�r{rKr�rfrr�r�rjr�rfr)r�rryr{r|�magicrr��headerrYrZ�line�dataryrzr[r�r�r�r�r�r�r�r�r�rlrrrr�is��











�
�zLWPCookieJar._really_load)TT)NFF)r�r�r�r�r}r�rrrrr@s

rc@s,eZdZe�d�ZdZdd�Zd	dd�ZdS)
rz#( Netscape)? HTTP Cookie Filezr# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

cCs^t��}|��}|j�|�s(td|��z�|��}|dkr>�q|�d�rT|dd�}|���d�s*|��dkrpq*|�d�\}}	}
}}}
}|dk}|	dk}	|
dkr�|}
d}|�d�}d	}|dkr�d}d
}t	d|
|dd	||	||
d	|||ddi�}|s�|j
r�q*|�s|�|��rq*|�|�q*Wn>t
�y0�Yn*t�yXt�td||f��Yn0dS)
Nz4%r does not look like a Netscape format cookies filerXr�r�)�#r�	�TRUEr�FTr	z+invalid Netscape format cookies file %r: %r)rMr�rvr@rr�r�rtr�rr�r�rjr�rfr)r�rryr{r|r�r�r�r�r�r�r�r�ryrzr�r�rlrrrr��sf��
��
�

�zMozillaCookieJar._really_loadNFc
Cs|dur"|jdur|j}ntt��t|d���}|�|j�t��}|D]�}|sV|jrVqF|sf|�|�rfqF|j	rrd}nd}|j
�d�r�d}nd}|jdur�t
|j�}	nd}	|jdur�d}
|j}n|j}
|j}|�d�|j
||j||	|
|g�d�qFWd�n1�s0YdS)Nr�r�ZFALSEr�rXr�r�)ryrLr~rr�r�rMr�r�r�r�rtr�r$rzryr�r�)r�ryr{r|rr�r�r�r�r�ryrzrrrr} s<


���zMozillaCookieJar.save)NFF)	r�r�r�rurtrvr�r�r}rrrrr�s
Ar)N)N)W�__all__rwr�r-rurMZurllib.parser�Zurllib.requestZ	threadingr?Zhttp.clientZhttpZcalendarr
rrrr$ZclientZ	HTTP_PORTr�r~rr%r,r6r7rIr(rsrKr5r8r>rtrur?rFrUrZ�Ir^�Xr`rcrdrfrlrnrorqrpr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr4r7r;rr�rrr�rrrrrr�<module>s�


8��
�8
�!



U
D'


#b!b7x