Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 M”ªjr+ã@s*dZddddddddgZd d lZd d lZd d lZd d lZd d lZd d lZy d d l Z Wne k rpd d l Z YnXd d l Zd d lmZd Zd ad d„ZeejjƒZdZdd„ZdZdd„ZdddddddgZddddd d!d"d#d$d%d&d'g ZgZxeD]Zej ej!ƒƒqòWdud(d)„Z"dvd*d+„Z#d d d d d,œZ$ej%d-ej&ƒZ'd.d/„Z(d0d1„Z)ej%d2ej&ƒZ*ej%d3ej+ej&BƒZ,ej%d4ej-ej&BƒZ.d5d6„Z/ej%d7ej-ej&BƒZ0d8d9„Z1d:d;„Z2ej%d<ƒZ3ej%d=ƒZ4ej%d>ƒZ5ej%d?ƒZ6d@dA„Z7ej%dBƒZ8dCdD„Z9dEdF„Z:dGdH„Z;ej%dIej&ƒZdNdO„Z?dPdQ„Z@ej%dRej&ƒZAdSdT„ZBdUdV„ZCdWdX„ZDdYdZ„ZEd[ZFej%d\ƒZGd]d^„ZHd_d`„ZIdadb„ZJdcdd„ZKGded„dƒZLGdfd„dƒZMGdgd„deMƒZNdhdi„ZOdjdk„ZPGdldm„dmƒZQGdnd„dƒZRGdod„deSƒZTGdpd„deRƒZUdqdr„ZVGdsd„deUƒZWGdtd„deUƒZXd S)waªHTTP 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Ú CookiePolicyÚDefaultCookiePolicyÚ FileCookieJarÚ LWPCookieJarÚ LoadErrorÚMozillaCookieJaréN)ÚtimegmFcGs(tsdStsddl}|jdƒatj|ŽS)Nr zhttp.cookiejar)ÚdebugÚloggerÚloggingZ getLogger)Úargsr ©rú!/usr/lib64/python3.6/cookiejar.pyÚ_debug.s  rzQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsJddl}ddl}ddl}|jƒ}|jd|ƒ|jƒ}|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|ko2dknr d|koJdknr d|kobdknr d|kozdknr d|ko’dknr t|ƒSdSdS) Nééé ér éé;é=)Ú EPOCH_YEARr )ÚttÚyearÚmonthZmdayÚhourÚminÚsecrrrÚ_timegmKs 8Hr,ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs@|dkrtjjƒ}n tjj|ƒ}d|j|j|j|j|j|jfS)aHReturn 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 Nz%04d-%02d-%02d %02d:%02d:%02dZ) ÚdatetimeÚutcnowÚutcfromtimestampr'r(Údayr)ÚminuteÚsecond)ÚtÚdtrrrÚ time2isozYs   r5cCsR|dkrtjjƒ}n tjj|ƒ}dt|jƒ|jt|jd|j|j |j |j fS)zðReturn 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 Nz#%s, %02d-%s-%04d %02d:%02d:%02d GMTr) r-r.r/ÚDAYSZweekdayr0ÚMONTHSr(r'r)r1r2)r3r4rrrÚ time2netscapels   r8)ZGMTÚUTCZUTÚZz^([-+])?(\d\d?):?(\d\d)?$cCsjd}|tkrd}nTtj|ƒ}|rfdt|jdƒƒ}|jdƒrR|dt|jdƒƒ}|jdƒdkrf| }|S)Nr iréé<rú-)Ú UTC_ZONESÚ TIMEZONE_REÚsearchÚintÚgroup)ÚtzÚoffsetÚmrrrÚoffset_from_tz_stringƒs  rFc Csˆt|ƒ}|tjkrdSytj|jƒƒd}WnXtk r„y t|ƒ}Wntk r\dSXd|kopdknr||}ndSYnX|dkr’d}|dkržd}|dkrªd}t|ƒ}t|ƒ}t|ƒ}t|ƒ}|dk�r0tjtjƒƒd}|d} |} ||| }| | } t | ƒdk�r0| dk�r(|d}n|d}t |||||||fƒ} | dk �r„|dk�r^d}|j ƒ}t |ƒ} | dk�r|dS| | } | S)Nrr r ièédé2r9) rAr-ZMAXYEARÚ MONTHS_LOWERÚindexÚlowerÚ ValueErrorÚtimeZ localtimeÚabsr,ÚupperrF) r0ÚmonÚyrÚhrr*r+rCZimonZcur_yrrEZtmpr3rDrrrÚ _str2time‘sV         rSzV^[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 CsÜtj|ƒ}|rl|jƒ}tj|djƒƒd}t|dƒ|t|dƒt|dƒt|dƒt|dƒf}t|ƒS|j ƒ}t j d|dƒ}dgd \}}}}}} } t j|ƒ}|dk rÄ|jƒ\}}}}}} } ndSt |||||| | ƒS) aÕReturns 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. rrr r;ééÚNé)ÚSTRICT_DATE_REr@ÚgroupsrIrJrKrAÚfloatr,ÚlstripÚ WEEKDAY_REÚsubÚLOOSE_HTTP_DATE_RErS) ÚtextrEÚgrPr&r0rQrRr*r+rCrrrÚ http2timeßs " raaÆ^ (\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|jƒ}dgd\}}}}}}}tj|ƒ}|dk rL|jƒ\}}}}}}}} ndSt|||||||ƒS)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 NrW)r[Ú ISO_DATE_REr@rYrS) r_r0rPrQrRr*r+rCrEÚ_rrrÚiso2time's  rdcCs*|jdƒ\}}|jd|…|j|d…S)z)Return unmatched part of re.Match object.r N)ÚspanÚstring)ÚmatchÚstartÚendrrrÚ unmatchedHsrjz^\s*([^=\s;,]+)z&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"z^\s*=\s*([^\s;,]*)z\\(.)c Cs<t|tƒ st‚g}�x |D�]}|}g}xú|�r$tj|ƒ}|r¾t|ƒ}|jdƒ}tj|ƒ}|r€t|ƒ}|jdƒ}tj d|ƒ}n.t j|ƒ}|rªt|ƒ}|jdƒ}|j ƒ}nd}|j ||fƒq,|j ƒjdƒrð|j ƒdd…}|rê|j |ƒg}q,tjdd|ƒ\}} | dk�std|||fƒ‚|}q,W|r|j |ƒqW|S) amParse 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"')]] rz\1Nú,z^[=\s;]*rVr z&split_header_words bug: '%s', '%s', %s)Ú isinstanceÚstrÚAssertionErrorÚHEADER_TOKEN_REr@rjrBÚHEADER_QUOTED_VALUE_REÚHEADER_ESCAPE_REr]ÚHEADER_VALUE_REÚrstripÚappendr[Ú startswithÚreÚsubn) Z header_valuesÚresultr_Z orig_textÚpairsrEÚnameÚvalueZnon_junkZ nr_junk_charsrrrÚsplit_header_wordsQsF-         r|z([\"\\])cCs„g}xt|D]l}g}xN|D]F\}}|dk rTtjd|ƒsHtjd|ƒ}d|}d||f}|j|ƒqW|r |jdj|ƒƒq Wdj|ƒS)a»Do 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"' Nz^\w+$z\\\1z"%s"z%s=%sz; z, )rvr@ÚHEADER_JOIN_ESCAPE_REr]rtÚjoin)ZlistsÚheadersryÚattrÚkÚvrrrÚjoin_header_words§s     rƒcCs0|jdƒr|dd…}|jdƒr,|dd…}|S)Nú"réÿÿÿÿ)ruÚendswith)r_rrrÚ strip_quotesÀs     r‡c Csd}g}xô|D]ì}g}d}xÀt|jd ƒƒD]®\}}|jƒ}|jd ƒ\}} } |jƒ}|sd|d kr*Pnq*| rp| jƒnd } |d krÊ|jƒ} | |kr�| }|dkr®| d k r¨t| ƒ} d }n|dkrÊ| d k rÊtt| ƒƒ} |j|| fƒq*W|r|�sð|jdƒ|j|ƒqW|S)a5Ad-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. ÚexpiresÚdomainÚpathÚsecureÚversionÚportúmax-ageFú;ú=r NTÚ0)rˆr‰rŠr‹rŒr�rŽ)rŒr‘)Ú enumerateÚsplitÚstripÚ partitionrKr‡rart) Z ns_headersZ known_attrsrxZ ns_headerryÚ version_setZiiZparamÚkeyÚsepÚvalÚlcrrrÚparse_ns_headersÇs@   r›z\.\d+$cCs:tj|ƒrdS|dkrdS|ddks2|ddkr6dSdS)z*Return True if text is a host domain name.FrVr Ú.rTr…)ÚIPV4_REr@)r_rrrÚis_HDN s ržcCsl|jƒ}|jƒ}||krdSt|ƒs(dS|j|ƒ}|dksB|dkrFdS|jdƒsTdSt|dd…ƒshdSdS)aýReturn 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 rœNr…)rKržÚrfindru)ÚAÚBÚirrrÚ domain_matchs  r£cCstj|ƒrdSdS)zdReturn True if text is a sort-of-like a host domain name. For accepting/blocking domains. FT)r�r@)r_rrrÚliberal_is_HDNBs r¤cCsb|jƒ}|jƒ}t|ƒot|ƒs0||kr,dSdS|jdƒ}|rL|j|ƒrLdS| r^||kr^dSdS)z\For blocking/accepting domains. A and B may be host domain names or IP addresses. TFrœ)rKr¤rur†)r r¡Ú initial_dotrrrÚuser_domain_matchLs r¦z:\d+$cCsB|jƒ}tjj|ƒd}|dkr,|jddƒ}tjd|dƒ}|jƒS)zˆReturn request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. rrVZHost)Ú get_full_urlÚurllibÚparseZurlparseZ get_headerÚ cut_port_rer]rK)ÚrequestÚurlÚhostrrrÚ request_hostas  r®cCs6t|ƒ}}|jdƒdkr.tj|ƒ r.|d}||fS)zzReturn a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased. rœrz.localr…)r®Úfindr�r@)r«ÚerhnÚreq_hostrrrÚeff_request_hostqs r²cCs4|jƒ}tjj|ƒ}t|jƒ}|jdƒs0d|}|S)z6Path component of request-URI, as defined by RFC 2965.ú/)r§r¨r©ZurlsplitÚ escape_pathrŠru)r«r¬ÚpartsrŠrrrÚ request_path|s    r¶c Cs^|j}|jdƒ}|dkrV||dd…}y t|ƒWqZtk rRtd|ƒdSXnt}|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|jdƒjƒS)Nz%%%sr)rBrO)rgrrrÚuppercase_escaped_char˜srºcCstjj|tƒ}tjt|ƒ}|S)zEEscape any invalid characters in HTTP URL, and uppercase all escapes.)r¨r©ZquoteÚHTTP_PATH_SAFEÚESCAPED_CHAR_REr]rº)rŠrrrr´šs  r´cCsP|jdƒ}|dkrL||dd…}|jdƒ}t|ƒrL|dksD|dkrLd|S|S)aBReturn reach of host h, as defined by RFC 2965, section 1. The reach R of a host name H is defined as follows: * If - H is the host domain name of a host; and, - H has the form A.B; and - A has no embedded (that is, interior) dots; and - B has at least one embedded dot, or B is the string "local". then the reach of H is .B. * Otherwise, the reach of H is H. >>> reach("www.acme.com") '.acme.com' >>> reach("acme.com") 'acme.com' >>> reach("acme.local") '.local' rœr rNZlocal)r¯rž)Úhr¢ÚbrrrÚreach¨s  r¿cCs$t|ƒ}t|t|jƒƒsdSdSdS)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. TFN)r®r£r¿Zorigin_req_host)r«r±rrrÚis_third_partyËs rÀc@sNeZdZdZddd„Zdd„Zddd „Zd d „Zdd d „Zdd„Z dd„Z dS)raÐHTTP 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. FcCs°|dk rt|ƒ}| dk r$tt| ƒƒ} |dkr<|dkr)r�r‰rŠr{rz)rËÚpÚlimitZ namevaluerrrÚ__str__%s   zCookie.__str__cCspg}x,dD]$}t||ƒ}|jd|t|ƒfƒq W|jdt|jƒƒ|jdt|jƒƒd|jjdj|ƒfS)NrŒrzr{r�rÁr‰rÂrÃrŠrÄr‹rˆrÅrÆrÇz%s=%szrest=%sz rfc2109=%sz%s(%s)z, )rŒrzr{r�rÁr‰rÂrÃrŠrÄr‹rˆrÅrÆrÇ)ÚgetattrrtÚreprrÊrÈÚ __class__Ú__name__r~)rËrrzr€rrrÚ__repr__/s zCookie.__repr__)F)N)N) rÛÚ __module__Ú __qualname__Ú__doc__rÍrÎrÑrÒrÔr×rÜrrrrrÜs    c@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ra Defines 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. cCs tƒ‚dS)zÄReturn 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. N)ÚNotImplementedError)rËÚcookier«rrrÚset_okGszCookiePolicy.set_okcCs tƒ‚dS)zAReturn true if (and only if) cookie should be returned to server.N)rà)rËrár«rrrÚ return_okPszCookiePolicy.return_okcCsdS)zMReturn false if cookies should not be returned, given cookie domain. Tr)rËr‰r«rrrÚdomain_return_okTszCookiePolicy.domain_return_okcCsdS)zKReturn false if cookies should not be returned, given cookie path. Tr)rËrŠr«rrrÚpath_return_okYszCookiePolicy.path_return_okN)rÛrÝrÞrßrârãrärårrrrr>s  c @súeZdZdZdZdZdZdZeeBZdddddddddeddf d d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„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)7rzBImplements the standard rules for accepting and returning cookies.rrrTr NTFc Csp||_||_||_||_||_||_| |_| |_| |_| |_ |dk rPt |ƒ|_ nf|_ |dk rft |ƒ}||_ dS)zAConstructor arguments should be passed as keyword arguments only.N) Ú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ÚtupleÚ_blocked_domainsÚ_allowed_domains) rËÚblocked_domainsÚallowed_domainsrærçrèrérêrërìrírîrïrrrrÍis  zDefaultCookiePolicy.__init__cCs|jS)z4Return the sequence of blocked domains (as a tuple).)rñ)rËrrrróŠsz#DefaultCookiePolicy.blocked_domainscCst|ƒ|_dS)z$Set the sequence of blocked domains.N)rðrñ)rËrórrrÚset_blocked_domains�sz'DefaultCookiePolicy.set_blocked_domainscCs"x|jD]}t||ƒrdSqWdS)NTF)rñr¦)rËr‰Zblocked_domainrrrÚ is_blocked‘s  zDefaultCookiePolicy.is_blockedcCs|jS)z=Return None, or the sequence of allowed domains (as a tuple).)rò)rËrrrrô—sz#DefaultCookiePolicy.allowed_domainscCs|dk rt|ƒ}||_dS)z-Set the sequence of allowed domains, or None.N)rðrò)rËrôrrrÚset_allowed_domainsšsz'DefaultCookiePolicy.set_allowed_domainscCs0|jdkrdSx|jD]}t||ƒrdSqWdS)NFT)ròr¦)rËr‰Zallowed_domainrrrÚis_not_allowed s    z"DefaultCookiePolicy.is_not_allowedcCsPtd|j|jƒ|jdk st‚x,d D]$}d |}t||ƒ}|||ƒs$d Sq$Wd S) 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). z - checking cookie %s=%sNrŒÚ verifiabilityrzrŠr‰r�Zset_ok_FT)rŒrùrzrŠr‰r�)rrzr{rnrØ)rËrár«ÚnÚfn_nameÚfnrrrrâ¨s   zDefaultCookiePolicy.set_okcCs^|jdkrtd|j|jƒdS|jdkr<|j r third-party RFC 2965 cookie during unverifiable transactionFz> third-party Netscape cookie during unverifiable transactionT)Ú unverifiablerÀrŒrërrì)rËrár«rrrÚset_ok_verifiabilityÊsz(DefaultCookiePolicy.set_ok_verifiabilitycCs0|jdkr,|jr,|jjdƒr,td|jƒdSdS)Nr ú$z' illegal name (starts with '$'): '%s'FT)rŒrîrzrur)rËrár«rrrÚ set_ok_nameÖs   zDefaultCookiePolicy.set_ok_namecCsL|jrHt|ƒ}|jdks(|jdkrH|jrH|j|jƒ rHtd|j|ƒdSdS)Nr z7 path attribute %s is not a prefix of request path %sFT)rÄr¶rŒrïrurŠr)rËrár«Úreq_pathrrrÚ set_ok_pathßs  zDefaultCookiePolicy.set_ok_pathc Csö|j|jƒrtd|jƒdS|j|jƒr8td|jƒdS|j�ròt|ƒ\}}|j}|jrÌ|jdƒdkrÌ|jdƒ}|jdd|ƒ}|dkrÌ||dd…}||d|…} | j ƒd$krÌt |ƒdkrÌtd|ƒdS|j dƒ�ræ|dd…} n|} | j dƒdk} | �r|dk�rtd|ƒdS|j dk�rb|j|ƒ �rb|j dƒ �rbd|j|ƒ �rbtd ||ƒdS|j dk�s||j|j@�r˜t||ƒ�s˜td!||ƒdS|j dk�s²|j|j@�rò|dt |ƒ …} | j dƒdk�ròtj|ƒ �ròtd"| |ƒdSd#S)%Nz" domain %s is in user block-listFz& domain %s is not in user allow-listrœrr rÚcoÚacÚcomÚeduÚorgÚnetÚgovÚmilrAÚaeroÚbizÚcatÚcoopÚinfoÚjobsÚmobiÚmuseumrzÚproÚtravelÚeuz& country-code second level domain %sz.localz/ 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)rrrrrr r r rAr r rrrrrrrzrrr)rör‰rrørÂr²rêÚcountrŸrKÚlenrur¯rŒr†ríÚDomainRFC2965Matchr£ÚDomainStrictNoDotsr�r@) rËrár«r±r°r‰r¢ÚjZtldZsldZundotted_domainZ embedded_dotsZ host_prefixrrrÚ set_ok_domainêsf            z!DefaultCookiePolicy.set_ok_domainc Cs†|jr‚t|ƒ}|dkrd}nt|ƒ}x\|jjdƒD]:}y t|ƒWntk r`td|ƒdSX||kr2Pq2Wtd||jƒdSdS)NÚ80rkz bad port %s (not numeric)Fz$ request port (%s) not found in %sT)rÁr¹rmr�r“rArLr)rËrár«Úreq_portrÕrrrÚ set_ok_port%s"   zDefaultCookiePolicy.set_ok_portcCsBtd|j|jƒx,d D]$}d|}t||ƒ}|||ƒsd SqWd S) 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). z - checking cookie %s=%srŒrùr‹rˆr�r‰Z return_ok_FT)rŒrùr‹rˆr�r‰)rrzr{rØ)rËrár«rúrûrürrrrã:s    zDefaultCookiePolicy.return_okcCs@|jdkr|j rtdƒdS|jdkr<|j r third-party RFC 2965 cookie during unverifiable transactionFz> third-party Netscape cookie during unverifiable transactionT)rþrÀrŒrërrì)rËrár«rrrÚreturn_ok_verifiabilityUsz+DefaultCookiePolicy.return_ok_verifiabilitycCs |jr|jdkrtdƒdSdS)NZhttpsz( secure cookie with non-secure requestFT)r‹Útyper)rËrár«rrrÚreturn_ok_secureasz$DefaultCookiePolicy.return_ok_securecCs|j|jƒrtdƒdSdS)Nz cookie expiredFT)rÔÚ_nowr)rËrár«rrrÚreturn_ok_expiresgs z%DefaultCookiePolicy.return_ok_expirescCsP|jrLt|ƒ}|dkrd}x0|jjdƒD]}||kr(Pq(Wtd||jƒdSdS)Nrrkz0 request port %s does not match cookie port %sFT)r�r¹r“r)rËrár«rrÕrrrÚreturn_ok_portms z"DefaultCookiePolicy.return_ok_portcCs¶t|ƒ\}}|j}|r,|jdƒ r,d|}n|}|jdkrb|j|j@rb|j rb||krbtdƒdS|jdkrˆt||ƒ rˆtd||ƒdS|jdkr²d|j |ƒ r²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‰rurŒríÚDomainStrictNonDomainrÂrr£r†)rËrár«r±r°r‰Ú dotdomainrrrÚreturn_ok_domain{s&    z$DefaultCookiePolicy.return_ok_domaincCsšt|ƒ\}}|jdƒsd|}|jdƒs0d|}|rJ|jdƒ rJd|}n|}|j|ƒp`|j|ƒsfdS|j|ƒr~td|ƒdS|j|ƒr–td|ƒdSdS)NrœFz" domain %s is in user block-listz& domain %s is not in user allow-listT)r²rur†rörrø)rËr‰r«r±r°r(rrrrä–s"        z$DefaultCookiePolicy.domain_return_okcCs0td|ƒt|ƒ}|j|ƒs,td||ƒdSdS)Nz- checking cookie path=%sz %s does not path-match %sFT)rr¶ru)rËrŠr«rrrrrå°s    z"DefaultCookiePolicy.path_return_ok) rÛrÝrÞrßrr'rZ DomainLiberalZ DomainStrictrÍrórõrörôr÷rørârýrÿrrrrrãr r!r#r%r&r)rärårrrrr_sL    ;  cCst|jƒƒ}t|j|ƒS)N)ÚsortedÚkeysÚmaprÏ)Zadictr+rrrÚvals_sorted_by_key¹s r-c csZt|ƒ}xL|D]D}d}y |jWntk r4YnXd}t|ƒEdH|s|VqWdS)zBIterates over nested mapping, depth-first, in sorted order by key.FTN)r-ÚitemsÚAttributeErrorÚ deepvalues)ÚmappingÚvaluesÚobjrrrr0½s  r0c@s eZdZdS)ÚAbsentN)rÛrÝrÞrrrrr4Ïsr4c@süeZdZdZejdƒZejdƒZejdƒZejdƒZ ejdƒZ ejdej ƒZ d3d d „Z d d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd4d%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Z d1d2„Z!dS)5rz”Collection of HTTP cookies. You may not need to know about this class: try urllib.request.build_opener(HTTPCookieProcessor).open(url). z\Wz([\"\\])z\.?[^.]*z[^.]*z^\.+z^\#LWP-Cookies-(\d+\.\d+)NcCs(|dkrtƒ}||_tjƒ|_i|_dS)N)rÚ_policyÚ _threadingÚRLockÚ _cookies_lockÚ_cookies)rËÚpolicyrrrrÍàs  zCookieJar.__init__cCs ||_dS)N)r5)rËr:rrrÚ set_policyèszCookieJar.set_policycCs”g}|jj||ƒsgStd|ƒ|j|}xd|jƒD]X}|jj||ƒsHq4||}x:|jƒD].}|jj||ƒsvtdƒqZtdƒ|j|ƒqZWq4W|S)Nz!Checking %s for cookies to returnz not returning cookiez it's a match) r5rärr9r+rår2rãrt)rËr‰r«ÚcookiesZcookies_by_pathrŠZcookies_by_namerárrrÚ_cookies_for_domainës   zCookieJar._cookies_for_domaincCs.g}x$|jjƒD]}|j|j||ƒƒqW|S)z2Return a list of cookies to be returned to server.)r9r+Úextendr=)rËr«r<r‰rrrÚ_cookies_for_requestýszCookieJar._cookies_for_requestc CsF|jdd„dd�d}g}�x$|D�]}|j}|sLd}|dkrL|jd|ƒ|jdk r~|jj|jƒr~|dkr~|jjd |jƒ}n|j}|jdkrœ|j|jƒn|jd |j|fƒ|dkr"|j rÎ|jd |j ƒ|j j d ƒ�r|j }|j oò|j d ƒ�r|d d…}|jd|ƒ|jdk r"d}|j�r4|d|j}|j|ƒq"W|S)zÜReturn 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). cSs t|jƒS)N)rrŠ)ÚarrrÚsz)CookieJar._cookie_attrs..T)r—ÚreverseFr z $Version=%sNz\\\1z%s=%sz $Path="%s"rœrz $Domain="%s"z$Portz="%s")ÚsortrŒrtr{Ú non_word_rer@Úquote_rer]rzrÄrŠr‰rurÃr�rÁ) rËr<r–ÚattrsrárŒr{r‰rÕrrrÚ _cookie_attrss>      zCookieJar._cookie_attrsc Cs¾tdƒ|jjƒz’ttjƒƒ|j_|_|j|ƒ}|j|ƒ}|r^|j dƒs^|j ddj |ƒƒ|jj r¢|jj r¢|j dƒ r¢x$|D]}|jdkr‚|j ddƒPq‚WWd|jjƒX|jƒdS)zžAdd correct Cookie: header to request (urllib.request.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. Úadd_cookie_headerrz; ZCookie2rz $Version="1"N)rr8ÚacquirerArMr5r$r?rGZ has_headerZadd_unredirected_headerr~rçrérŒÚreleaseÚclear_expired_cookies)rËr«r<rFrárrrrH?s$          zCookieJar.add_cookie_headercCs�g}d}d}�x||D�]r}|d \}}d }d } i} i} �x4|d d…D�]"\} } | jƒ}||ksh||krl|} | |kr€| dkr€d} | | krŠqF| dkr°| dkr¨tdƒd} P| jƒ} | dkrÐ|r¾qF| dkrÐtdƒqF| dk�rd}y t| ƒ} Wn$tk �rtdƒd} PYnXd} |j| } | |k�s2| |k�rb| dk�rX| dk�rXtd| ƒd} P| | | <qF| | | <qFW| �rvq|j||| | fƒqW|S)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. rÅr‹rŒrˆúmax-ager‰rŠr�rÆÚ commenturlr FrNTz% missing value for domain attributezM missing or invalid value for expires attribute: treating as session cookiez? missing or invalid (non-numeric) value for max-age attributez! missing value for %s attribute)rÅr‹)rŒrˆrLr‰rŠr�rÆrM)r�rÆrM)rKrrArLr$rt)rËÚ attrs_setÚ cookie_tuplesÚ boolean_attrsÚ value_attrsZ cookie_attrsrzr{Z max_age_setZ bad_cookieÚstandardrÌr�r‚ršrrrÚ_normalized_cookie_tuples`sl          z#CookieJar._normalized_cookie_tuplesc!Cs$|\}}}}|jdtƒ}|jdtƒ}|jdtƒ} |jdtƒ} |jddƒ} | dk rry t| ƒ} Wntk rpdSX|jddƒ} |jddƒ} |jd dƒ}|jd dƒ}|tk rÀ|d krÀd }t|ƒ}nXd}t|ƒ}|jd ƒ}|dk�r| dkrö|d|…}n|d|d…}t|ƒdk�rd }|tk }d}|�r8t|j dƒƒ}|tk�rTt |ƒ\}}|}n|j dƒ�shd|}d}| tk �rž| dk�rŠt |ƒ} nd }t j dd | ƒ} nd} | tk�r¶d} d } nH| |jk�rþy|j|||ƒWntk �rêYnXtd|||ƒdSt| ||| ||||||| | | |||ƒS)Nr‰rŠr�rˆrŒr‹FrÅrÆrMrVTr³rr rœz\s+z2Expiring cookie, domain='%s', path='%s', name='%s'r…)rÏr4rArLr´r¶rŸrÚboolrur²r¹rvr]r$ÚclearÚKeyErrorrr)rËÚtupr«rzr{rRrÌ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_tuplecCs:|j|ƒ}g}x&|D]}|j||ƒ}|r|j|ƒqW|S)N)rSrXrt)rËrNr«rOr<rWrárrrÚ_cookies_from_attrs_sets   z!CookieJar._cookies_from_attrs_setcCsLt|jddƒ}|dkr |jj }x&|D]}|jdkr&d|_|r&d|_q&WdS)NrèrTr )rØr5rçrŒrÈ)rËr<Z rfc2109_as_nsrárrrÚ_process_rfc2109_cookies&s   z"CookieJar._process_rfc2109_cookiesc Cs6|jƒ}|jdgƒ}|jdgƒ}|jj}|jj}| r<| s`| rH| s`| rT| s`| rd| rdgSy|jt|ƒ|ƒ}Wntk r–tƒg}YnX|ož|�r2y|jt |ƒ|ƒ} Wntk rÔtƒg} YnX|j | ƒ|�r"i} x |D]} d| | j | j | j f<qðW| fdd„} t| | ƒ} | �r2|j| ƒ|S)zAReturn sequence of Cookie objects extracted from response object.z Set-Cookie2z Set-CookieNcSs|j|j|jf}||kS)N)r‰rŠrz)Z ns_cookieÚlookupr—rrrÚno_matching_rfc2965^sz3CookieJar.make_cookies..no_matching_rfc2965)rZget_allr5rçrærYr|Ú Exceptionrr›rZr‰rŠrzÚfilterr>) rËÚresponser«rZ rfc2965_hdrsZns_hdrsrçrær<Z ns_cookiesr[rár\rrrÚ make_cookies2sB              zCookieJar.make_cookiesc CsN|jjƒz2ttjƒƒ|j_|_|jj||ƒr:|j|ƒWd|jjƒXdS)z-Set a cookie if policy says it's OK to do so.N) r8rIrArMr5r$râÚ set_cookierJ)rËrár«rrrÚset_cookie_if_okhs  zCookieJar.set_cookie_if_okc Csl|j}|jjƒzJ|j|kr&i||j<||j}|j|krDi||j<||j}|||j<Wd|jjƒXdS)z?Set a cookie, without checking whether or not it should be set.N)r9r8rIr‰rŠrzrJ)rËráÚcZc2Zc3rrrraus     zCookieJar.set_cookiec Cs|td|jƒƒ|jjƒzRttjƒƒ|j_|_x6|j||ƒD]&}|jj ||ƒr>td|ƒ|j |ƒq>WWd|jj ƒXdS)zAExtract cookies from response, where allowable given the request.zextract_cookies: %sz setting cookie: %sN) rrr8rIrArMr5r$r`rârarJ)rËr_r«rárrrÚextract_cookies‚s  zCookieJar.extract_cookiescCst|dk r2|dks|dkr tdƒ‚|j|||=n>|dk rX|dkrJtdƒ‚|j||=n|dk rj|j|=ni|_dS)aÑClear 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)rLr9)rËr‰rŠrzrrrrU�s  zCookieJar.clearc CsH|jjƒz,x&|D]}|jr|j|j|j|jƒqWWd|jjƒXdS)z»Discard 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)r8rIrÅrUr‰rŠrzrJ)rËrárrrÚclear_session_cookies«s   zCookieJar.clear_session_cookiesc CsT|jjƒz8tjƒ}x*|D]"}|j|ƒr|j|j|j|jƒqWWd|jjƒXdS)a”Discard 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) r8rIrMrÔrUr‰rŠrzrJ)rËrÓrárrrrKºs   zCookieJar.clear_expired_cookiescCs t|jƒS)N)r0r9)rËrrrÚ__iter__ÍszCookieJar.__iter__cCsd}x|D] }|d}q W|S)z#Return number of contained cookies.r rr)rËr¢rárrrÚ__len__Ðs zCookieJar.__len__cCs6g}x|D]}|jt|ƒƒq Wd|jjdj|ƒfS)Nz<%s[%s]>z, )rtrÙrÚrÛr~)rËÚrrárrrrÜÖs zCookieJar.__repr__cCs6g}x|D]}|jt|ƒƒq Wd|jjdj|ƒfS)Nz<%s[%s]>z, )rtrmrÚrÛr~)rËrhrárrrr×Ûs zCookieJar.__str__)N)NNN)"rÛrÝrÞrßrvÚcompilerDrEZstrict_domain_reZ domain_reZdots_reÚASCIIÚmagic_rerÍr;r=r?rGrHrSrXrYrZr`rbrardrUrerKrfrgrÜr×rrrrrÑs8      ;!a\  6   c@s eZdZdS)rN)rÛrÝrÞrrrrrâsc@s8eZdZdZd dd„Zd dd„Zddd „Zdd d „ZdS)rz6CookieJar that can be loaded from and saved to a file.NFc CsJtj||ƒ|dk r6y |dWntdƒ‚YnX||_t|ƒ|_dS)z} Cookies are NOT loaded from the named file until either the .load() or .revert() method is called. NrVzfilename must be string-like)rrÍrLÚfilenamerTÚ delayload)rËrlrmr:rrrrÍçs  zFileCookieJar.__init__cCs tƒ‚dS)zSave cookies to a file.N)rà)rËrlÚignore_discardÚignore_expiresrrrÚsaveöszFileCookieJar.savec CsJ|dkr"|jdk r|j}nttƒ‚t|ƒ�}|j||||ƒWdQRXdS)zLoad cookies from a file.N)rlrLÚMISSING_FILENAME_TEXTÚopenÚ _really_load)rËrlrnrorrrrÚloadús   zFileCookieJar.loadcCs„|dkr"|jdk r|j}nttƒ‚|jjƒzFtj|jƒ}i|_y|j|||ƒWnt k rn||_‚YnXWd|jj ƒXdS)zÈClear 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) rlrLrqr8rIrÉÚdeepcopyr9rtÚOSErrorrJ)rËrlrnroZ old_staterrrÚreverts    zFileCookieJar.revert)NFN)NFF)NFF)NFF)rÛrÝrÞrßrÍrprtrwrrrrräs    cCs$|j|jfd|jfd|jfg}|jdk r8|jd|jfƒ|jrH|jdƒ|jrX|jdƒ|jrh|jdƒ|j rx|jdƒ|j r–|jd t t |j ƒƒfƒ|j r¦|jdƒ|jr¼|jd |jfƒ|jrÒ|jd |jfƒt|jjƒƒ}x$|D]}|j|t|j|ƒfƒqæW|jd t|jƒfƒt|gƒS)z�Return string representation of Cookie in the LWP cookie file format. Actually, the format is extended a bit -- see module docstring. rŠr‰Nr�Ú path_specÚ port_specÚ domain_dotr‹rˆrÅrÆrMrŒ)rxN)ryN)rzN)r‹N)rÅN)rzr{rŠr‰r�rtrÄrÁrÃr‹rˆr5rZrÅrÆrÇr*rÊr+rmrŒrƒ)rár½r+r�rrrÚlwp_cookie_strs6         r{c@s,eZdZdZd dd„Zd dd„Zd d „ZdS) ra[ 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) TcCs\tjƒ}g}x>|D]6}| r$|jr$q| r6|j|ƒr6q|jdt|ƒƒqWdj|dgƒS)zžReturn cookies as a string of "\n"-separated "Set-Cookie3" headers. ignore_discard and ignore_expires: see docstring for FileCookieJar.save zSet-Cookie3: %sÚ rV)rMrÅrÔrtr{r~)rËrnrorÓrhrárrrÚ as_lwp_strGs  zLWPCookieJar.as_lwp_strNFc CsX|dkr"|jdk r|j}nttƒ‚t|dƒ�"}|jdƒ|j|j||ƒƒWdQRXdS)NÚwz#LWP-Cookies-2.0 )rlrLrqrrÚwriter})rËrlrnrorrrrrpWs   zLWPCookieJar.savecCsL|jƒ}|jj|ƒs$d|}t|ƒ‚tjƒ}d}d} d} �yÊ�xÂ|jƒ} | dkrRP| j|ƒs^q@| t|ƒd…jƒ} �xˆt| gƒD�]x} | d\} }i}i}x| D] }d||<q Wx„| dd…D]t\}}|dk rØ|j ƒ}nd}|| k�sð|| k�rô|}|| k�r|dk�r d}|||<q¾|| k�r*|||<q¾|||<q¾W|j }|d ƒ}|dƒ}|dk �r^t |ƒ}|dk�rld}|d ƒ}|jdƒ}t |dƒ| ||d ƒ|dƒ|||dƒ|d ƒ|dƒ|dƒ|||d ƒ|dƒ|ƒ}| �rÚ|j �rÚq€| �rð|j|ƒ�rðq€|j|ƒq€Wq@WWnBtk �r‚Yn,tk �rFtƒtd|| fƒ‚YnXdS)Nz5%r does not look like a Set-Cookie3 (LWP) format filez Set-Cookie3:ryrxrzr‹rÅrŒr�rŠr‰rˆrÆrMrVr FrTrœz&invalid Set-Cookie3 format file %r: %r)ryrxrzr‹rÅ)rŒr�rŠr‰rˆrÆrM)Úreadlinerkr@rrMrurr”r|rKrÏrdrrÅrÔrarvr]r)rËrrlrnroÚmagicrrÓÚheaderrPrQÚlineÚdatarzr{rRrÌr�r‚ršr½rˆrÅr‰rÂrcrrrrscsŒ                   zLWPCookieJar._really_load)TT)NFF)rÛrÝrÞrßr}rprsrrrrr:s   c@s0eZdZdZejdƒZdZdd„Zd dd „Z dS) ra’ 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. lynx uses 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). z#( 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|tjƒ}|jƒ}|jj|ƒs(td|ƒ‚�y �x|jƒ}|dkrBP|jdƒrX|dd…}|jƒjdƒs0|jƒdkrtq0|jdƒ\}} } } } } }| dk} | dk} | dkr¬|} d}|jd ƒ}| |ksÂt ‚d }| dkrÖd} d }t d | |dd || || d | | |ddiƒ}| �r|j �rq0| �r$|j |ƒ�r$q0|j |ƒq0WWnBtk �rL‚Yn,tk �rvtƒtd ||fƒ‚YnXdS)Nz4%r does not look like a Netscape format cookies filerVr|rú#rú ÚTRUErœFTr z+invalid Netscape format cookies file %r: %rr…)r…r)rMr€rkr@rr†r”rur“rnrrÅrÔrarvr]r)rËrrlrnrorÓr�rƒr‰rÂrŠr‹rˆrzr{r¥rÅrcrrrrsÙsb     zMozillaCookieJar._really_loadNFc Cs|dkr"|jdk r|j}nttƒ‚t|dƒ�Ð}|j|jƒtjƒ}x´|D]¬}| rZ|jrZqH| rl|j|ƒrlqH|j rxd}nd}|j j dƒrŽd}nd}|j dk r¨t |j ƒ} nd} |jdkrÂd} |j} n |j} |j} |jdj|j ||j|| | | gƒdƒqHWWdQRXdS)Nr~r‡ZFALSErœrVr†r|)rlrLrqrrrr‚rMrÅrÔr‹r‰rurˆrmr{rzr~rŠ) rËrlrnrorrÓrár‹r¥rˆrzr{rrrrps<          zMozillaCookieJar.save)NFF) rÛrÝrÞrßrvrirkr‚rsrprrrrr²s  A)N)N)YrßÚ__all__rÉr-rvrMZ urllib.parser¨Zurllib.requestZ threadingr6Ú ImportErrorZdummy_threadingZ http.clientZhttpZcalendarr r r rrmZclientZ HTTP_PORTr¸rqrr%r,r6r7rIr(rtrKr5r8r>rirjr?rFrSrXÚIr\ÚXr^rarbrdrjrorprrrqr|r}rƒr‡r›r�ržr£r¤r¦rªr®r²r¶r¹r»r¼rºr´r¿rÀrrrr-r0r4rrvrrr{rrrrrrÚs°        88!    U D'    #b!\:x