e~.rSr/SQrSSKrSSKrSSKrSSKrSSKrSSKrSSK rSSK r SSK r SSKJr SrSqSrSrSr\"\ R,R.5r\R2"S 5rS rS rS rS rSr/SQr /SQr!\!Vs/sHoRE5PM snr#SKSjr$SKSjr%SSSSS.r&\R2"S\RN5r(Sr)Sr*\R2"S\RN5r+\R2"S\RX\RN-5r-\R2"S\R\\RN-5r/Sr0\R2"S\R\\RN-5r1Sr2Sr3\R2"S5r4\R2"S5r5\R2"S 5r6\R2"S!5r7S"r8\R2"S#5r9S$r:S%r;S&r<\R2"S'\RN5r=S(r>S)r?S*r@S+rA\R2"S,\RN5rBS-rCS.rDS/rES0rFS1rG\R2"S25rHS3rIS4rJS5rKS6rL"S7S85rM"S9S:5rN"S;S<\N5rOS=rP"S>S?5rQ"S@SA5rR"SBSC\S5rT"SDSE\R5rUSFrV"SGSH\U5rW"SISJ\U5rXgs snf)LaHTTP cookie handling for web clients. This module has (now fairly distant) origins in Gisle Aas' Perl module HTTP::Cookies, from the libwww-perl library. Docstrings, comments and debug strings in this code refer to the attributes of the HTTP cookie system as cookie-attributes, to distinguish them clearly from Python attributes. Class diagram (note that BSDDBCookieJar and the MSIE* classes are not distributed with the Python standard library, but are available from http://wwwsearch.sf.net/): CookieJar____ / \ \ FileCookieJar \ \ / | \ \ \ MozillaCookieJar | LWPCookieJar \ \ | | \ | ---MSIEBase | \ | / | | \ | / MSIEDBCookieJar BSDDBCookieJar |/ MSIECookieJar )Cookie CookieJar CookiePolicyDefaultCookiePolicy FileCookieJar LWPCookieJar LoadErrorMozillaCookieJarN)timegmFc[(dg[(dSSKnURS5q[R"U6$)Nr zhttp.cookiejar)debugloggerlogging getLogger)argsrs 4/opt/imh/python3.13/lib/python3.13/http/cookiejar.py_debugr,s2 5 6""#34 << HTTPOnlyz #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. cSSKnSSKnSSKnUR5nUR SU5 UR 5nUR SU-SS9 g)Nr zhttp.cookiejar bug! %s) stacklevel)iowarnings tracebackStringIO print_excgetvaluewarn)rrrfmsgs r_warn_unhandled_exceptionr"BsF#" A a **,C MM+c1aM@ricUSSupp4pVU[:a[SUs=::aS::aNO gSUs=::aS::a>O gSUs=::aS::a.O gSUs=::aS::aO gSUs=::aS::aO g[U5$g) N r ;=) EPOCH_YEARr )ttyearmonthmdayhourminsecs r_timegmr3Qs(*2A%DS  !u"2"2 :;db db !C~2~56NNbzr)MonTueWedThuFriSatSun) JanFebMarAprMayJunJulAugSepOctNovDeccFUc,[RR[RS9nO,[RRU[RS9nSURUR UR URURUR4-$)a0Return a string representing time in seconds since epoch, t. If the function is called without an argument, it will use the current time. The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ", representing Universal Time (UTC, aka GMT). An example of this format is: 1994-11-24 08:49:37Z tzz%04d-%02d-%02d %02d:%02d:%02dZ) datetimenowUTC fromtimestampr-r.dayr0minutesecondtdts r time2isozrT^s y    " "hll " 3    , ,Q8<< , @ + 266277BIIryy/B BBrcUc,[RR[RS9nO,[RRU[RS9nS[UR 5UR [URS- URURURUR4-$)zReturn a string representing time in seconds since epoch, t. If the function is called without an argument, it will use the current time. The format of the returned string is like this: Wed, DD-Mon-YYYY HH:MM:SS GMT rHz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr%) rJrKrLrMDAYSweekdayrNMONTHSr.r-r0rOrPrQs r time2netscaperYqs y    " "hll " 3    , ,Q8<< , @ 0 RZZ\BFFF288A:$6 "))RYY40 00r)GMTrLUTZz^([-+])?(\d\d?):?(\d\d)?$c4SnU[;aSnU$[RU5nU(akS[UR S55-nUR S5(a US[UR S55--nUR S5S:XaU*nU$)Nr ir<r%-) UTC_ZONES TIMEZONE_REsearchintgroup)rIoffsetms roffset_from_tz_stringrhs F Y M   r " C O+Fwwqzz"s1771:"66wwqzS   Mrc [U5nU[R:ag[R UR 55S-nUcSnUcSnUcSn[U5n[U5n[U5n[U5nUS:a^[R"[R"55SnUS-n Un X(-U - nX- n [U 5S:aU S:aUS-nOUS- n[X!XXEU45n U b(UcSnUR5n[U5n U cgX- n U $![ a6 [U5nO![ a gf=fSUs=::aS::aO OUnGNgf=f)Nr%r&r id2rL) rdrJMAXYEAR MONTHS_LOWERindexlower ValueErrortime localtimeabsr3upperrh) rNmonyrhrr1r2rIimoncur_yrrgtmprRrfs r _str2timer{sr RB H     -a/ z2 {!C {!C c(C RB c(C c(C Dy ,Q/ SL [1_ G q6B;1u28bCx" #3R01A} :B XXZ&r* > J H[   s8D   ??C s5&D## E#. D:9E#: EE#EE#"E#zV^[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* )?$c ([RU5nU(aUR5n[R USR 55S-n[ US5U[ US5[ US5[ US5[US54n[U5$UR5n[RSUS5nS/S -upSpgpn [RU5nUbUR5upSpgpn Og[XSXgXU 5$) aReturns time in seconds since epoch of time represented by a string. Return value is an integer. None is returned if the format of str is unrecognized, the time is outside the representable range, or the timezone string is not recognized. If the string contains no timezone, UTC is assumed. The timezone in the string may be numerical (like "-0800" or "+0100") or a string timezone (like "UTC", "GMT", "BST" or "EST"). Currently, only the timezone strings equivalent to UTC (zero offset) are known to the function. The function loosely parses the following formats: Wed, 09 Feb 1994 22:23:32 GMT -- HTTP format Tuesday, 08-Feb-94 14:15:29 GMT -- old rfc850 HTTP format Tuesday, 08-Feb-1994 14:15:29 GMT -- broken rfc850 HTTP format 09 Feb 1994 22:23:32 GMT -- HTTP format (no weekday) 08-Feb-94 14:15:29 GMT -- rfc850 format (no weekday) 08-Feb-1994 14:15:29 GMT -- broken rfc850 format (no weekday) The parser ignores leading and trailing whitespace. The time may be absent. If the year is given with only 2 digits, the function will select the century that makes the year closest to the current date. r%rr r^N)STRICT_DATE_RErcgroupsrmrnrordfloatr3lstrip WEEKDAY_REsubLOOSE_HTTP_DATE_REr{) textrggrur,rNrvrwr1r2rIs r http2timers< d#A HHJ  1.2!A$ic!A$i!A$iQqTE!A$K1r{ ;;=D >>"dA &D'+VAX"Cbc !!$'A})*&"#B Srs 44ra^ (\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 UR5nS/S-upp4pVn[RU5nUbUR5up2ppVpyOg[ XX4XVU5$)aV As for http2time, but parses the ISO 8601 formats: 1994-02-03 14:15:29 -0100 -- ISO 8601 format 1994-02-03 14:15:29 -- zone is optional 1994-02-03 -- only date 1994-02-03T14:15:29 -- Use T as separator 19940203T141529Z -- ISO 8601 compact format 19940203 -- only date Nr)r ISO_DATE_RErcrr{) rrNrurvrwr1r2rIrg_s riso2timer2sh ;;=D'+VAX"Cbc 4 A}-.HHJ)#B Srs 44rcfURS5upURSUURUS-$)z)Return unmatched part of re.Match object.r N)spanstring)matchstartends r unmatchedrSs2AJE <<  ST 2 22rz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c[U[5(ae/nUGHnUn/nU(Gav[RU5nU(a[ U5nUR S5n[ RU5nU(a3[ U5nUR S5n[RSU5nOK[RU5nU(a-[ U5nUR S5nUR5nOSnURXg45 OUR5RS5(a.UR5SSnU(aURU5 /nO5[R"SSU5upU S:dSU<S U<S U<35eUnU(aGMvU(dGMURU5 GM U$) aParse header values into a list of lists containing key,value pairs. The function knows how to deal with ",", ";" and "=" as well as quoted values after "=". A list of space separated tokens are parsed as if they were separated by ";". If the header_values passed as argument contains multiple values, then they are treated as if they were a single value separated by comma ",". This means that this function is useful for parsing header fields that follow this syntax (BNF as from the HTTP/1.1 specification, but we relax the requirement for tokens). headers = #header header = (token | parameter) *( [";"] (token | parameter)) token = 1* separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext = > quoted-pair = "\" CHAR parameter = attribute "=" value attribute = token value = token | quoted-string Each header is represented by a list of key/value pairs. The value for a simple token (not part of a parameter) is None. Syntactically incorrect headers will not necessarily be parsed as you would want. This is easier to describe with some examples: >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz']) [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]] >>> split_header_words(['text/html; charset="iso-8859-1"']) [[('text/html', None), ('charset', 'iso-8859-1')]] >>> split_header_words([r'Basic realm="\"foo\bar\""']) [[('Basic', None), ('realm', '"foobar"')]] r%z\1N,z^[=\s;]*rr zsplit_header_words bug: 'z', 'z', ) isinstancestrHEADER_TOKEN_RErcrreHEADER_QUOTED_VALUE_REHEADER_ESCAPE_RErHEADER_VALUE_RErstripappendr startswithresubn) header_valuesresultr orig_textpairsrgnamevaluenon_junk nr_junk_charss rsplit_header_wordsr\sZ---- - F &&t,A |wwqz*11$7$QE'..t4A(| !  % !% d]+))#..{{}QR(&--.+-''+r4*H'$q(.e-.( ?d@ 5&--&GH Mr([\"\\])cN/nUHn/nUHYupEUb@[R"SU5(d[RSU5nSU-nU<SU<3nUR U5 M[ U(dMmUR SR U55 M SR U5$)aDo the inverse (almost) of the conversion done by split_header_words. Takes a list of lists of (key, value) pairs and produces a single header value. Attribute values are quoted if needed. >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]]) 'text/plain; charset="iso-8859-1"' >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]]) 'text/plain, charset="iso-8859-1"' z^\w+$\\\1z"%s"=; , )rrcHEADER_JOIN_ESCAPE_RErrjoin)listsheadersrattrkvs rjoin_header_wordsrsGDA}yy1---11'1=A A !$ KKN  4 $0 99W rcrURS5(aUSSnURS5(aUSSnU$)N"r%)rendswithrs r strip_quotesrs; sABx }}SCRy KrcXSn/nUGHn/nSn[URS55HupgUR5nURS5upn UR5nU(d US:Xa OMJU (aU R5OSn US:waKUR 5n X;aU nUS:XaU b [ U 5n SnOUS :XaU b[ [ U 55n URX45 M U(dMU(dURS 5 URU5 GM! U$) aAd-hoc parser for Netscape protocol cookie-attributes. The old Netscape cookie format for Set-Cookie can for instance contain an unquoted "," in the expires field, so we have to use this ad-hoc parser instead of split_header_words. XXX This may not make the best possible effort to parse all the crap that Netscape Cookie headers contain. Ronald Tschalar's HTTPClient parser is probably better, so could do worse than following that if this ever gives any trouble. Currently, this is also used for parsing RFC 2109 cookies. )expiresdomainpathsecureversionportmax-ageF;rr NrTr)r0) enumeratesplitstrip partitionrorrr) ns_headers known_attrsr ns_headerr version_setiiparamkeysepvallcs rparse_ns_headersrs1KF  #9??3#78IBKKME!OOC0MCc))+C7"%#))+$CQwYY[$C)#*3/"&KI%' S(9: LL# $=9@ 5 -. MM% W Z Mrz\.\d+$cn[RU5(agUS:XagUSS:Xd USS:Xagg)z*Return True if text is a host domain name.Frr .rTIPV4_RErcrs ris_HDNrs;~~d rz Aw#~bS rcUR5nUR5nX:Xag[U5(dgURU5nUS:XdUS:XagURS5(dg[USS5(dgg)aReturn True if domain A domain-matches domain B, according to RFC 2965. A and B may be host domain names or IP addresses. RFC 2965, section 1: Host names can be specified either as an IP address or a HDN string. Sometimes we compare one host name with another. (Such comparisons SHALL be case-insensitive.) Host A's name domain-matches host B's if * their host name strings string-compare equal; or * A is a HDN string and has the form NB, where N is a non-empty name string, B has the form .B', and B' is a HDN string. (So, x.y.com domain-matches .Y.com but not Y.com.) Note that domain-match is not a commutative operation: a.b.c.com domain-matches .c.com, but not the reverse. TFrr rr%N)rorrfindr)ABis r domain_matchr&sr.  A  Av !99  ABw!q& <<   !AB%== rc:[RU5(agg)z\Return True if text is a sort-of-like a host domain name. For accepting/blocking domains. FTrrs rliberal_is_HDNrMs ~~d rc UR5nUR5n[U5(a[U5(dX:XaggURS5nU(aURU5(agU(dX:Xagg)zTFor blocking/accepting domains. A and B may be host domain names or IP addresses. TFr)rorrr)rr initial_dots ruser_domain_matchrWsg  A  A 1  ."3"3 6,,s#Kqzz!}} 16 rz:\d+$cUR5n[RRU5SnUS:XaUR SS5n[ R SUS5nUR5$)z|Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. r%rHost) get_full_urlurllibparseurlparse get_header cut_port_rerro)requesturlhosts r request_hostrlsd    C <<  %a (D rz!!&"- ??2tQ 'D ::<rc6[U5=pSU;aUS-nX!4$)zrReturn a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased. r.local)r)rerhnreq_hosts reff_request_hostr|s+ #7++D ((" >rcUR5n[RRU5n[ UR 5nUR S5(dSU-nU$)z6Path component of request-URI, as defined by RFC 2965./)rrrurlsplit escape_pathrr)rrpartsrs r request_pathrsO    C LL ! !# &E uzz "D ??3  Tz KrcURnURS5nUS:aXS-Sn[U5 U$[ nU$![a [ SU5 gf=f)N:r r%znonnumeric port: '%s')rfindrdrprDEFAULT_HTTP_PORT)rrrrs r request_portrsj <>> reach("www.acme.com") '.acme.com' >>> reach("acme.com") 'acme.com' >>> reach("acme.local") '.local' rr r%Nlocal)rr)hrbs rreachrsU4 s AAv cdG FF3K !99!q&ALq5L Hrcd[U5n[U[UR55(dgg)z RFC 2965, section 3.3.6: An unverifiable transaction is to a third-party host if its request- host U does not domain-match the reach R of the request-host O in the origin transaction. TF)rrrorigin_req_host)rrs ris_third_partyrs,G$H %(?(?"@ A ArcP\rSrSrSrS SjrSrS SjrSrS Sjr S r S r S r g)riaHTTP Cookie. This class represents both Netscape and RFC 2965 cookies. This is deliberately a very simple class. It just holds attributes. It's possible to construct Cookie instances that don't comply with the cookie standards. CookieJar.make_cookies is the factory function for Cookie objects -- it deals with cookie parsing, supplying defaults, and normalising to the representation used in this class. CookiePolicy is responsible for checking them to see whether they should be accepted from and returned to the server. Note that the port may be present in the headers, but unspecified ("Port" rather than"Port=80", for example); if this is the case, port is None. cUb [U5nU b[[U 55n UcUSLa [S5eXlX lX0lX@lXPlUR5Ul Xpl Xl Xl Xl XlXlXlXlXlUUl[(R("U5Ulg)NTz-if port is None, port_specified must be false)rdrrprrrrport_specifiedrordomain_specifieddomain_initial_dotrpath_specifiedrrdiscardcomment comment_urlrfc2109copy_rest)selfrrrrrrrrrrrrrrrrestrs r__init__Cookie.__init__s  #g,  #eGn*= rcURcSnOSUR-nURU-UR-nURbUR<SUR<3nO URnSU<SU<S3$)Nrrrz)rrrrr)rplimit namevalues r__str__Cookie.__str__0sd 99 "adii-a a$))+ :: !#'99djj9I I'0%88rcf/nSH/n[X5nURU<S[U5<35 M1 URS[UR5-5 URS[UR5-5 UR R <SSRU5<S3$)N)rrrrrrrrrrrrrrrrzrest=%sz rfc2109=%s(r))getattrrreprrr __class____name__r)rrrrs r__repr__Cookie.__repr__:sD 4&D KK4d4 5 ITZZ 001 L4 #556>>22DIIdODDr)rrrrrrrrrrrrrrrrr)Fr$) rA __module__ __qualname____firstlineno____doc__r!r&r+r.r2r9rB__static_attributes__rrrrs16(%T"-! 9 Errc0\rSrSrSrSrSrSrSrSr g) riIaDefines which cookies get accepted from and returned to server. May also modify cookies, though this is probably a bad idea. The subclass DefaultCookiePolicy defines the standard rules for Netscape and RFC 2965 cookies -- override that if you want a customized policy. c[5e)zReturn true if (and only if) cookie should be accepted from server. Currently, pre-expired cookies never get this far -- the CookieJar class deletes such cookies itself. NotImplementedErrorrcookiers rset_okCookiePolicy.set_okRs "##rc[5e)zAReturn true if (and only if) cookie should be returned to server.rLrNs r return_okCookiePolicy.return_ok[ !##rcg)zMReturn false if cookies should not be returned, given cookie domain. TrI)rrrs rdomain_return_okCookiePolicy.domain_return_ok_rcg)zKReturn false if cookies should not be returned, given cookie path. TrI)rrrs rpath_return_okCookiePolicy.path_return_okdrYrrIN) rArDrErFrGrPrSrWr[rHrIrrrrIs$$ rrc \rSrSrSrSrSrSrSr\\-r SSSS SS S SS \S S S 4 S jr S r S r Sr SrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrSrS rS!r S"r!g)#rijzBImplements the standard rules for accepting and returning cookies.r%rr}r NTF)httpswsscX0lX@lXPlX`lXplXlXlXlXlXl Xl Ub[U5Ul OSUl Ub [U5nX l g)zAConstructor arguments should be passed as keyword arguments only.NrI)netscaperfc2965rfc2109_as_netscape hide_cookie2 strict_domainstrict_rfc2965_unverifiablestrict_ns_unverifiablestrict_ns_domainstrict_ns_set_initial_dollarstrict_ns_set_pathsecure_protocolstuple_blocked_domains_allowed_domains)rblocked_domainsallowed_domainsrarbrcrdrerfrgrhrirjrks rr!DefaultCookiePolicy.__init__tsu!  #6 (*+F(&<# 0,H)"4 0  &$)/$:D !$&D !  &#O4O /rcUR$)z4Return the sequence of blocked domains (as a tuple).)rmrs rro#DefaultCookiePolicy.blocked_domains$$$rc$[U5Ulg)z$Set the sequence of blocked domains.N)rlrm)rros rset_blocked_domains'DefaultCookiePolicy.set_blocked_domainss %o 6rcNURHn[X5(dM g gr1)rmr)rrblocked_domains r is_blockedDefaultCookiePolicy.is_blockeds%"33N 884rcUR$)z=Return None, or the sequence of allowed domains (as a tuple).)rnrss rrp#DefaultCookiePolicy.allowed_domainsrurc,Ub [U5nXlg)z-Set the sequence of allowed domains, or None.N)rlrn)rrps rset_allowed_domains'DefaultCookiePolicy.set_allowed_domainss  &#O4O /rcjURcgURHn[X5(dM g g)NFT)rnr)rrallowed_domains ris_not_allowed"DefaultCookiePolicy.is_not_alloweds4  ("33N 884rc[SURUR5 URceSH"nSU-n[X5nU"X5(aM" g g)z If you override .set_ok(), be sure to call this method. If it returns false, so should your subclass (assuming your subclass wants to be more strict about which cookies to accept).  - checking cookie %s=%s)r verifiabilityrrrrset_ok_FTrrrr>rrOrnfn_namefns rrPDefaultCookiePolicy.set_oksZ )6;; E{{&&&MAkG'Bf&& N rcURc"[SURUR5 gURS:aUR(d [S5 gURS:XaUR (d [S5 gg)Nz0 Set-Cookie2 without version attribute (%s=%s)Fr $ RFC 2965 cookies are switched off$ Netscape cookies are switched offT)rrrrrbrarNs rset_ok_version"DefaultCookiePolicy.set_ok_versionsh >> ! E;;  . >>A dll 9 : ^^q  9 :rcUR(aj[U5(aZURS:aUR(a [ S5 gURS:XaUR (a [ S5 ggNr z> third-party RFC 2965 cookie during unverifiable transactionFz> third-party Netscape cookie during unverifiable transactionT unverifiablerrrfrrgrNs rset_ok_verifiability(DefaultCookiePolicy.set_ok_verifiabilitys`   N7$;$;~~!d&F&F891$)D)D89rcURS:XaHUR(a7URRS5(a[ SUR5 gg)Nr $z' illegal name (starts with '$'): '%s'FT)rrirrrrNs r set_ok_nameDefaultCookiePolicy.set_ok_namesB NNa D$E$E KK " "3 ' ' XVS-SnXWS-Un U R5S;a[U5S:Xa [S U5 gURS5(aUSSn OUn U RS5S:n U (d#URS 5(d [S U5 gURS:XakURU5(dUURU S 35(d<URS5(d&SU-RU5(d [S XE5 gURS:dURUR -(a[#XE5(d [S XE5 gURS:dURUR$-(aKUS[U5*n U RS5S:a'[&R)U5(d [SX5 gg)N" domain %s is in user block-listF& domain %s is not in user allow-listrrr r%)coaccomeduorgnetgovmilrdaerobizcatcoopinfojobsmobimuseumrprotraveleuz& country-code second level domain %srz/ 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{rrrrrrecountrrolenrrrrrhDomainRFC2965MatchrDomainStrictNoDotsrrc) rrOrrrrrjtldsldundotted_domain embedded_dots host_prefixs r set_ok_domain!DefaultCookiePolicy.set_ok_domainsb ??6== ) ) 7 G   v}} - - ;V]] K  " " "-g6NH]]F!!v||C'8A'=LL%LLa+6 1,C 1Q-Cyy{''',/s8q=GP$  %%"(*"(,11#6!;M x)@)@H~~"v../):&'ABB--d(,,V44?)!"&&)@)@@#D11 !%/ "&&)@)@@&}V 5 $$S)Q.x00K&0 rc0UR(ah[U5nUcSnO [U5nURR S5Hn[ U5 XC:XdM g [SX1R5 gg![ a [SU5  gf=f)N80rz bad port %s (not numeric)Fz$ request port (%s) not found in %sT)rrrrrrdrprrrOrreq_portr6s r set_ok_portDefaultCookiePolicy.set_ok_port3s  #G,Hx=[[&&s+!F= ,=."!91= !s A;;BBc[SURUR5 SH"nSU-n[X5nU"X5(aM" g g)z If you override .return_ok(), be sure to call this method. If it returns false, so should your subclass (assuming your subclass wants to be more strict about which cookies to return). r)rrrrrr return_ok_FTrrs rrSDefaultCookiePolicy.return_okHsJ )6;; ERA"1nG'Bf&& S rcURS:aUR(d [S5 gURS:XaUR(d [S5 gg)Nr rFrT)rrbrrarNs rreturn_ok_version%DefaultCookiePolicy.return_ok_versionZsA >>A dll 9 : ^^q  9 :rcUR(aj[U5(aZURS:aUR(a [ S5 gURS:XaUR (a [ S5 ggrrrNs rreturn_ok_verifiability+DefaultCookiePolicy.return_ok_verifiabilitycs`   N7$;$;~~!d&F&F%&1$)D)D%&rcrUR(a&URUR;a [S5 gg)Nz( secure cookie with non-secure requestFT)rtyperkrrNs rreturn_ok_secure$DefaultCookiePolicy.return_ok_secureos) ==W\\1F1FF = >rc\URUR5(a [S5 gg)Nz cookie expiredFT)r2_nowrrNs rreturn_ok_expires%DefaultCookiePolicy.return_ok_expiresus&   TYY ' ' & 'rcUR(aP[U5nUcSnURRS5H nXC:XdM g [SX1R5 gg)Nrrz0 request port %s does not match cookie port %sFT)rrrrrs rreturn_ok_port"DefaultCookiePolicy.return_ok_port{s^ ;;#G,H[[&&s+= ,I.rc[U5up4URnU(aURS5(dSU-nOUnURS:Xa@URUR -(a"UR (dXT:wa [S5 gURS:a[XE5(d [SXE5 gURS:Xa&SU-RU5(d [SX55 gg)Nrr 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) rrrrrhDomainStrictNonDomainrrrr)rrOrrrr dotdomains rreturn_ok_domain$DefaultCookiePolicy.return_ok_domains)'2 &++C00f II NNa   " "T%?%? ?''FN - . >>A l4&@&@ /04 > >>Q D':':9'E'E ! +rc[U5up4URS5(dSU-nURS5(dSU-nU(aURS5(dSU-nOUnURU5(dURU5(dgURU5(a [ SU5 gUR U5(a [ SU5 gg)NrFrrT)rrrr{rr)rrrrrrs rrW$DefaultCookiePolicy.domain_return_oks*'2""3''8|Hs##t8D &++C00f II!!),, i0H0H ??6 " " 7 @   v & & ;V Drc[SU5 [U5n[U5nX1:XagURU5(a"UR S5(d X4US-S:Xag[SX15 g)Nz- checking cookie path=%sTrr%z %s does not path-match %sF)rrrrr)rrrrpathlens rr["DefaultCookiePolicy.path_return_oksj*D1(d)  !!$''}}S!!Xgai%@C%G,h=r) rnrmrdrarcrbrkrerhrirjrgrf)"rArDrErFrGrrr DomainLiberal DomainStrictr!rorwr{rprrrPrrrrrrrSrrrrrrrWr[rHrIrrrrjsLM%&;;L"&t%)#$-1(-"/.3$)"2!0F%7 %0 &   :x*$   64 rrc## [UR55H4nSnUR Sn[U5ShvN U(aM0Uv M6 gN![a N f=f7f)z)Iterates over nested mapping, depth-firstFTN)listvaluesitems deepvaluesAttributeError)mappingobjs rrrsbGNN$% ' IIG!# & &wI& '    s7A' AA'A A' A' A$!A'#A$$A'c\rSrSrSrg)AbsentirINrArDrErFrHrIrrrrsdrrc\rSrSrSr\R "S5r\R "S5r\R "S5r \R "S5r \R "S5r \R "S\R5r S S jrS rS rS rSrSrSrSrSrSrSrSrSrSrS!SjrSrSrSrSr Sr!Sr"Sr#g )"rizCollection of HTTP cookies. You may not need to know about this class: try urllib.request.build_opener(HTTPCookieProcessor).open(url). z\Wrz\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NclUc [5nXl[R"5Ul0Ulgr$)r_policy _threadingRLock _cookies_lock_cookiesrpolicys rr!CookieJar.__init__s, >(*F '--/ rcXlgr$)rrs r set_policyCookieJar.set_policys rc/nURRX5(d/$[SU5 URUnUR 5HnURR XR5(dM%XEnUR 5HLnURRXr5(d [S5 M0[S5 URU5 MN M U$)Nz!Checking %s for cookies to returnz not returning cookiez it's a match) rrWrrkeysr[rrSr)rrrcookiescookies_by_pathrcookies_by_namerOs r_cookies_for_domainCookieJar._cookies_for_domains||,,V==I2F;--/#((*D<<..t==-3O)002||--f>>45()v& 3 +rc/nURR5H#nURURX155 M% U$)z2Return a list of cookies to be returned to server.)rrextendr)rrrrs r_cookies_for_requestCookieJar._cookies_for_request s:mm((*F NN433FD E+rcURSSS9 Sn/nUGHnURnU(dSnUS:aURSU-5 URbWURR UR5(a-US:a'UR RSUR5nO URnURcURUR5 O"URUR<S U<35 US:dMUR(aURS UR-5 URRS 5(aLURnUR(dURS 5(aUS SnURS U-5 URcGMSnUR(aUSUR--nURU5 GM U$)zReturn a list of cookie-attributes to be returned to server. like ['foo="bar"; $Path="/"', ...] The $Version attribute is also added when appropriate (currently only once per request). c,[UR5$r$)rr)as r)CookieJar._cookie_attrs..s 3qvv;rT)rreverseFr z $Version=%sNrrz $Path="%s"rr%z $Domain="%s"z$Portz="%s")sortrrr non_word_rercquote_rerrrrrrrrr) rrrattrsrOrrrr6s r _cookie_attrsCookieJar._cookie_attrss  . = FnnG" Q;LL!89 )  '' 55'A+ ))'6<<@ ||# V[[)  U;<{((LL !;<==++C00#]]F"55))#..!'LL&!89;;*A,,6;;!67LLOQT rc[S5 URR5 [[R"55=UR lUlURU5nURU5nU(a7URS5(d!URSSRU55 UR R(a^UR R(dCURS5(d-UH'nURS:wdMURSS5 O URR5 UR!5 g!URR5 f=f)zAdd correct Cookie: header to request (urllib.request.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. add_cookie_headerrrCookie2r%z $Version="1"N)rracquirerdrqrrr r has_headeradd_unredirected_headerrrbrdrreleaseclear_expired_cookies)rrrrrOs rrCookieJar.add_cookie_headerLs "# ""$ ),/ ,< R&    & & ( ""$    & & (sC3EEE;ch/nSnSnUGHnUSupgSnSn 0n 0n USSHupU R5nX;dX;aUn X;aU cSn X;aM2U S:Xa"U c[S 5 Sn OU R5n U S :XaU(aMiU c [S 5 MyU S :XaSn[U 5n S n URU -n X;dX;a!U cU S;a[SU -5 Sn OXU 'MXU 'M U (aMUR XgX45 GM U$![a [S 5 Sn  M>f=f)aReturn list of tuples containing normalised cookie information. attrs_set is the list of lists of key,value pairs extracted from the Set-Cookie or Set-Cookie2 headers. Tuples are name, value, standard, rest, where name and value are the cookie name and value, standard is a dictionary containing the standard cookie-attributes (discard, secure, version, expires or max-age, domain, path and port) and rest is a dictionary containing the rest of the cookie-attributes. )rr)rrrrrrr commenturlr Fr%NTrz% missing value for domain attributerzM missing or invalid value for expires attribute: treating as session cookierz? missing or invalid (non-numeric) value for max-age attribute)rrr$z! missing value for %s attribute)rorrdrprr)r attrs_set cookie_tuples boolean_attrs value_attrs cookie_attrsrr max_age_set bad_cookiestandardr rrrs r_normalized_cookie_tuples#CookieJar._normalized_cookie_tuplesms + 0 &L&q/KD KJHD$QR(WWY$(;A%!)A==yFG%)  A >" y FG  >"&KF"A A A$!*< !BBBQFG%) "#QKGe)h  $x!> ?Q&T5& 23%)  s# DD10D1cvUup4pVURS[5nURS[5nURS[5n URS[5n URSS5n U b [U 5n URSS5n URSS5n URS S5nURS S5nU[LaUS :waS n[ U5nOISn[ U5nUR S 5nUS:waU S:XaUSUnOUSUS-n[U5S:XaS nU[LnSnU(a[URS55nU[La[U5unnUnOURS5(dSU-nSnU [La*U c [U5n OS n[R"SS U 5n OSn U [LaSn S n O0XR::a!URXxU5 [#SXxU5 g[%U X4U UUUUUUU U U UUU5$![a gf=f![ a NCf=f)NrrrrrrFrrr$rTrrr r%rz\s+z2Expiring cookie, domain='%s', path='%s', name='%s')r)rrdrprrrrboolrrrrrrclearKeyErrorrr)rtuprrrr,r rrrrrrrrrrrrrrrrs r_cookie_from_cookie_tuple#CookieJar._cookie_from_cookie_tuplesm'*#Xh/||FF+||FF+,,y&1,,y$/   g,h.,,y%0,,y$/ll<6  v $"*!Nt$D"N(D 3ABwa<8D1:D4yA~ct"/" !%f&7&7&rrbrr)rr rfc2109_as_nsrOs r_process_rfc2109_cookies"CookieJar._process_rfc2109_cookies3sX .CTJ  $ 4 44MF~~"!% =&'FN rcUR5nURS/5nURS/5n[[R"55=URlUlURR nURRnU(dU(a*U(dU(aU(dU(aU(d U(d/$UR[U5U5nU(aU(aUR[U5U5n URU 5 U(aA0n UH(n SXRU RU R 4'M* U 4Sjn [#X5n U (aUR%U 5 U$![a [5 /nNf=f![a [5 /n Nf=f)zAReturn sequence of Cookie objects extracted from response object.z Set-Cookie2z Set-CookieNcPURURUR4nX!;$r$)rrr) ns_cookielookuprs rno_matching_rfc29653CookieJar.make_cookies..no_matching_rfc2965ls%#**INNINNJC,,r)rget_allrdrqrrrbrar7r Exceptionr"rr;rrrfilterr ) rresponserr rfc2965_hdrsns_hdrsrbrar ns_cookiesr@rOrAs r make_cookiesCookieJar.make_cookies?sl--/}b9 //,3(+DIIK(88 DI,,&&<<((gh'I 22"<0';G x !99$W-w8  ) )* 5%FHLFMM6;; DE&;A-$$7D z*C  % 'G  )+  s$F:F$F! F!$F=<F=cvURR5 [[R"55=URlUlURR X5(aURU5 URR5 g!URR5 f=f)z-Set a cookie if policy says it's OK to do so.N) rrrdrqrrrP set_cookier rNs rset_cookie_if_okCookieJar.set_cookie_if_okvs ""$ ),/ ,< <<&&v770&9OOF+?    & & (D   & & (s2B(,!B((CcUb%UbUc [S5eURUUU gUbUc [S5eURUU gUbURU g0Ulg)aClear some cookies. Invoking this method without arguments will clear all cookies. If given a single argument, only cookies belonging to that domain will be removed. If given two arguments, cookies belonging to the specified path within that domain are removed. If given three arguments, then the cookie with the specified name, path and domain is removed. Raises KeyError if no matching cookie exists. Nz8domain and path must be given to remove a cookie by namez.domain must be given to remove cookies by path)rpr)rrrrs rr1CookieJar.clears  DL NPP f%d+D1  ~ DFF f%d+   f%DMrcFURR5 UHGnUR(dMURURUR UR 5 MI URR5 g!URR5 f=f)zDiscard all session cookies. Note that the .save() method won't save session cookies anyway, unless you ask otherwise by passing a true ignore_discard argument. N)rrrr1rrrr )rrOs rclear_session_cookiesCookieJar.clear_session_cookiessq ""$ )>>>JJv}}fkk6;;G    & & (D   & & (sB5BB czURR5 [R"5nUHLnURU5(dMUR UR UR UR5 MN URR5 g!URR5 f=f)adDiscard all expired cookies. You probably don't need to call this method: expired cookies are never sent back to the server (provided you're using DefaultCookiePolicy), this method is called by CookieJar itself every so often, and the .save() method won't save expired cookies anyway (unless you ask otherwise by passing a true ignore_expires argument). N) rrrqr2r1rrrr )rrKrOs rr!CookieJar.clear_expired_cookiess ""$ )))+C$$S))JJv}}fkk6;;G    & & (D   & & (s.B5BB:c,[UR5$r$)rrrss r__iter__CookieJar.__iter__s$--((rc$SnUHo!S-nM U$)z#Return number of contained cookies.r r%rI)rrrOs r__len__CookieJar.__len__s FAAdrc/nUHo!R[U55 M SURR<SSR U5<S3$N<[rz]>)rr?r@rArrrrOs rrBCookieJar.__repr__s8 FHHT&\2d!^^44diilCCrc/nUHo!R[U55 M SURR<SSR U5<S3$rf)rrr@rArris rr9CookieJar.__str__s8 FHHS[1d!^^44diilCCr)rrrrr$)NNN)$rArDrErFrGrcompilerrstrict_domain_re domain_redots_reASCIImagic_rer!rrr rrr-r4r7r;rJrNrMrVr1r[r!r`rcrBr9rHrIrrrrs **U#Kzz+&Hzz+. 8$Ijj!Gzz6AH$9v%B_BZx '5n ) ) )6 ))&) D Drrc\rSrSrSrg)rirINrrIrrrrs$rrcD\rSrSrSrS SjrS SjrS SjrS SjrSr g) riz6CookieJar that can be loaded from and saved to a file.Nc[RX5 Ub[R"U5nXl[ U5Ulg)ze Cookies are NOT loaded from the named file until either the .load() or .revert() method is called. N)rr!osfspathfilenamer0 delayload)rryrzrs rr!FileCookieJar.__init__s6 4(  yy*H irc[5e)zSave cookies to a file.rL)rryignore_discardignore_expiress rsaveFileCookieJar.saverUrcUc)URb URnO[[5e[U5nUR XAX#5 SSS5 g!,(df  g=f)zLoad cookies from a file.N)ryrpMISSING_FILENAME_TEXTopen _really_loadrryr}r~r s rloadFileCookieJar.loadsI  }}(T]]("#899 (^q   a> J^^s A A"cUc)URb URnO[[5eURR 5 [ R "UR5n0UlURXU5 URR5 g![a X@lef=f!URR5 f=f)zClear all cookies and reload cookies from a saved file. Raises LoadError (or OSError) if reversion is not successful; the object's state will not be altered if this happens. N) ryrprrrrdeepcopyrrOSErrorr )rryr}r~ old_states rrevertFileCookieJar.revert s  }}(T]]("#899 ""$ ) dmm4IDM  (NC    & & (   )      & & (s'B30BB00B33C)rrzry)NFNNFF) rArDrErFrGr!rrrrHrIrrrrs"@ )$K#49)rrcVURUR4SUR4SUR4/nURbUR SUR45 UR (aUR S5 UR(aUR S5 UR(aUR S5 UR(aUR S5 UR(a/UR S[[UR5545 UR(aUR S 5 UR(aUR S UR45 UR(aUR S UR45 [!UR"R%55nUH,nUR U['UR"U545 M. UR S ['UR(545 [+U/5$) zReturn string representation of Cookie in the LWP cookie file format. Actually, the format is extended a bit -- see module docstring. rrr) path_specN) port_specN) domain_dotN)rNr)rNrr$r)rrrrrrrrrrrrTrrrrsortedrrrrr)rOr rrs rlwp_cookie_strr's ++v|| $ &++  FMM " $A{{&&++)> ? ahh':; ahh':;   !((+?"@ }}ahh/0 ~~qxx(v~~)>?!AB ~~qxx 12 ~~qxxFNN ;< 188\63E3E$FG &,,##% &D  !Sa)*+HHiV^^, -. aS !!rc2\rSrSrSrSSjrS SjrSrSrg) riCa? The LWPCookieJar saves a sequence of "Set-Cookie3" lines. "Set-Cookie3" is the format used by the libwww-perl library, not known to be compatible with any browser, but which is easy to read and doesn't lose information about RFC 2965 cookies. Additional methods as_lwp_str(ignore_discard=True, ignore_expired=True) c[R"5n/nUHYnU(dUR(aMU(dURU5(aM<URS[ U5-5 M[ SR US/-5$)zReturn cookies as a string of "\n"-separated "Set-Cookie3" headers. ignore_discard and ignore_expires: see docstring for FileCookieJar.save zSet-Cookie3: %s r)rqrr2rrr)rr}r~rKrjrOs r as_lwp_strLWPCookieJar.as_lwp_strPsn iik F!fnn!f&7&7&<&< HH&)?? @  yyB4  rNcUc)URb URnO[[5e[R"[R "U[R [R-[R-S5S5nURS5 URURX#55 SSS5 g!,(df  g=f)Nwz#LWP-Cookies-2.0 ) ryrprrwfdopenrO_CREATO_WRONLYO_TRUNCwriterrs rrLWPCookieJar.save`s  }}(T]]("#899 YY GGHbjj2;;6CU K   GG( ) GGDOONC D   s 2C CcUR5nURRU5(dSU-n[U5e[R"5nSnSn Sn UR5=n S:wGaU R U5(dM/U [ U5SR5n [U /5GHWn U Sup0n0nU HnSUU'M U SSHNunnUbUR5nOSnUU ;dUU ;aUnUU ;a UcS nUUU'M<UU ;aUUU'MIUUU'MP URnU"S 5nU"S 5nUb [U5nUcS nU"S 5nUR S 5n[U"S5XU"S5U"S5UUU"S5U"S5U"S5U"S5UUU"S5U"S5U5nU(dUR(aGM&U(dURU5(aGMFURU5 GMZ UR5=n S:waGMgg![ a e["a [%5 [SU<SW <35ef=f)Nz5%r does not look like a Set-Cookie3 (LWP) format filez Set-Cookie3:)rrrrr)rrrrrrr$rr Fr%Trrrrrrrrrrrrr$z invalid Set-Cookie3 format file : )readlinersrcrrqrrrrror)rrrr2rMrrDr")rr ryr}r~magicr!rKheaderr'r(linedatarrr,r rrrr rrrrrQs rrLWPCookieJar._really_loadosn }}##E**$%CC. iik. 0 9 .::<'4B.v..CKL)//1.v6D"&q'KD!HD*&+ + $QR1=!"B!%B+-23F "A - yd!*+HQK+-*+HQK&'DG!) ! A lG lG*"*7"3"&x[F'-'8'8'=$q|T y!K.%'7< y!K. {&& | # %A*aii )all3.?.? OOA&[7 ::<'4B..f   . % '%t-. . .s G H++2IrI)TTr) rArDrErFrGrrrrHrIrrrrCs ! EJ.rrc(\rSrSrSrSrSSjrSrg)r iaB WARNING: you may want to backup your browser's cookies file if you use this class to save cookies. I *think* it works, but there have been bugs in the past! This class differs from CookieJar only in the format it uses to save and load cookies to and from a file. This class uses the Mozilla/Netscape `cookies.txt' format. curl and lynx use this file format, too. Don't expect cookies saved while the browser is running to be noticed by the browser (in fact, Mozilla on unix will overwrite your saved cookies if you change them on disk while it's running; on Windows, you probably can't save at all while the browser is running). Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to Netscape cookies on saving. In particular, the cookie version and port number information is lost, together with information about whether or not Path, Port and Discard were specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the domain as set in the HTTP header started with a dot (yes, I'm aware some domains in Netscape files start with a dot and some don't -- trust me, you really don't want to know any more about this). Note that though Mozilla and Netscape use the same format, they use slightly different headers. The class saves cookies using the Netscape header by default (Mozilla can cope with that). c[R"5n[RUR55(d[ SU-5eUR5=nS:wGaX0nUR [ 5(aSU['U[[ 5SnURS5(aUSSnUR5R S5(dUR5S:XaMURS5upppnU S:Hn U S:Hn U S:XaUn SnUR S5nX:XdeS nU S:XaSn S n[S XSS XUU S U U USSU5nU(dUR(aGM$U(dURU5(aGMDURU5 UR5=nS:waGMWgg![ a e["a [%5 [ S U<S W<35ef=f)Nz4%r does not look like a Netscape format cookies filerrr)#r TRUErFTr z%invalid Netscape format cookies file r)rqNETSCAPE_MAGIC_RGXrrrrHTTPONLY_PREFIX HTTPONLY_ATTRrrrrrrr2rMrrDr")rr ryr}r~rKrr rrrrrrrrrrQs rrMozillaCookieJar._really_loadsiik!'' 55F < .::<'4B. ???33*,D'O 4 56D==&&tCRyJJL++J77JJLB& 4(M$u F*$4$> 2:!D E$//4 '666b="G"G1d![!"" !&!))%!,,s*;*;"i::<'4B..l   . % '%t-. . .s E+F==2G/Nc Uc)URb URnO[[5e[R"[R "U[R [R-[R-S5S5nUR[5 [R"5nUGH'nURnU(dUR(aM*U(dURU5(aMIUR(aSnOSnUR!S5(aSn OSn UR"b[%UR"5n OSn UR&cSn UR(n OUR(n UR&n UR+[,5(a [.U-nURSR1XyUR2XX/5S-5 GM* SSS5 g!,(df  g=f) NrrrFALSErrrr)ryrprrwrrrrrrNETSCAPE_HEADER_TEXTrqrrr2rrrrrrr&rrrr) rryr}r~r rKrOrrrrrrs rrMozillaCookieJar.save"s}  }}(T]]("#899 YY GGHbjj2;;6CU K   GG( )))+C%&..%&*;*;C*@*@==6&&f$$S));$+k>>-!&..1G G<<'D"KKE!;;D"LLE..}==,v5FIIvFKK%=>3    s EG,, G:rIr)rArDrErFrGrrrHrIrrr r s>D.L'rr r$)YrG__all__rwrrJrrq urllib.parserurllib.request threadingr http.clienthttpcalendarr r rrrrrclient HTTP_PORTrrnrrrr"r+r3rVrXrormrTrYrarrrbrhr{rIrXrrrrrrrrrrrrrrrrrrrrrrrrr r rrrrrrrrrrrrrrrr )r.s0rrs6 M  #    --.ZZ @A:A 9 4+126% 62 B&0(T = jj5rxx@  6 p,-/XX7ZZ2BDD288OE ZZ & DD288O)*65pjj 44")) # $5B3 $67$MN$9:::h'Sj ;/2AH **Y ) %N(jj288,    $**9:+ ! F"_E_EDB_,_B "LDLD`4)I4)n"8v.=v.rM}MA;3sJ4