+
    BiH                       R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
t
^ RIt^ RIt^ RIHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtHtH t H!t!H"t"H#t#H$t$H%t% ]PL                  R8H  t' ! R R]PP                  4      t) ! R	 R
]PP                  4      t* ! R R4      t+R t,R t-R t. ! R R]PP                  4      t/ ! R R]PP                  4      t0 ! R R]PP                  4      t1]2R8X  d   ]Pf                  ! 4        R# R# )zTests for http/cookiejar.py.N)support)	os_helper)warnings_helper)	time2isoz	http2timeiso2timetime2netscapeparse_ns_headersjoin_header_wordssplit_header_wordsCookie	CookieJarDefaultCookiePolicyLWPCookieJarMozillaCookieJar	LoadErrorlwp_cookie_strDEFAULT_HTTP_PORTescape_pathreachis_HDNdomain_matchuser_domain_matchrequest_pathrequest_portrequest_hostwin32c                      a  ] tR t^t o R tR tR tR t]P                  ! R. RO4      R 4       t
R tR t]P                  ! R	. RO4      R
 4       t]P                  ! R. RO4      R 4       tR tRtV tR# )DateTimeTestsc           	        R pR
pV P                  \        V4      R4       V P                  \        W,           4      R4       V P                  \        V^V,          ,           4      R4       V P                  \        V^V,          ,           4      R4       \        4       p\        R4      pW43 F  pV P                  VRRV: RV: 24       K   	  R	# )x+<z2002-04-19 14:36:40Zz2002-04-20 14:36:40Zz2002-04-21 14:36:40Zz2002-04-22 14:36:40Z  z!^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$zbad time2isoz format:  NQ )assertEqualr   assertRegexselfbasedayazbztexts   &     //usr/lib/python3.14/test/test_http_cookiejar.pytest_time2isozDateTimeTests.test_time2isoz   s    4*@A48,.DE4#:.0FG4#:.0FG[vHDT#G>@"EG     c           	        R pR
pV P                  \        V4      R4       V P                  \        W,           4      R4       V P                  \        V^V,          ,           4      R4       V P                  \        V^V,          ,           4      R4       \        4       p\        R4      pW43 F  pV P                  VRRV: RV: 24       K   	  R	# )r    zFri, 19-Apr-2002 14:36:40 GMTzSat, 20-Apr-2002 14:36:40 GMTzSun, 21-Apr-2002 14:36:40 GMTzMon, 22-Apr-2002 14:36:40 GMTr!   z;[a-zA-Z]{3}, \d{2}-[a-zA-Z]{3}-\d{4} \d{2}:\d{2}:\d{2} GMT$zbad time2netscape format: r"   Nr#   )r$   r   r%   r&   s   &     r-   test_time2netscape DateTimeTests.test_time2netscape'   s    t,.MNtx08	: 	tAcEz28	: 	tAcEz28	: _6"HDN57<> r0   c                    R  pV P                  V! R4      R4       V P                  V! R4      R4       V P                  V! R4      R4       R# )c                 N    \         P                  ! \        V 4      4      R ,          # :N   N)timegmtimer   r,   s   &r-   
parse_date0DateTimeTests.test_http2time.<locals>.parse_date>   s    ;;y/33r0   z01 Jan 2001z	03-Feb-20z	03-Feb-98N)i     r=       r>           )i        r>   r>   r?   )i  r@   rA   r>   r>   r?   r$   r'   r;   s   & r-   test_http2timeDateTimeTests.test_http2time=   sO    	4 	M24KL 	K02IJ 	K02IJr0   c           
        . ROpRp\        V4      pRpV P                  W4V: RV: RV: R24       V F  pV P                  \        V4      W%4       V P                  \        VP                  4       4      W%P                  4       4       V P                  \        VP	                  4       4      W%P	                  4       4       K  	  R# )Thu, 03 Feb 1994 00:00:00 GMT>P-z1994-02-03 00:00:00Zz  =>  'z' ()N)rG    Thursday, 03-Feb-94 00:00:00 GMTz"Thursday, 03-Feb-1994 00:00:00 GMTz03 Feb 1994 00:00:00 GMTz03-Feb-94 00:00:00 GMTz03-Feb-1994 00:00:00 GMTz03-Feb-1994 00:00 GMTz03-Feb-1994 00:00z02-Feb-1994 24:00z	03-Feb-94z03-Feb-1994z03 Feb 1994z  03   Feb   1994  0:00  z  03-Feb-1994  )r   r$   r   lowerupper)r'   teststest_tresultexpectedss   &     r-   test_http2time_formats$DateTimeTests.test_http2time_formatsI   s    
, 6")06I	K AYq\65Yqwwy16779EYqwwy16779E r0   testc                :    V P                  \        V4      4       R # N)assertIsNoner   r'   rT   s   &&r-   test_http2time_garbage$DateTimeTests.test_http2time_garbagem   s    " 	)D/*r0   c                    \        R P                  RR,          4      4       \        RP                  RR,          4      4       R# )z01 Jan 1970{}00:00:00 GMT!r"   z01 Jan 1970 00:00:00{}GMT!Ni )r   formatr'   s   &r-   2test_http2time_redos_regression_actually_completes@DateTimeTests.test_http2time_redos_regression_actually_completes   s4     	.55cGmDE.55cGmDEr0   c                    R  pV P                  V! R4      R4       V P                  V! R4      R4       V P                  V! R4      R4       R# )c                 N    \         P                  ! \        V 4      4      R ,          # r6   )r8   r9   r   r:   s   &r-   r;   /DateTimeTests.test_iso2time.<locals>.parse_date   s    ;;x~.r22r0   19940203T141529Zz1994-02-03 07:15:29 -0700z1994-02-03 19:45:29 +0530N)i  r@   rA            rB   rC   s   & r-   test_iso2timeDateTimeTests.test_iso2time   sX    	3 	$671	3 	$?@1	3 	$?@1	3r0   rQ   c                   R pV P                  \        V4      W!4       V P                  \        VP                  4       4      W!P                  4       4       V P                  \        VP                  4       4      W!P                  4       4       R# )rH   N)r$   r   rK   rL   )r'   rQ   rN   s   && r-   test_iso2time_formats#DateTimeTests.test_iso2time_formats   s_      !f0!''),fggi@!''),fggi@r0   c                :    V P                  \        V4      4       R # rV   )rW   r   rX   s   &&r-   test_iso2time_garbage#DateTimeTests.test_iso2time_garbage   s     	(4.)r0   c                    \        R P                  RR,          4      4       \        RP                  RR,          4      4       R# )z1994-02-03{}14:15:29 -0100!r"   z1994-02-03 14:15:29{}-0100!Ni@B )r   r\   r]   s   &r-   $test_iso2time_performance_regression2DateTimeTests.test_iso2time_performance_regression   s4     	.55c%i@A.55c%i@Ar0    N) GarbagezMandag 16. September 1996z
01-00-1980z
01-13-1980z
00-01-1980z
32-01-1980z01-01-1980 25:00:00z01-01-1980 00:61:0001-01-1980 00:00:62z08-Oct-3697739z08-01-3697739z09 Feb 19942632 22:23:32 GMTz Wed, 09 Feb 1994834 22:23:32 GMT)
z1994-02-03 00:00:00 -0000z1994-02-03 00:00:00 +0000z1994-02-03 00:00:00z
1994-02-03z1994-02-03T00:00:0019940203z1994-02-02 24:00:0019940203T000000Zz  1994-02-03 z  1994-02-03T00:00:00  )rs   rt   rJ   z
1980-00-01z
1980-13-01z
1980-01-00z
1980-01-32z1980-01-01 25:00:00z1980-01-01 00:61:00ru   z01-01-1980T00:00:6219800101T250000Z)__name__
__module____qualname____firstlineno__r.   r2   rD   rR   r   subTestsrY   r^   rg   rj   rm   rp   __static_attributes____classdictcell____classdict__s   @r-   r   r      s     G>,
K"FH f 
  +! +F3  c 
 AA f 
 **B Br0   r   c                     a  ] tR t^t o ]P
                  ! RRR.4      R 4       t]P
                  ! RRR.4      R 4       tR t]P
                  ! R	R#R$..R3. R3. .R3R%..R3R&..R3R'R(.R)..R3R*R#.R)..R3.4      R 4       t	]P
                  ! RR
R#..3RR+..3RR#..3RR,..3RR,..3RR,..3RR,R$..3RR+R$..3RR-..3RR+R$..3R. R.O.3RR/.R0.R1..3RR#R$.R2.R3.R4..3.4      R  4       t
]P
                  ! R. R5O4      R! 4       tR"tV tR# )6HeaderTestshdrz)foo=bar; expires=01 Jan 2040 22:23:32 GMTz+foo=bar; expires="01 Jan 2040 22:23:32 GMT"c                H    . RO.pV P                  \        V.4      V4       R# )fooN)r   bar)expiresl   d9W version0r$   r	   r'   r   rP   s   && r-   test_parse_ns_headers!HeaderTests.test_parse_ns_headers   s%     PP)3%0(;r0   zfoo=bar; version="1"foo=bar; Version="1"c                H    RR..pV P                  \        V.4      V4       R# )r   Nr   )r   1r   r   s   && r-   test_parse_ns_headers_version)HeaderTests.test_parse_ns_headers_version   s*     $%567)3%0(;r0   c                L    R pRR..pV P                  \        V.4      V4       R# )z expires=01 Jan 2040 22:23:32 GMTN)r   z01 Jan 2040 22:23:32 GMTr   r   r   s   &  r-   #test_parse_ns_headers_special_names/HeaderTests.test_parse_ns_headers_special_names   s/     1<>NOP)3%0(;r0   zsrc,expectedr   Nzfoo; bar=bazrs   za=_za=";"zn; foo="foo;_", bar=foo_barzn=m; foo, bar=foo_barc                <    V P                  \        V4      V4       R # rV   )r$   r
   )r'   srcrP   s   &&&r-   test_join_header_words"HeaderTests.test_join_header_words   s     	*3/:r0   z
arg,expectfoo=bar	   foo   z
   foo=   z   foo=z   foo=   ; z   foo=   ; bar= baz foo=bar bar=bazzfoo= bar=bazfoo=bar;bar=bazfoo bar bazza, b, cz(foo; bar=baz, spam=, foo="\,\;\"", bar= c                     \        V.4      pT P                  Y2RT: RT: RT: R24       R#    ^ RIp^ RIpTP                  4       pTP	                  RT4       RTP                  4       ,          p Lf; i)r>   Nz (error -- traceback follows)

%s
When parsing: ''
Expected:     ''
Got:          ''
)r   	tracebackioStringIO	print_excgetvaluer$   )r'   argexpectrO   r   r   fs   &&&    r-   test_split_header_words#HeaderTests.test_split_header_words   sl    &	I'.F 	& FF	+ 		I Aa(9AJJLHFs
   / AA4c                z    \        V.4      p\        V4      pV P                  WBR V: RV: RV: RV: R2	4       R# )r   r   r   z'
Input was:    'r   N)r   r
   r$   )r'   r   r   inputress   &&&  r-   test_roundtripHeaderTests.test_roundtrip  s=    F #C5)&f
 FC'  	!r0   rr   r   N)r   baz)a_)r   ;)nN)r   zfoo;_)r   foo_bar)r   mr   )r   rs   )r   zbar=baz)r   )r   N)r   N)r   N)bN)cN)spamrs   )r   z,;")r   rs   ))r   r   )r   r   )r   r   )zfoo=foo="")r   foo=bar; bar=baz)r   r   )r   zfoo; bar; baz)zfoo="\"" bar="\\"zfoo="\""; bar="\\")u	   föo=bäru   föo="bär")z	foo,,,barzfoo, bar)zfoo=bar,bar=bazzfoo=bar, bar=baz)zfoo=
r   )foo="
"r   )zfoo=bar
r   )
foo="bar
"r   )zfoo=bar
bazzfoo=bar; baz)foo="bar
baz"r   )text/html; charset=iso-8859-1r   )text/html; charset="iso-8859/1"r   )z)foo="bar"; port="80,81"; discard, bar=bazz'foo=bar; port="80,81"; discard, bar=baz)zBasic realm="\"foo\\\\bar\""zBasic; realm="\"foo\\\\bar\"")n; foo="foo;_", bar="foo,_"r   )ry   rz   r{   r|   r   r}   r   r   r   r   r   r   r~   r   r   s   @r-   r   r      s    e79
 <	<
 e""
 <	<
< nn-.?2JdRL|nu%|nw',-0B/CD*,=),>+?@$&
'
 
;
; lm_%&.)*+M?+,[M?++({m_-$^'D&EF..!A BC1234..!A BCJKL+}EF8n-n~.?@%
 $%$ l !%
 !D!E!D!r0   r   c                   4   a  ] tR tRt o . R3R ltR tRtV tR# )FakeResponsei;  Nc                d    ^ RI pVP                  RP                  V4      4      V n        W n        R# )z4
headers: list of RFC822-style 'Key: value' strings
N
)emailmessage_from_stringjoin_headers_url)r'   headersurlr   s   &&& r-   __init__FakeResponse.__init__<  s'     	11$))G2DE	r0   c                    V P                   # rV   )r   r]   s   &r-   infoFakeResponse.infoC  s    4==(r0   )r   r   )ry   rz   r{   r|   r   r   r~   r   r   s   @r-   r   r   ;  s     !t  )(r0   r   c                     \        WVR 4      # )zSet-Cookie2	_interact	cookiejarr   set_cookie_hdrss   &&*r-   interact_2965r   E  s    Y_mDDr0   c                     \        WVR 4      # )z
Set-Cookier   r   s   &&*r-   interact_netscaper   H  s    Y_lCCr0   c                   \         P                  P                  V4      pV P                  V4       VP	                  RR4      p. pV F  pVP                  V: RV: 24       K  	  \        Wa4      pV P                  W4       V# )zDPerform a single request / response cycle, returning Cookie: header.r   rs   z: )urllibrequestRequestadd_cookie_header
get_headerappendr   extract_cookies)	r   r   r   hdr_namereq
cookie_hdrr   r   r   s	   &&&&     r-   r   r   K  sr    
..
 
 
%C$"-JG8S12 
w
$Cc'r0   c                   4  a  ] tR tRt o R tR tR tR tR t]	P                  ! ]R4      ]P                  R 4       4       t]	P                  ! ]R4      ]P                  R	 4       4       t]	P                  ! ]R4      ]P                  R
 4       4       tR tRtV tR# )FileCookieJarTestsiX  c                t    \         P                  p\        V4      pV P                  VP                  V4       R # rV   )r   TESTFNr   r$   filenamer'   r   r   s   &  r-   test_constructor_with_str,FileCookieJarTests.test_constructor_with_strY  s+    ##"X.r0   c                    \         P                  p\        \         P                  ! V4      4      pV P	                  VP
                  V4       R # rV   )r   r   r   FakePathr$   r   r   s   &  r-   test_constructor_with_path_like2FileCookieJarTests.test_constructor_with_path_like^  s6    ##++H56X.r0   c                R    \        R 4      pV P                  VP                  4       R # rV   )r   rW   r   r'   r   s   & r-   test_constructor_with_none-FileCookieJarTests.test_constructor_with_nonec  s    !**%r0   c           
     H    ! R  R4      p\         \        V3 F_  pV P                  VR7      ;_uu_ 4        V P                  \        4      ;_uu_ 4        V! 4       p\        VR7      pRRR4       RRR4       Ka  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)c                       ] tR tRtRtR# )?FileCookieJarTests.test_constructor_with_other_types.<locals>.Aih  rr   N)ry   rz   r{   r|   r~   rr   r0   r-   Ar   h  s    r0   r   r   N)intfloatsubTestassertRaises	TypeErrorr   )r'   r   type_instancer   s   &    r-   !test_constructor_with_other_types4FileCookieJarTests.test_constructor_with_other_typesg  sq    	 	 5!_Eu--&&y11$wH$h7A 2 .- %11 .--s#   BA='B=BBB!c                   \         P                  p\        4       p\        VR R4       V P	                  VP
                  R,          R,          R,          P                  R4        VP                  VRR7       \        4       pVP                  VRR7       \         P                  ! V4       V P	                  VP
                  R,          R,          R,          P                  R4       R#   \         P                  ! T4       i ; i)http://www.acme.com/boowww.acme.com/NTignore_discard)
r   r   r   r   r$   _cookiesvaluesaveloadunlinkr   s   &  r-   test_lwp_valueless_cookie,FileCookieJarTests.test_lwp_valueless_cookieq  s    ##N!3U;N3C8?EEtL	'FF8DF1AFF8DF1X&N3C8?EEtL X&s   $0C' 'C?z9windows file permissions are incompatible with file modesc                j   \         P                  p\        4       p\        VR R4        VP	                  VRR7       \
        P                  ! V4      pV P                  \        P                  ! VP                  4      R4       \         P                  ! V4       R#   \         P                  ! T4       i ; ir  r  Tr  i  N)r   r   r   r   r  osstatr$   S_IMODEst_moder  r'   r   r   sts   &   r-   test_lwp_filepermissions+FileCookieJarTests.test_lwp_filepermissions  s     ##N!3U;	'FF8DF1"BT\\"**5u=X&IX&   AB B2c                j   \         P                  p\        4       p\        VR R4        VP	                  VRR7       \
        P                  ! V4      pV P                  \        P                  ! VP                  4      R4       \         P                  ! V4       R#   \         P                  ! T4       i ; ir  )r   r   r   r   r  r  r  r$   r  r  r  r  s   &   r-   test_mozilla_filepermissions/FileCookieJarTests.test_mozilla_filepermissions  s     ##!3U;	'FF8DF1"BT\\"**5u=X&IX&r#  c                *   \         P                  p\        \        3 F  pV! V4      p\        P
                  P                  R 4      pR.p\        VR 4      pVP                  Wd4       V P                  \        V4      ^4        VP                  4        VP                  4        VP                  4        VP                  4        \         P                  ! V4       V P                  \        V4      ^ 4       K  	  R#   \         P                  ! T4       i ; i)r  z1Set-Cookie: pll_lang=en; Max-Age=31536000; path=/N)r   r   r   r   r   r   r   r   r   r$   lenr  clearr  r  )r'   r   cookiejar_classr   r   r   r   s   &      r-   test_cookie_files_are_truncated2FileCookieJarTests.test_cookie_files_are_truncated  s     ## ,.>?O)A..(()?@CJKGw(>?Cc'SVQ'	+	  *SVQ')  @$   *s   A C::Dc                p   \         P                  p\        \        3 F.  pV! 4       p VP	                  R R7       V P                  R4       K0  	   \        VR4      ;_uu_ 4       pVP                  R4       \        \        3 F+  pV! 4       pV P                  \        VP                  V4       K-  	  RRR4       \         P                  ! V4       R#   \         d,   pT P                  TP                  \        4        Rp?K  Rp?ii ; i  + '       g   i     La; i  \         P                  ! T4       i ; i)zAfor this test to work, a file with this filename should not existr  z%expected OSError for invalid filenameNwzoops
)r   r   r   r   r  failOSErrorassertIsNot	__class__r   openwriter  r  )r'   r   r*  r   excr   s   &     r-   test_bad_magic!FileCookieJarTests.test_bad_magic  s    ##+-==O!AC !< = 		AB  >	'h$$!'35E'EO')A%%iB (F % X&  ;   	::; %$ X&s<   CD $AD
1D D DD
D	D D5rr   N)ry   rz   r{   r|   r   r   r   r	  r  unittestskipIf	mswindowsr   skip_unless_working_chmodr!  r%  r+  r6  r~   r   r   s   @r-   r   r   X  s     /
/
&8M __Y [\((
' ) ]
' __Y [\((
' ) ]
' __Y [\((( ) ](0' 'r0   r   c                     a  ] tR tRt o ]P
                  ! R. R/O4      R 4       tR t]P
                  ! R. R0O4      R 4       tR t	R	 t
R
 tR tR t]P
                  ! R. R1O4      R 4       tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR  t R! t!R" t"R# t#R$ t$R% t%R& t&R' t'R( t(R) t)R* t*R+ t+R, t,R- t-R.t.V t/R# )2CookieTestsi  zurl,domain,okc                    \        4       p\        P                  P                  V4      pVP	                  W%4      pV'       d   V P                  V4       R # V P                  V4       R # rV   )r   r   r   r   domain_return_ok
assertTrueassertFalse)r'   r   domainokpolr   rs   &&&&   r-   test_domain_return_ok!CookieTests.test_domain_return_ok  sL    6 "#..((-  1tq!q!r0   c                   \         P                  p\        V4      p\        VR R4       \        VR R4       VP                  R,          R,          R,          pV P                  VP                  4       V P                  VP                  R4       VP                  R,          R,          R,          pV P                  VP                  4       V P                  VP                  R4       V P                  \        V4      R4       \        V4      pVP                  RRR	7        \        V4      pVP                  RRR	7       \         P                  ! VP                  4       V P                  \        V4      \        P                   ! R
R,          R
R,          V4      4       V P                  \        VR4      R4       R#   \         P                  ! TP                  4       i ; i)r  eggsz"spam"; path=/foo/r  r  /foo/z"spam"zH"spam"; path="/foo/"; domain=www.acme.com; path_spec; discard; version=0T)ignore_expiresr  zpath_specified=%sFhttp://www.acme.com/foo/z"spam"; eggsN)r   r   r   r   r  rW   r  r$   namer   reprr  revertr  r   resub)r'   r   r   cookieold_strs   &    r-   test_missing_valueCookieTests.test_missing_value  s~    ##X&!3V<!35IJN+C08&,,'f-N+G4X>&,,'h//,	. q'	d48	) *AHHDH>QZZ(GFF&-/BU/J	
 	*1.HI'	) QZZ(s    F; ;"Gz#rfc2109_as_netscape,rfc2965,versionNc                   \        VVR 7      p\        V4      p\        VRR4        VP                  R,          R,          R,          pV P	                  VP
                  V4       \        VRR4       V'       d@   VP                  R,          R,          R,          pV P	                  VP
                  ^4       R# R#   \         d    T P                  T4        R# i ; i)	)rfc2109_as_netscaperfc2965http://www.example.com/zni=ni; Version=1www.example.comr  nifoo=bar; Version=1r   N)	r   r   r   r  r$   r   r   KeyErrorrW   )r'   rW  rX  r   policyr   rR  
cookie2965s   &&&&    r-   test_rfc2109_handling!CookieTests.test_rfc2109_handling>  s     % 3 f!68JK	8ZZ 1237=F V^^W5!602ZZ(9:3?F
  !3!3Q7   	'g&	's   !B: :CCc                t   \        4       p\        VR R4       \        VR R4       \        VRR4       \        VRR4       \        VRR4       \        VR R4       \        VR R4       \        VR R	4       VP                  R
,          R,          R,          pV P                  VP                  R
4       V P                  VP                  4       V P                  VP                  \        4       V P                  VP                  4       V P                  VP                  R4      4       V P                  VP                  R4      4       VP                  R,          R,          R,          pV P                  VP                  R4       V P                  VP                  4       V P                  VP                  R4       V P                  VP                  4       VP                  R,          R,          R,          pV P                  VP                  4       V P                  VP                  4       VP                  R,          R,          R,          pVP                  R,          R,          R,          pV P                  VP                  4       V P                  VP                  4       VP                  R,          R,          R,          pV P                  VP                  4       V P                  VP                  R4       VP                  R,          R,          R	,          pV P                  VP                  4       R# )r  z0spam=eggs; DoMain=.acme.com; port; blArgh="feep"zni=ni; port=80,8080http://www.acme.com:80/znini=nizfoo=bar; expires=z-spam=eggs; expires="Foo Bar 25 33:22:11 3022"z	fortytwo=z=unladenswallowholyhandgrenade	.acme.comr  r   blArghblarghr  r[  z80,8080ninir   fortytwors   N)r   r   r  r$   rB  r@  domain_specifiedportr   rA  port_specifiedhas_nonstandard_attrrW   r   assertIsNotNoner  )r'   r   rR  r   r   s   &    r-   test_ns_parserCookieTests.test_ns_parser]  s{   K!3L	N!35JK!6	B!68KL!6 9? 	@!3[A!35FG!35FGK(-f54//0&78../33H=>44X>?N+C067001i0--.N+C08&++&../ jj(-e4zz.)#.u5#++&$,,'N+C0<V\\*r*
 N+C01BC&,,'r0   c                    \        4       p\        VR R4       \        VR R4       VP                  R,          R,          pV P                  RV4       V P                  RV4       R# )r  zexpires=eggszversion=eggs; spam=eggsr  r  r   r   N)r   r   r  assertIn)r'   r   cookiess   &  r-   test_ns_parser_special_names(CookieTests.test_ns_parser_special_names  sU     K!3^D!35NO**^,S1i)i)r0   c                   \        4       p\        \        P                  ! 4       R ,           4      p\        P                  ! V 4      ;_uu_ 4        RV 2.p\
        P                  P                  R4      p\        VR4      pVP                  WT4      pV P                  \        V4      ^4       V P                  \        V^ ,          P                  4      V4       RRR4       \        VRRV,          4       V P                  \        V4      ^4       \        \        P                  ! 4       ^,
          4      p\        VRRV,          4       \        VR4      pV P                  \        V4      ^4       V P                  RV4       V P                  RV4       \        VRR	V,          4       \        VRR
V,          4       V P                  \        V4      ^4       \        VRRV,          4       \        VRRV,          4       \        VR4      pV P                  \        V4      ^4       \        VRR4       V P                  \        V4      ^4       VP!                  4        V P                  \        V4      ^4       V P                  RV4       \#        ^ RRRRRRRRRRRRRR/ 4      p	V P                  V	P                  R4       R#   + '       g   i     EL; i)  z%Set-Cookie: FOO=BAR; path=/; expires=http://www.coyote.com/Nr  zspam="bar"; expires=%szfoo="eggs"; expires=%s
spam="bar"r   zeggs="bar"; expires=%szbar="bar"; expires=%sz!eggs="bar"; expires=%s; max-age=0z bar="bar"; max-age=0; expires=%szhttp://www.rhubarb.net/zwhum="fizz"rM  r  Fzwww.python.orgTr  z1444312383.018307i?uV)r   r   r8   r   check_no_warningsr   r   r   r   make_cookiesr$   r(  r   r   rr  assertNotInclear_session_cookiesr   )
r'   r   futurer   r   r   rs  nowhrR  s
   &         r-   test_expiresCookieTests.test_expires  s   Ktyy{4/0..t44>vhGHG..(()ABCw(@ACnnS.GS\1-]71:+=+=>G 5 	!35M 6! 	"Q#DIIKM*!35M6 	a!78Q#lA&" 	!35M 6! 	"!35L 6! 	"Q#!3 624:6; 	<!3 624:6; 	<a!78Q# 	!6FQ#	!Q#lA& FGu&6uc':d 	4a 544s   B
KK	c                   \        R R7      p\        V4      p\        VRR4       V P                  RVP                  R,          4       \        V4      p\        VRR4       V P                  RVP                  R,          4       \        V4      p\        VRR4       V P                  R	VP                  R,          4       \        V4      p\        VR
R4       V P                  RVP                  R,          4       \        4       p\        VRR4       V P                  RVP                  R,          4       \        4       p\        VRR4       V P                  RVP                  R,          4       \        4       p\        VRR4       V P                  RVP                  R,          4       \        4       p\        VR
R4       V P                  RVP                  R,          4       R# )TrX  r  zspam="bar"; Version="1"r  r  zhttp://www.acme.com/blahzeggs="bar"; Version="1"z http://www.acme.com/blah/rhubarb/blah/z!http://www.acme.com/blah/rhubarb/z/blah/rhubarb/ry  
eggs="bar"/blahz/blah/rhubarbN)r   r   r   rr  r  r   r'   rD  r   s   &  r-   test_default_pathCookieTests.test_default_path  sw   !$/cNa/1JKc1::n56cNa35NOc1::n56cNa;/	1h

> :;cNa</	1&

>(BC K!3\Bc1::n56K!7Fc1::n56K!?Ngqzz.9:K!@,Ooqzz.'ABr0   c                    \        4       pR pRp\        WV4       V P                  RVP                  R,          4       V P	                  \        W4      V4       R# )zhttp://example.com/?spam/eggsr  r  zexample.comN)r   r   rr  r  r$   )r'   cjurir  s   &   r-   test_default_path_with_query(CookieTests.test_default_path_with_query  sJ    [-"5)c2;;}56*23U;r0   z
arg,resultc                <    V P                  \        V4      V4       R # rV   )r$   r   )r'   r   rO   s   &&&r-   test_escape_pathCookieTests.test_escape_path  s    , 	S)62r0   c                b   \         P                  P                  R 4      pV P                  \	        V4      R4       \         P                  P                  R4      pV P                  \	        V4      R4       \         P                  P                  R4      pV P                  \	        V4      R4       R# )zThttp://www.example.com/rheum/rhaponticum;foo=bar;sing=song?apples=pears&spam=eggs#niz$/rheum/rhaponticum;foo=bar;sing=songzBhttp://www.example.com/rheum/rhaponticum?apples=pears&spam=eggs#niz/rheum/rhaponticumzhttp://www.example.comr  N)r   r   r   r$   r   r'   r   s   & r-   test_request_pathCookieTests.test_request_path  s    nn$$:; 	c*?	A nn$$() 	c*,@Ann$$%=>c*C0r0   c                   \        4       p\        R R7      p\        V4      pRp\        W4R4       VP                  R,          R,          R,          pR F  w  rgV V 2p\        P
                  P                  V4      p	\        W84      p
V'       d9   V P                  RV
RV 24       V P                  VP                  WY4      4       Ku  V P                  RV
R	V 24       V P                  VP                  WY4      4       K  	  R
# )T)strict_ns_set_pathzhttp://bar.comzspam=eggs; Path=/foobar.com/foor   z	spam=eggszcookie not set for zcookie set for N))r  T)rJ  T)/foo/barT)r  F)z/foobad/fooF)r   r   r   r  r   r   r   rr  r@  set_ok_pathr|  rA  )r'   rD  strict_ns_path_polr   base_urlrR  pathrC  r   r   r  s   &          r-   test_path_prefix_match"CookieTests.test_path_prefix_match+  s    !#0DIcN#!'=>I&v.v61HD
 Jtf%C..((-C!!)Ak10CD6.JK 2 > >v KL  a?4&1IJ  !3!?!?!LM1r0   c                   \         P                  P                  R RR/R7      pV P                  \	        V4      R4       \         P                  P                  RRR/R7      pV P                  \	        V4      \
        4       R# )zhttp://www.acme.com:1234/Hostzwww.acme.com:4321r   1234r  N)r   r   r   r$   r   r   r  s   & r-   test_request_portCookieTests.test_request_portC  sy    nn$$%@.46I-J % Lc*F3nn$$%;.46I-J % Lc*,=>r0   c                z   \         P                  P                  R RR/R7      pV P                  \	        V4      R4       \         P                  P                  RRR/R7      pV P                  \	        V4      R4       \         P                  P                  RRR	/R7      pV P                  \	        V4      R4       R
# )zhttp://1.1.1.1/r  www.acme.com:80r  z1.1.1.1r  zirrelevant.comr  z&http://www.acme.com:2345/resource.htmlzwww.acme.com:5432N)r   r   r   r$   r   r  s   & r-   test_request_hostCookieTests.test_request_hostK  s    nn$$%6.46G-H % J
 	c*I6nn$$%;.46F-G % Ic*N;nn$$%M.46I-J % Lc*N;r0   c                   V P                  \        R 4      4       V P                  \        R4      4       V P                  \        R4      4       V P                  \        R4      4       V P                  \        R4      4       V P                  \        R4      4       V P                  \        R4      4       V P                  \        R4      4       R# )	foo.bar.comz1foo2.3bar4.5com192.168.1.1rs   ..foo.bar.comz..foozfoo.N)r@  r   rA  r]   s   &r-   test_is_HDNCookieTests.test_is_HDN[  s    }-.123./$%/0)(r0   c                   V P                  \        R 4      R4       V P                  \        R4      R4       V P                  \        R4      R4       V P                  \        R4      R4       V P                  \        R4      R4       V P                  \        R4      R4       V P                  \        R4      R4       V P                  \        R4      R4       R	# )
r  re  acme.comz
acme.local.local.comr  rs   z192.168.0.1N)r$   r   r]   s   &r-   
test_reachCookieTests.test_reache  s    ~.<z*J7|,h7x(3v/sS)rB'}-}=r0   c                   V P                  \        R R 4      4       V P                  \        R R4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR	4      4       V P                  \        R
R4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        RR4      4       V P                  \        R R 4      4       V P                  \        R R4      4       V P                  \        R R4      4       V P                  \        R R4      4       R# )r  z.168.1.1zx.y.comzx.Y.comz.Y.comzY.comz	a.b.c.comz.c.comzexample.localr  z	blah.blahrs   z.rhubarb.rhubarbr  re  zrhubarb.acme.comzwww.rhubarb.acme.comzy.comz.y.comr  comr   z.mr  N)r@  r   rA  r   r]   s   &r-   test_domain_matchCookieTests.test_domain_matcho  s   ]MBCmZ@AY	:;Y9:i9:[(;<h<=_h?@k267b*<=>R,-)*jAB*:{CD)*<kJK)*@+NO))Y?@))X>?*9g>?)'7;<*8W=>)(H=>))V<=*9e<=*9c:;*9d;<*9b9:*9c:;)-GH*=*EF*=#>?*="=>r0   c                j    \        4       p\        VR R4       V P                  \        V4      ^ 4       R# )zhttp://www.nasty.com/z)foo=bar; domain=friendly.org; Version="1"N)r   r   r$   r(  r   s   & r-   test_wrong_domainCookieTests.test_wrong_domain  s0    
 Ka0A	CQ#r0   c                   \        R R7      p\        VR7      p\        VRR4       \        VRR4       V P                  \	        V4      ^4       R	 F2  p\        VRV,          R4       V P                  \	        V4      ^4       K4  	  R# )
T)strict_domainr^  zhttp://example.co.uk/zno=problemoz!okey=dokey; Domain=.example.co.ukzhttp://example.%s/zspam=eggs; Domain=.co.ukN)z.co.ukz.org.zaz.tx.usz.name.us)r   r   r   r$   r(  )r'   cpr  
pseudo_tlds   &   r-   test_strict_domainCookieTests.test_strict_domain  s}     !t4b!"5}E"5=	?R!$EJb"6"C8:SWa( Fr0   c                   \        4       p\        VR R4       V P                  \        V4      ^4       V P                  VP                  R,          R,          R,          P
                  R4       V P                  \        VR 4      R4       V P                  \        VR4      R4       \        \        P                  R7      pVP                  V4       V P                  \        VR4      R4       \        VR	R
4       \        VRR4       V P                  \        V4      ^4       V P                  VP                  R,          R,          R,          P
                  R4       V P                  VP                  R,          R,          R,          P
                  R4       V P                  \        VR4      R4       \        VR R4       V P                  \        V4      ^4       \        VRR4       V P                  \        V4      ^4       R# )http://foo.net/zns=barfoo.netr  nsr   http://www.foo.net/)strict_ns_domainrs   http://foo.net/foo/zspam1=eggs; domain=foo.netzhttp://foo.net/foo/bar/zspam2=eggs; domain=.foo.net.foo.netr  spam1rI  r  spam2zspam2=eggs; spam1=eggs; ns=barznini="ni"; domain=.netzhttp://foo.co.ukznasty=trick; domain=.co.ukN)	r   r   r$   r(  r  r  r   DomainStrictNonDomain
set_policy)r'   r   rD  s   &  r-   test_two_component_domain_ns(CookieTests.test_two_component_domain_ns  s    K 	!.9Q#I.s3D9??G*1.?@(K*1.CD!	# "0FFH	S*1.CDbI 	!26	8 	!67	9Q#J/7@FF	!J/
;GDJJ	!*1.GH9	; 	!.0HIQ# 	!/1MNQ#r0   c                j    \        4       p\        VR R4       V P                  \        V4      ^4       R# )http://localhostfoo=bar; domain=localhost;Nr   r   r$   r(  r   s   & r-   test_localhost_domain!CookieTests.test_localhost_domain  s+    K!/1MNQ#r0   c                    \        4       p\        VR R4       V P                  VP                  R,          R,          R,          P                  R4       R# )r  r  z
.localhostr  r   r   Nr   r   r$   r  r  r   s   & r-   test_localhost_domain_contents*CookieTests.test_localhost_domain_contents  s@    K!/1MNL1#6u=CCUKr0   c                    \        4       p\        VR R4       V P                  VP                  R,          R,          R,          P                  R4       R# )r  zfoo=bar;zlocalhost.localr  r   r   Nr  r   s   & r-    test_localhost_domain_contents_2,CookieTests.test_localhost_domain_contents_2  s@    K!/<$56s;EBHH%Pr0   c                j    \        4       p\        VR R4       V P                  \        V4      ^ 4       R# )zhttp://evil.comzfoo=bar; domain=.localhostNr  r   s   & r-   test_evil_nonlocal_domain%CookieTests.test_evil_nonlocal_domain  s+    K!.0LMQ#r0   c                j    \        4       p\        VR R4       V P                  \        V4      ^ 4       R# )r  zfoo=bar; domain=.evil.comNr  r   s   & r-   test_evil_local_domain"CookieTests.test_evil_local_domain  s+    K!/1LMQ#r0   c                j    \        4       p\        VR R4       V P                  \        V4      ^ 4       R# )r  z foo=bar; domain=.someother.localNr  r   s   & r-   test_evil_local_domain_2$CookieTests.test_evil_local_domain_2  s+    K!/1STQ#r0   c                   \        R R7      p\        V4      p\        VRR4       V P                  \	        V4      ^4       V P                  VP
                  R,          R,          R,          P                  R4       V P                  \        VR4      R4       V P                  \        VR	4      R
4       \        VRR4       V P                  \	        V4      ^4       V P                  \        VR4      R4       \        VRR4       V P                  VP
                  R,          R,          R,          P                  R4       V P                  \	        V4      ^4       V P                  \        VR4      R4       V P                  \        VR4      R4       \        VRR4       V P                  \	        V4      ^4       \        VRR4       V P                  \	        V4      ^4       R# )Tr  r  r   r  r  r   r   z$Version=1; foo=barr  rs   zhttp://foo.net/fooz1spam=eggs; domain=foo.net; path=/foo; Version="1"zhttp://www.foo.net/foo/z&spam=eggs; domain=foo.net; Version="1"r  rJ  r   rI  r  z($Version=1; spam=eggs; $Domain="foo.net"z#ni="ni"; domain=".net"; Version="1"zhttp://foo.co.uk/z'nasty=trick; domain=.co.uk; Version="1"N)r   r   r   r$   r(  r  r  r  s   &  r-   !test_two_component_domain_rfc2965-CookieTests.test_two_component_domain_rfc2965  s   !$/cN 	a*,BCQ#I.s3E:@@%Hq*;<.	0 	q*?@"E
 	a-I	KQ#q*>?.	0
 	a2>	@J/8@FF	!Q#q*?@.	0q*CDC	E 	a*;	=Q# 	a,?	AQ#r0   c                   \        \        R .R.R7      R7      p\        P                  P	                  R4      pR.p\        VR4      pVP                  WB4       V P                  \        V4      ^ 4       \        P                  P	                  R4      p\        VR4      pVP                  WB4       V P                  \        V4      ^4       \        P                  P	                  R4      p\        VR4      pVP                  WB4       V P                  \        V4      ^4       \        P                  P	                  R4      p\        VR4      pVP                  WB4      pVP                  V^ ,          4       V P                  \        V4      ^4       VP                  V4       V P                  VP                  R4      4       R	# )
r  r  )blocked_domainsallowed_domainsr  http://acme.com/*Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/r  rx  r   N)r   r   r   r   r   r   r   r$   r(  r{  
set_cookier   rA  
has_header)r'   r   r   r   r   rs  s   &     r-   test_domain_allowCookieTests.test_domain_allow1  sp   0'L+,. / nn$$%78?@7$67	##Q#nn$$%;<7$:;	##Q#nn$$%=>7$<=	##Q# nn$$%=>7$<=..*	WQZ Q#	C 12r0   c                   \        R R.R7      p\        VR7      pR.p\        P                  P	                  R4      p\        VR4      pVP                  WT4       V P                  \        V4      ^ 4       VP                  R.4      pVP                  WT4       V P                  \        V4      ^4       VP                  4        \        P                  P	                  R4      p\        VR4      pVP                  WT4       V P                  \        V4      ^4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       V P                  VP                  R	4      4       VP                  4        VP                  R.4       VP                  WT4       V P                  \        V4      ^4       \        P                  P	                  R4      p\        VR4      pVP                  WT4      pVP                  V^ ,          4       V P                  \        V4      ^4       VP                  V4       V P!                  VP                  R4      4       VP                  4        VP                  . 4       \        P                  P	                  R
4      p\        VR
4      pVP                  WT4      pVP                  WT4       V P                  \        V4      ^4       \        P                  P	                  R
4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P!                  VP#                  V^ ,          V4      4       V P!                  VP                  R4      4       VP                  R.4      p\        P                  P	                  R
4      pVP                  V4       V P!                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P!                  VP                  R4      4       R# )Tre  )rX  r  r  r  r  r  zhttp://www.roadrunner.net/r   Cookie2r  zhttp://badacme.com/N)r   r   r   r   r   r   r   r$   r(  set_blocked_domainsr)  r   r@  r  r{  r  rA  	return_ok)r'   rD  r   r   r   r   prs  s   &       r-   test_domain_blockCookieTests.test_domain_blockP  sk   !;-9S!?@nn$$%;<7$:;	##Q###ZL1	##Q#		nn$$%AB7$@A	##Q#nn$$%AB	C x01y12		.	##Q# nn$$%;<7$:;..*	WQZ Q#	C 12		#nn$$%787$67..*	##Q#nn$$%78	C x01nn$$%:;	C wqz37812##ZL1nn$$%78	C 12nn$$%:;	C 12r0   c           
        R F  pR F  p\        4       pV'       d   \        RR7      p\        pRpM\        R R7      p\        pRpVP	                  V4       RpV! W7RV: V: 24       V! W7RV: RV: 24       V P                  VP                  R	,          R
,          R,          P                  R4       V P                  VP                  R	,          R
,          R,          P                  R4       K  	  K  	  R# )TFrs   r  z; Version=1r  foo1=barfoo2=barz; securer  r  foo1z#non-secure cookie registered securefoo2z#secure cookie registered non-secureN)TF)r"   rs   )	r   r   r   r   r  rA  r  securer@  )r'   r  
whitespacer   rD  r  vsr   s   &       r-   test_secureCookieTests.test_secure  s    B%
K-e<C+CB-d;C'C&BS!,Asb*=>Asr:FG  JJ~.s3F;BB9; JJ~.s3F;BB9;# & r0   c                f   \        4       p\        VR 7      pR.p\        P                  P	                  R4      p\        VR4      pVP                  WT4       V P                  \        V4      ^4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       R# )r  (Set-Cookie: session=narf; secure; path=/https://www.acme.com/r   r  zwss://www.acme.com/zws://www.acme.com/N)r   r   r   r   r   r   r   r$   r(  r   r@  r  rA  r'   rD  r   r   r   r   s   &     r-   test_secure_blockCookieTests.test_secure_block  sH   !#S!=>nn$$%<=7$;<	##Q#nn$$%<=	C x01nn$$%;<	C 12 nn$$%:;	C x01 nn$$%9:	C 12r0   c                l   \        R .R7      p\        VR7      pR.p\        P                  P	                  R4      p\        VR4      pVP                  WT4       V P                  \        V4      ^4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      4       R	# )
foos)secure_protocolsr  r	  r
  r   r  zfoos://www.acme.com/zfoo://www.acme.com/N)r   r   r   r   r   r   r   r$   r(  r   rA  r  r@  r  s   &     r-   test_custom_secure_protocols(CookieTests.test_custom_secure_protocols  sL   !F8<S!=>nn$$%<=7$;<	##Q# nn$$%<=	C 12nn$$%;<	C 12nn$$%;<	C x01nn$$%:;	C 12r0   c                    \        \        R R7      R7      p\        VRR4       \        VR4      pV P                  VR4       R# )Tr  r  r  zfoo=\b"a"r; Version=1z$Version=1; foo=\\b\"a\"rN)r   r   r   r$   )r'   r   r  s   &  r-   test_quote_cookie_value#CookieTests.test_quote_cookie_value  s>    0>?a/1IJ!3489r0   c                "   R p\        \        RR7      4      p\        W!R4       \        P                  P                  V4      pV P                  \        V4      ^4       VP                  V4       V P                  VP                  R4      4       R# )http://www.acme.comTr  r\  r   N)r   r   r   r   r   r   r$   r(  r   r@  r  )r'   r   r   r   s   &   r-   test_missing_final_slash$CookieTests.test_missing_final_slash  sm    #)$78a23nn$$S)Q#	C x01r0   c                h   \        R R7      p\        V4      pRp\        W#R4       \        W#4      pV P                  RVR4       \        V4      pRp\        W#R4       \        W#4      pV P	                  RVR4       \        V4      pRp\        W#R	4       \        W#4      pV P	                  R
VR4       R# )Tr  http://foo.bar.com/spam=eggs; Version=1Domainz*absent domain returned with domain presentz%spam=eggs; Version=1; Domain=.bar.comz$Domain=".bar.com"zdomain not returnedz$spam=eggs; Version=1; Domain=bar.comz$Domain="bar.com"Nr   r   r   r|  rr  r'   rD  r   r   r  s   &    r-   test_domain_mirrorCookieTests.test_domain_mirror  s    !$/cN#a45!!1A	C cN#aEF!!*A/DEcN#aDE!!)1.CDr0   c                    \        R R7      p\        V4      pRp\        W#R4       \        W#4      pV P                  RVR4       \        V4      pRp\        W#R4       \        W#4      pV P	                  RVR4       R	# )
Tr  r  r  Pathz&absent path returned with path presentzspam=eggs; Version=1; Path=/z	$Path="/"zpath not returnedNr  r  s   &    r-   test_path_mirrorCookieTests.test_path_mirror  sv    !$/cN#a45!!$LMcN#a<=!!k1&9:r0   c                   \        R R7      p\        V4      pRp\        W#R4       \        W#4      pV P                  RVR4       \        V4      pRp\        W#R4       \        W#4      pV P	                  VRR4       \        V4      pRp\        W#R	4       \        W#4      pV P                  R
VR4       \        V4      pRp\        W#R4       \        W#4      pV P                  RVR4       R# )Tr  r  r  Portz&absent port returned with port presentzspam=eggs; Version=1; Portz\$Port([^=]|$)z-port with no value not returned with no valuezspam=eggs; Version=1; Port="80"z
$Port="80"z5port with single value not returned with single valuez$spam=eggs; Version=1; Port="80,8080"z$Port="80,8080"z;port with multiple values not returned with multiple valuesN)r   r   r   r|  r%   rr  r  s   &    r-   test_port_mirrorCookieTests.test_port_mirror  s    !$/cN#a45!!$LMcN#a:;!!-H	J cN#a?@!!lAM	O cN#aDE!!'	 r0   c                    \        \        R R7      4      pRp\        WR4       \        W4      pV P                  RVR4       R# )Tr  r  zfspam=eggs; Version=1; Comment="does anybody read these?"; CommentURL="http://foo.bar.net/comment.html"Commentz:Comment or CommentURL cookie-attributes returned to serverN)r   r   r   r|  )r'   r   r   r  s   &   r-   test_no_return_comment"CookieTests.test_no_return_comment6  sJ    )$78#a E 	F !!AH	Jr0   c                Z   \        \        R R7      4      p\        VRR4       \        VRR4       \        VRR4       \        VRR4       \        VRR	4       . ROp. ROp. ROp. ROp\	        ^4       F  p^ pV F  pV P                  V\        4       V P                  VP                  W&,          4       V P                  VP                  W6,          4       V P                  VP                  WF,          4       V P                  VP                  WV,          4       V^,           pK  	  K  	  R
# )Tr  zhttp://blah.spam.org/zefoo=eggs; Version=1; Comment="does anybody read these?"; CommentURL="http://foo.bar.net/comment.html"zhttp://www.acme.com/blah/zspam=bar; securezfoo=bar; secure; Version=1zfoo=bar; path=/; Version=1http://www.sol.nosbang=wallop; version=1; domain=".sol.no"; port="90,100, 80,8080"; max-age=100; Comment = "Just kidding! (\"|\\\\) "N)r=   r>   r=   r=   r=   )r   r   r   r   bang)zblah.spam.orgr  r  r  z.sol.no)r  r  r  r  r  )r   r   r   r   rangeassertIsInstancer   r$   r   rM  rB  r  )r'   csversionsnamesdomainspathsir   s   &       r-   test_Cookie_iterator CookieTests.test_Cookie_iterator@  s   *489b1 4E 	F 	"9;MNb52	4b52	4b-K	L
 #5.2qAA%%a0  HK8  2  7:6  2E  r0   c                t   V P                  \        R .4      . R	O.4       V P                  \        R.4      . R
O.4       V P                  \        R.4      RR..4       V P                  \        R.4      . R
O.4       V P                  \        R.4      RR..4       V P                  \        R.4      . 4       R# )zfoo=bar; path=/; domainr   Nz)foo=bar; expires=Foo Bar 12 33:22:11 2000zfoo=bar; expireszfoo=bar; versionrs   r   r   )r   )r  r  )rB  Nr   )r   )r   Nr   r   )r   Nr   r]   s   &r-   r   !CookieTests.test_parse_ns_headers`  s    789A B	 	IJKBC	
 	eW%-./	
 	012BC	E 	012/01	3 	)2$/4r0   c                b   R  p\        \        P                  ! 4       R,           4      pR.R.R.R.R.RV,          .3 F&  pV! V4      pV P                  \        V4      ^ 4       K(  	  R.pV! V4      pVP                  R	,          R
,          R,          pV P                  VP                  4       R# )c                     \        4       p\        P                  P                  R 4      p\	        V R 4      pVP                  W24       V# )rY  )r   r   r   r   r   r   )r   r   r   rE  s   &   r-   cookiejar_from_cookie_headersICookieTests.test_bad_cookie_header.<locals>.cookiejar_from_cookie_headers}  s>    A..(()BCCW&?@Aa%Hr0   rw  zSet-Cookie: zSet-Cookie2: z-Set-Cookie2: a=foo; path=/; Version=1; domainzSet-Cookie: b=foo; max-age=oopszSet-Cookie: b=foo; version=spamzSet-Cookie:; Expires=%sz3Set-Cookie: c=foo; expires=Foo Bar 12 33:22:11 2000rZ  r  r   N)r   r8   r$   r(  r  rW   r   )r'   r@  r~  r   r   rR  s   &     r-   test_bad_cookie_header"CookieTests.test_bad_cookie_header{  s    	 tyy{4/0 <=././&/0
G .g6ASVQ'
  II)'2-.s3C8&..)r0   rr   ))r  zblah.comF)r  zrhubarb.blah.comF)r  zrhubarb.foo.bar.comF)r  r  T)r  r  T)r  z.bar.comT)r  r  T)r  r  T)http://foo.com/zrhubarb.foo.comF)rD  .foo.comT)rD  foo.comT)rD  r  T)http://foo/zrhubarb.fooF)rG  z.fooT)rG  r   T)rG  z	foo.localT)rG  r  T)http://barfoo.comrE  F)rH  rF  F))NFr>   )NTr=   )FFN)FTr=   )TFr>   )TTr>   ))z/foo%2f/bar/foo%2F/bar)rI  rI  )
/foo%%/barrJ  )/fo%19o/barrK  )z/fo%7do/barz/fo%7Do/bar)	/foo/bar&rL  )	/foo//barrM  )	~/foo/barrN  )z	/foo/barz/foo%19/bar)z	/}foo/barz/%7Dfoo/bar)u
   /foo/barüz/foo/bar%C3%BC)u   /foo/barꯍz/foo/bar%EA%AF%8D)0ry   rz   r{   r|   r   r}   rF  rT  r`  ro  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r$  r(  r,  r:  r   rB  r~   r   r   s   @r-   r=  r=    sG    ^ o (
 *
"+*
")@ ; 	>
 	8	8*.(`	*55r&CP< l %
 *3+*31 N0?< )>"?H$).$`$LQ$$$*$X3>A3F;.3836:2E.; >J@56* *r0   r=  c                   h   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tRtV tR# )LWPCookieTestsi  c                l   \         P                  ! 4       ^ ,          ^,           p. p\        \        RR7      4      p\        P
                  P                  RRR/R7      pVP                  RV,          4       \        VR4      pVP                  WT4       \        P
                  P                  R4      pVP                  V4       V P                  VP                  R	4      R
4       V P                  VP                  R4      R4       VP                  R4       \        VR4      pVP                  WT4       \        P
                  P                  R4      pVP                  V4       VP                  R	4      pV P                  RV4       V P                  R
V4       VP                  R4       \        VR4      pVP                  WT4       \        P
                  P                  R4      pVP                  V4       VP                  R	4      pV P                  RV4       V P                  R
V4       V P                  RV4       \        P
                  P                  R4      pVP                  V4       VP                  R	4      pV P                  RV4       V P                  R
V4       V P                  VR4       R# )r>   Tr  rc  r  r  r  zVSet-Cookie: CUSTOMER=WILE_E_COYOTE; path=/ ; expires=Wednesday, 09-Nov-%d 23:12:40 GMTr  r   zCUSTOMER=WILE_E_COYOTEr  $Version="1"4Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/zhttp://www.acme.com/foo/bar PART_NUMBER=ROCKET_LAUNCHER_0001z%Set-Cookie: SHIPPING=FEDEX; path=/foor  zSHIPPING=FEDEXrL  zSHIPPING=FEDEX;N)r8   	localtimer   r   r   r   r   r   r   r   r   r$   r   rr  r|  assertStartsWith)r'   year_plus_oner   r   r   r   r  s   &      r-   test_netscape_example_1&LWPCookieTests.test_netscape_example_1  sF   J (+a/)D9: nn$$%>%'89 % ; 	8:GH	I 7$:;	##nn$$%;<	C 13KL	2NCMN7$:;	##nn$$%BC	C NN8$8!<.2>?7$9:	##nn$$%;<	C NN8$8!<.2)1-nn$$%?@	C NN8$8!<.2a!23r0   c                X   \        4       p. p\        P                  P                  R 4      pVP	                  R4       \        VR 4      pVP                  WC4       \        P                  P                  R 4      pVP                  V4       V P                  VP                  R4      R4       VP	                  R4       \        VR 4      pVP                  WC4       \        P                  P                  R4      pVP                  V4       V P                  VP                  R4      R4       R# )r  rS  r   rT  z6Set-Cookie: PART_NUMBER=RIDING_ROCKET_0023; path=/ammozhttp://www.acme.com/ammozBPART_NUMBER=RIDING_ROCKET_0023;\s*PART_NUMBER=ROCKET_LAUNCHER_0001N)r   r   r   r   r   r   r   r   r$   r   r%   r'   r   r   r   r   s   &    r-   test_netscape_example_2&LWPCookieTests.test_netscape_example_2  s    0 Knn$$%;<MN7$:;	##nn$$%;<	C 1;	= 	D	F7$:;	##nn$$%?@	C 1=	>r0   c                   \        \        R R7      4      p\        VRR4      pV P                  V4       \        VRR4      pV P	                  VR4       \        VRR4      pV P	                  VR	4       V P	                  VR
4       V P	                  VR4       \        VR4      pV P	                  VR4       V P                  RV4       R# )Tr  zhttp://www.acme.com/acme/loginz3Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"z!http://www.acme.com/acme/pickitem=Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"z=^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$z!http://www.acme.com/acme/shippingz+Shipping="FedEx"; Version="1"; Path="/acme"z^\$Version="?1"?;z7Part_Number="?Rocket_Launcher_0001"?;\s*\$Path="\/acme"z-Customer="?WILE_E_COYOTE"?;\s*\$Path="\/acme"z http://www.acme.com/acme/processz%Shipping="?FedEx"?;\s*\$Path="\/acme"WILE_E_COYOTEN)r   r   r   rA  r%   rr  r'   r   rR  s   &  r-   test_ietf_example_1"LWPCookieTests.test_ietf_example_1.  s     )$78, /AC 	 & q"E ;< 	L	N* q"ELN 	!56 "7 	8 "7 	8* q"DE!IJov.r0   c                    \        \        R R7      4      p\        VRRR4       \        VR4      pV P                  VR4       \        VR4      pV P	                  RV4       V P                  R	V4       R
# )Tr  z&http://www.acme.com/acme/ammo/specificr_  z@Part_Number="Riding_Rocket_0023"; Version="1"; Path="/acme/ammo"z!http://www.acme.com/acme/ammo/...z(Riding_Rocket_0023.*Rocket_Launcher_0001zhttp://www.acme.com/acme/parts/Rocket_Launcher_0001Riding_Rocket_0023N)r   r   r   r%   rr  r|  ra  s   &  r-   test_ietf_example_2"LWPCookieTests.test_ietf_example_2  sz     )$78 	7KN	P" q"EF!LM q"CD,f5-v6r0   c                   \        R R7      p\        VR7      pRp\        VRR4      pV P                  V4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR	4      pV P	                  \        V4      ^4       \        VR
R4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        VRR4      pV P	                  \        V4      ^4       \        P                  p VP                  VR R7       \        V4      p\        VR7      pVP                  VR R7       \        P                  ! V4       V P	                  V\        V4      4       R#   \        P                  ! T4       i ; i)Tr  r  zmax-age=3600r  z!foo=bar; domain=".com"; version=1z'ping=pong; domain="acme.com"; version=1zhttp://www.a.acme.comz'whiz=bang; domain="acme.com"; version=1z,wow=flutter; domain=".a.acme.com"; version=1zhttp://125.125.125.125z*zzzz=ping; domain="125.125.125"; version=1r/  z6blah=rhubarb; domain=".sol.no"; path="/foo"; version=1zhttp://www.sol.no/foo/barz3bing=bong; domain=".sol.no"; path="/foo"; version=1z5whiz=ffft; domain=".sol.no"; port="90,100"; version=1r0  z9foo9=bar; version=1; domain=".sol.no"; port; max-age=100;zhttp://www.sol.no/<oo/z"foo8=bar; version=1; path="/%3coo"r  N)r   r   r   rA  r$   r(  r   r   r  rN  r  r  )r'   rD  r   max_agerR  r   olds   &      r-   test_rejectionLWPCookieTests.test_rejection  sc   !$/$  q"7BD q"7HJQ# q"9HJQ# q"9MOQ# q":KMQ# q"5 +, 	Q# q"= +, 	Q# q"5 +, 	Q# "AB
 	Q# q"5 ./ 	Q# q":DFQ# ##	'FF8DF1q'CC(AFF8DF1X&d1g& X&s   =I
 
I"c                F   \        \        R R7      4      p\        VRR4       \        VRR4      p\        P                  ! R\        P
                  4      pV P                  RV4       V P                  W#4       \        VR4      pV P                  V4       \        VR	4      pR
# )Tr  z7http://www.acme.com/foo%2f%25/%3c%3c%0Anew%C3%A5/%C3%A5zfoo  =   bar; version    =   1u/   http://www.acme.com/foo%2f%25/<<%0anewå/æøåz bar=baz; path="/foo/"; version=1z^\$version=\"?1\"?r   u-   http://www.acme.com/foo/%25/<<%0anewå/æøåu   http://www.acme.com/üN)	r   r   r   rP  compileIrr  r%   rA  )r'   r   rR  
version_res   &   r-   test_url_encoding LWPCookieTests.test_url_encoding-  s     )$78a 56	8 H.0 ZZ 5rtt<
i(,FH  q"<=r0   c                  a \         P                  ! 4       ^ ,          ^,           p\        P                  o\	        S\        RR7      R7      p\        VRR4       \        VRR4       \        VRR4       RV3,          p\        VR	R
V,          4       \        VR	RV,          4       \        VR	RV,          4       V F(  pVP                  R8X  g   K  VP                  RR4       K*  	  V3R lpV! VR4      pV P                  \        V4      ^4       V P                  R\        V4      4       V P                  R\        V4      4       V! VR4      pV P                  \        V4      ^4       V P                  R\        V4      4       R# )r>   Tr  r  r  z foo1=bar; max-age=100; Version=1z4foo2=bar; port="80"; max-age=100; Discard; Version=1zfoo3=bar; secure; Version=1zexpires=09-Nov-%d 23:12:40 GMTzhttp://www.foo.com/zfooa=bar; %szfoob=bar; Domain=.foo.com; %sz fooc=bar; Domain=www.foo.com; %sr  HTTPOnlyrs   c                    <  V P                  VR 7       \        S\        RR7      4      pVP                  VR 7       \        P
                  ! S4       V#   \        P
                  ! S4       i ; i)r  Tr  )r  r   r   r  r   r  )r  r  new_cr   s   && r-   save_and_restore5LWPCookieTests.test_mozilla.<locals>.save_and_restore]  s^    +~6()<T)JL

.
9  *L   *s   :A A-zname='foo1', value='bar'zrest={'HTTPOnly': ''}FN)r8   rU  r   r   r   r   r   r   rM  set_nonstandard_attrr$   r(  rr  rN  )r'   rW  r   r   rR  rx  rw  r   s   &      @r-   test_mozillaLWPCookieTests.test_mozillaC  s^   (+a/##X$7$EGa/8	:a/L	Na/1NO2m5EE!2(72	4!29GC	E!2<wF	H F{{f$++J; 	 !D)UQ'0$u+>-tE{; E*UQ'0$u+>r0   c                   \        4       p. p\        P                  P                  R 4      pVP	                  R4       \        VR4      pVP                  WC4       VP	                  R4       \        VR4      pVP                  WC4       \        P                  P                  R 4      pVP                  V4       V P                  RVP                  R4      4       V P                  RVP                  R4      4       R# )zhttp://foo.bar.acme.com/fooz4Set-Cookie: Customer=WILE_E_COYOTE; domain=.acme.comzhttp://www.acme.com/fooz4Set-Cookie: PART_NUMBER=3,4; domain=foo.bar.acme.comzPART_NUMBER=3,4r   zCustomer=WILE_E_COYOTEN)
r   r   r   r   r   r   r   r   rr  r   r[  s   &    r-   test_netscape_misc!LWPCookieTests.test_netscape_miscp  s    Knn$$%BC 	MN7$=>	##
 	MN7$=>	##nn$$%BC	C ')AB.s~~h/GHr0   c                   \        \        R R7      4      p\        VRR4       \        VRR4      pV P                  RV4       \        VRR4       \        VR4      pV P                  RV4       V P	                  \        V4      ^4       R# )	Tr  http://example/z#foo1=bar; PORT; Discard; Version=1;z$foo2=bar; domain=".local"; Version=1r  zfoo3=bar; Version=1r   N)r   r   r   rr  r$   r(  ra  s   &  r-   test_intranet_domains_2965)LWPCookieTests.test_intranet_domains_2965  s    )$78a*;	=q"3EGj&)a*,ABq"34j&)Q#r0   c                0   \        \        R R7      4      p\        VRR4       \        VRR4      pV P                  \	        V4      ^4       V P                  RV4       \        VR4      pV P                  RV4       V P                  \	        V4      ^4       R# )Fr  r  r  zfoo2=bar; domain=.localr   N)r   r   r   r$   r(  rr  ra  s   &  r-   test_intranet_domains_ns'LWPCookieTests.test_intranet_domains_ns  s    )E:;!.
;"1&7#<>Q#j&)"1&78j&)Q#r0   c                   \        \        R R7      4      p. p\        P                  P	                  R4      pVP                  R4       \        VR4      pVP                  WC4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       \        P                  P	                  R4      pVP                  V4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       R	# )
Tr  zhttp://www.ants.com/z,Set-Cookie: JSESSIONID=ABCDERANDOM123; Path=r   zJSESSIONID=ABCDERANDOM123r  rR  zhttp://www.ants.com:8080N)r   r   r   r   r   r   r   r   r   r$   r   r[  s   &    r-   test_empty_pathLWPCookieTests.test_empty_path  s    )D9:nn$$%;<EF7$:;	##nn$$%;<	C 14	6	2NC nn$$%?@	C 14	6	2NCr0   c                .   \         P                  ! 4       ^ ,          ^,           p\        P                  P	                  R4      p. pVP                  R4       VP                  RV,          4       VP                  RV,          4       VP                  R4       VP                  R4       \        VR4      p\        4       pVP                  WB4       R^ R^ R	^ R
^ /pV F'  pRVP                  ,          pWh,          ^,           Wh&   K)  	  VP                  4        V F'  pRVP                  ,          pWh,          ^,           Wh&   K)  	  V P                  VR,          VR
,          4       V P                  VR,          ^ 4       V P                  VR	,          ^ 4       R# )r>   z"http://www.perlmeister.com/scriptsz$Set-Cookie: s1=session;Path=/scriptszWSet-Cookie: p1=perm; Domain=.perlmeister.com;Path=/;expires=Fri, 02-Feb-%d 23:24:20 GMTz>Set-Cookie: p2=perm;Path=/;expires=Fri, 02-Feb-%d 23:24:20 GMTz<Set-Cookie: s2=session;Path=/scripts;Domain=.perlmeister.comz2Set-Cookie2: s3=session;Version=1;Discard;Path="/"session_after
perm_aftersession_beforeperm_beforez	%s_beforez%s_afterN)r8   rU  r   r   r   r   r   r   r   r  r}  r$   assertNotEqual)	r'   rW  r   r   r   r   counterrR  keys	   &        r-   test_session_cookies#LWPCookieTests.test_session_cookies  sv   (+a/
 nn$$%IJ=> D$% 	& 	 02?@ 	A 1 	2KL7$HIK	##"A#Q !% F,C"<!+GL  	
!Fv||+C"<!+GL 
 	.0FG115G$45q9r0   rr   N)ry   rz   r{   r|   rX  r\  rb  rg  rl  rr  r{  r~  r  r  r  r  r~   r   r   s   @r-   rP  rP    sQ     Y4v1>fg/`37jX't>,+?ZI.$
$D>(: (:r0   rP  __main__)4__doc__r  r  sysrP  rT   r   test.supportr   r   r8   r8  urllib.requestr   http.cookiejarr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   platformr:  TestCaser   r   r   r   r   r   r   r=  rP  ry   mainrr   r0   r-   <module>r     s    " 	  
 	  " (   ! ! ! ! ! ! ! \\W$	jBH%% jBZt!(## t!n) )ED
t'** t'lL*(## L*^K	:X&& K	:\ zMMO r0   