python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_urllib2.cpython-312.pyc

Αe=>ddlZddlmZddlmZddlmZddlmZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZmZmZmZmZmZddlmZddlZddlZej:d	
Gddej<ZGd
dej<Z GddZ!GddZ"Gdde#Z$Gdde	jJZ&GddZ'GddZ(Gdde	jRZ*GddZ+Gdd Z,d!Z-d"Z.Gd#d$ej^j`Z1Gd%d&ej^jdZ3e4ejjd'rGd(d)ej^jlZ7Gd*d+ej^jdZ8Gd,d-Z9Gd.d/ej<Z:d0Z;Gd1d2ej<Z<Gd3d4ej<Z=Gd5d6ej<Z>e?d7k(rejyy)8N)support)	os_helper)warnings_helper)test_urllib)mock)RequestOpenerDirectorHTTPBasicAuthHandlerHTTPPasswordMgrWithPriorAuth_parse_proxy_proxy_bypass_macosx_sysconfAbstractDigestAuthHandler)urlparseT)modulec$eZdZdZdZdZdZy)TrivialTestscdD]}i}td|z||d=|dk(rmtjdk(rZ|jd|jd}}|j	|j
d|j	|j
d|j
D]7\}}|j	|j
d	|z|d
|d|j
9y)N)requestresponseparseerrorrobotparserzfrom urllib.%s import *__builtins__rnturl2pathnamepathname2url
nturl2pathz	urllib.%sz is exposed in 'urllib.z' but defined in )execosnamepopassertEqual
__module__items)selfrcontextupkvs       E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_urllib2.pytest___all__zTrivialTests.test___all__%sL	/FG*V3W='"rww${{>2GKK4O1  |<  |<


/1  {V/C./
/	/c"|jtjj|j	t
tjjdtjjtjjjtjd}tjdk(rd|z}nd|z}tjj
|5}|jdddy#1swYyxYw)Nz	bogus url/rz
file:///%s	file://%s)
addCleanupurllibr
urlcleanupassertRaises
ValueErrorurlopenrpathabspath__file__replacesepr read)r%fnamefile_urlfs    r+test_trivialzTrivialTests.test_trivial4s	
112*fnn&<&<kJ 7 78@@M
77d?#e+H"U*H
^^
#
#H
-	
FFH			s+DDcdgdfdddgfdgdfdgd	fg}|D]4\}}|jtjj||6y)
Nza,b,c)abczpath"o,l"og"i"cal, examplezpath"o,l"og"i"calexampleza, b, "c", "d", "e,f", g, h)rBrCz"c"z"d"z"e,f"ghza="b\"c", d="e\,f", g="h\\i")za="b"c"zd="e,f"zg="h\i")r"r2rparse_http_list)r%testsstringlists    r+test_parse_http_listz!TrivialTests.test_parse_http_listGsk
o&
),?+KL
*
8
:
/
/
12"	KLFDV^^;;FCTJ	Kr-ctjjd}|j|jt|y)Nreason)r2rURLErrorassertInrNstr)r%errs  r+test_URLError_reasonstrz$TrivialTests.test_URLError_reasonstrRs,ll##H-

cjj#c(+r-N)__name__r#__qualname__r,r@rLrSr-r+rr#s
/&	K,r-rc$eZdZdZdZdZdZy)RequestHdrsTestscd}|jt|ddijdd|jt|ddijddy)a(
        The Request.headers dictionary is not a documented interface.  It
        should stay that way, because the complete set of headers are only
        accessible through the .get_header(), .has_header(), .header_items()
        interface.  However, .headers pre-dates those methods, and so real code
        will be using the dictionary.

        The introduction in 2.4 of those methods was a mistake for the same
        reason: code that previously saw all (urllib2 user)-provided headers in
        .headers now sees only a subset.

        http://example.com	Spam-eggsblahheadersz	spam-EggSN)r"rr^)r%urls  r+test_request_headers_dictz*RequestHdrsTests.test_request_headers_dictYsi#*5v)>##*7;89?	A	
*5v)>##*7;89?	Ar-cd}t|ddi}|j|jd|j|j	dg|jdd|jt
|j	ddg|j|jd	|j|jd	|j|jd	d
d
|jd|j|jd|jdd|j|jd|jd|j|jdy
)a;
        Note the case normalization of header names here, to
        .capitalize()-case.  This should be preserved for
        backwards-compatibility.  (In the HTTP case, normalization to
        .title()-case is done by urllib2 before sending headers to
        http.client).

        Note that e.g. r.has_header("spam-EggS") is currently False, and
        r.get_header("spam-EggS") returns None, but that could be changed in
        future.

        Method r.remove_header should remove items both from r.headers and
        r.unredirected_hdrs dictionaries
        rZr[r\r])r[r\zFoo-Barbaz)zFoo-barrbz	Not-theredefaultzUnredirected-spamEggsN)r
assertTrue
has_headerr"header_items
add_headersortedassertFalseassertIsNone
get_header
remove_headeradd_unredirected_header)r%r_reqs   r+test_request_headers_methodsz-RequestHdrsTests.test_request_headers_methodsns>#cK#89{34))+.C-DEy%( 0 0 23,.CD	F45#..56Y?K+&45##$7@':;<-.(;<=r-ctjj}|j}|j}|dddd|dddd|dddd	|dd
dd|dd
dd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|d	ddd|d	ddd|d	ddd|j|d	dd|j|d	dd|j|d	dd|j|d	dd|j|d	d d|j|d	d!d"|d	d#d$d%|j|d	d&d"|j|d	d#d'|j|d	d(d'|d)dd*d+|d)dd,d-|j|d)dd.|d/dd0d/|j|d/dd1|j|d/d2d"|j|dd3d"|j|dd4d5|j|ddd5|j|dd
d6|j|dd
d7y)8Nz
Some Realmhttp://example.com/joepasswordzhttp://example.com/ninizhttp://c.example.com:31283rDz
d.example.com4dze.example.com:31285eexample.com)rsrtrZzhttp://example.com/spamzhttp://example.com/spam/spamzhttp://example.com/foofoozhttp://example.com/barbarninizhttp://example.com/foo/barfoobarnibar)r|ru)r}r~zhttp://example.com/foo/zhttp://example.com/foo/bazzhttp://example.com/foobarNNzhttp://example.com/baz/rbnininizhttp://example.com/baz)rbrzhttp://example.com/baz/barrCfirstr\secondspam)rrrB1)rrBzhttp://a.example.com/z
c.example.comzc.example.com:3128)rvrD)rwrx)ryrzr2rHTTPPasswordMgradd_passwordfind_user_passwordr"r%mgraddfind_user_passs    r+test_password_managerz&RequestHdrsTests.test_password_managers`nn,,.//L/
CL14>L5sC@L/34L.S9	
mD,	.6MN,	.6JK,	.6KL,	.(AC,	.	
(FH,	.	C)5$7C)5&9C-xA-EF&	(-EF(	*-FG&	(-IJ&	(-IJ&	(-HI%	'	C*E8<-EF%	'-FG*	,-IJ*	,
	C&8C&&9-BC+	-
	C%sC0-BC#	%	
-DE%	'
	
oF%	'6JK#	%<)DE		
oF#	%6JK#	%r-ctjj}|j}|j}|dddd|dddd|d	d
dd|d
ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|ddd|j|d	dd|j|d	d
d|j|d	dd|j|d
dd|j|d
d d|j|d
d!d|j|d
d"dy#)$z
        The point to note here is that we can't guess the default port if
        there's no scheme.  This applies to both add_password and
        find_user_password.
        r?zhttp://g.example.com:8010jrFzhttp://h.example.com11r)rGzi.example.com:8012liz
j.example.com13mzg.example.com:100rzg.example.com:80)rrz
g.example.comzhttp://g.example.com:100zhttp://g.example.comz
h.example.com)rr)zh.example.com:80zhttp://h.example.com:80z
i.example.com)rrzhttp://i.example.com:80)rrzj.example.com:80zhttp://j.example.comzhttp://j.example.com:80Nrrs    r+"test_password_manager_default_portz3RequestHdrsTests.test_password_manager_default_portsnn,,.//C*D#6C's3C#T3/C$,-@A%	'-?@$	&_=%	'-GH%	'-FG$	&-CD$	&_={K-?@+N-FG$	&_=|L-?@+N-FG$	&_={K-?@%	'-CD$	&-FG%	'r-N)rTr#rUr`rprrrVr-r+rXrXWsA*">HT%l''r-rXc6eZdZgZdej
fdZdZy)
MockOpenerNc0|||c|_|_|_yN)rodatatimeout)r%rorrs    r+openzMockOpener.opens,/w)$)T\r-c"||c|_|_yr)protoargs)r%rrs   r+rzMockOpener.errors %t
DIr-)rTr#rU
addheaderssocket_GLOBAL_DEFAULT_TIMEOUTrrrVr-r+rrsJ!6+I+I?,r-rc"eZdZddZddZdZy)MockFileNcyrrVr%counts  r+r<z
MockFile.readr-cyrrVrs  r+readlinezMockFile.readline rr-cyrrVr%s r+closezMockFile.close#rr-r)rTr#rUr<rrrVr-r+rrs


r-rceZdZdZy)MockHeadersc4t|jSr)rKvalues)r%r s  r+
getheaderszMockHeaders.getheaders(sDKKM""r-N)rTr#rUrrVr-r+rr's#r-rc eZdZddZdZdZy)MockResponseNctjj||||||f\|_|_|_|_yr)ioStringIO__init__codemsgr^r_)r%rrr^rr_s      r+rzMockResponse.__init__-s5
T4(6:C#6M3	48T\48r-c|jSrr]rs r+infozMockResponse.info1s||r-c|jSrr_rs r+geturlzMockResponse.geturl4xxr-r)rTr#rUrrrrVr-r+rr,sNr-rceZdZdZdZy)
MockCookieJarc||_yr)ach_req)r%rs  r+add_cookie_headerzMockCookieJar.add_cookie_header9s	r-c"||c|_|_yr)ec_reqec_r)r%rrs   r+extract_cookieszMockCookieJar.extract_cookies<s!((TYr-N)rTr#rUrrrVr-r+rr8s3r-rceZdZdZdZy)
FakeMethodc.||_||_||_yr)	meth_namehandleaction)r%rrrs    r+rzFakeMethod.__init__As"r-cR|j|j|jg|Sr)rrr)r%rs  r+__call__zFakeMethod.__call__Fs"t{{4>>4;;>>>r-N)rTr#rUrrrVr-r+rr@s
?r-rc$eZdZdZdZdZdZy)MockHTTPResponsecJ||_||_||_||_d|_y)N)fprstatusrNr)r%rrrrNs     r+rzMockHTTPResponse.__init__Ks%	r-cy)NrVrs r+r<zMockHTTPResponse.readRsr-ciSrrVrs r+rzMockHTTPResponse.infoUs	r-c|jSrrrs r+rzMockHTTPResponse.geturlXrr-N)rTr#rUrr<rrrVr-r+rrJsr-rcXeZdZdZej
fdZdZddZddddZ	d	Z
d
Zy)
MockHTTPClasscXd|_g|_d|_d|_d|_i|_y)NrF)levelreq_headersrraise_on_endheaderssock_tunnel_headersrs r+rzMockHTTPClass.__init__]s/
	#( 	!r-c"||_||_|Sr)hostr)r%rrs   r+rzMockHTTPClass.__call__es	r-c||_yr)r)r%rs  r+set_debuglevelzMockHTTPClass.set_debugleveljs	
r-Nch||_||_|r||_y|jjyr)_tunnel_host_tunnel_portrclear)r%rportr^s    r+
set_tunnelzMockHTTPClass.set_tunnelms/  #*D   &&(r-F)encode_chunkedc||_||_|#|xj|jz
c_|jj	|r||_||_|jr
tyr)	methodselectorrr$sortrrrOSError)r%rr_bodyr^rs      r+rzMockHTTPClass.requestusf


/DI,##)O$r-c.ttiddS)NrOK)rrrs r+getresponsezMockHTTPClass.getresponses
BT::r-cyrrVrs r+rzMockHTTPClass.closerr-r)rTr#rUrrrrrrrrrrVr-r+rr\s8"&,%C%C
)$;
r-rc4eZdZdZdZdZdZdZdZdZ	y)	MockHandlerc&|j|yr)_define_methods)r%methodss  r+rzMockHandler.__init__sW%r-c|D]H}t|dk(r|\}}n|d}}t|||j}t|j||Jy)N)lenrrsetattr	__class__)r%rspecr rmeths      r+rzMockHandler._define_methodssP	0D4yA~#f#TfdFDKK8DDNND$/
	0r-c|jjj||||f|y|dk(r|S|dk(rtddid}|S|dk(rt	dS|jdrT||j
d	d
zd}	t|}tddid}|jjd|d||diS|d
k(rtjjdJ#t$rYbwxYw)Nreturn selfreturn responserrrreturn requestzhttp://blah/r httprraiser\)parentcallsappendrr
startswithrfindintr5rr2rO)r%fn_namerrkwdsresrs       r+rzMockHandler.handles
  $t!<=>
}
$K
(
(sD"b1CJ
'
'>**


w
'&,,s+A-./D
4ysD"b1C;;$$VT!Wc4RHH
w
,,''//


sC$$	C0/C0cyrrVrs r+rzMockHandler.closerr-c4||_g|j_yr)rr)r%rs  r+
add_parentzMockHandler.add_parentsr-cNt|dsy|j|jkS)N
handler_orderT)hasattrr)r%others  r+__lt__zMockHandler.__lt__s&uo.!!E$7$777r-N)
rTr#rUrrrrrrr"rVr-r+rrs'M&0.
8r-rcg}d}|D]f}Gddt}||}|xj|z
c_|j||dz}|j||j	|h|S)aCreate MockHandlers and add them to an OpenerDirector.

    meth_spec: list of lists of tuples and strings defining methods to define
    on handlers.  eg:

    [["http_error", "ftp_open"], ["http_open"]]

    defines methods .http_error() and .ftp_open() on one handler, and
    .http_open() on another.  These methods just record their arguments and
    return None.  Using a tuple instead of a string causes the method to
    perform some action (see MockHandler.handle()), eg:

    [["http_error"], [("http_open", "return request")]]

    defines .http_error() on one handler (which simply returns None), and
    .http_open() on another handler, which returns a Request object.

    rceZdZy)6add_ordered_mock_handlers.<locals>.MockHandlerSubclassNrTr#rUrVr-r+MockHandlerSubclassr%r-r'r)rrrradd_handler)opener	meth_spechandlersrmethsr'rGs       r+add_ordered_mock_handlersr.sy&H
E		+	
 &	5 	V	1	Or-cJt}|D]}|j||Sr)r	r))handler_instancesr*rGs   r+build_test_openerr1s,

F
1Mr-c&eZdZdfd	ZdZxZS)MockHTTPHandlercLtt||t|_y)N
debuglevel)superr3rrhttpconn)r%r6rs  r+rzMockHTTPHandler.__init__s
ot--D%
r-c:|j|j|Srdo_openr8r%ros  r+	http_openzMockHTTPHandler.http_opens||DMM3//r-r)rTr#rUrr=
__classcell__rs@r+r3r3s
(0r-r3ceZdZdZdZdZy)MockHTTPHandlerRedirectc@||_||_|jyr)rr^reset)r%rr^s   r+rz MockHTTPHandlerRedirect.__init__s	

r-c d|_g|_y)Nr)_countrequestsrs r+rCzMockHTTPHandlerRedirect.resets
r-cddl}ddl}|jj|j	||j
dk(r|j
dz|_tjj|j}|j|j}|jjd|t|j||S||_|jd}t!dd|d|j#S)Nrrr

rrr)emailcopyrFrdeepcopyrErclient	responsesrmessage_from_stringr^rrrrorget_full_url)r%rorIrJr rs      r+r=z!MockHTTPHandlerRedirect.http_opens

T]]3/0;;!++/DK;;((3D++DLL9C;;$$XZD#?
?DH++J7CT3C4D4D4FGGr-NrTr#rUrrCr=rVr-r+rArAs
Hr-rAHTTPSConnectionc&eZdZdfd	ZdZxZS)MockHTTPSHandlercNtt||||t|_yr)r7rSrrr8)r%r6r&check_hostnamers    r+rzMockHTTPSHandler.__init__s "D2:wW)ODMr-c:|j|j|Srr:r<s  r+
https_openzMockHTTPSHandler.https_opens<<

s33r-)NNN)rTr#rUrrWr>r?s@r+rSrSs
	,	4r-rSceZdZdZdZdZy)MockHTTPHandlerCheckAuthc ||_d|_yNF)rhas_auth_header)r%rs  r+rz!MockHTTPHandlerCheckAuth.__init__ s	$r-cd|_yr[)r\rs r+rCzMockHTTPHandlerCheckAuth.reset$s
$r-c|jdrd|_tjj|j
}t
|j
|td|jS)N
AuthorizationTr)	rfr\rrLrMrrrrO)r%ror s   r+r=z"MockHTTPHandlerCheckAuth.http_open'sP>>/*#'D {{$$TYY/DIItXZS=M=M=OPPr-NrPrVr-r+rYrYs%%Qr-rYceZdZdZdZy)MockPasswordManagerc<||_||_||_||_yr)realmr_userrt)r%rcurirdrts     r+rz MockPasswordManager.add_password0s
	 
r-cN||_||_|j|jfSr)target_realm
target_urlrdrt)r%rcauthuris   r+rz&MockPasswordManager.find_user_password6s$!!yy$--''r-N)rTr#rUrrrVr-r+rara/s!(r-rac6eZdZdZdZdZdZdZdZdZ	y)	OpenerDirectorTestsc~Gddt}|jttj|y)NceZdZy)<OpenerDirectorTests.test_add_non_handler.<locals>.NonHandlerNr&rVr-r+
NonHandlerrn?r(r-ro)objectr4	TypeErrorr	r))r%ros  r+test_add_non_handlerz(OpenerDirectorTests.test_add_non_handler>s/		)(*66
	Fr-cddlm}t}ddgdgg}t|||j	t
jjdD]"}|j||j|dz$y)Nr)rO)r;r)
proxy_openr)redirect_requestr)doproxyredirectz://example.com/)
urllib.errorrOr	r.r)r2rUnknownHandlerr4r)r%rOor+schemes     r+test_badly_named_methodsz,OpenerDirectorTests.test_badly_named_methodsDsw	*
')FG
01		"!Y/	

fnn3356/	JFh7H0HI	Jr-c\t}gddgdgdgg}t||}td}|j|}|j	||d|ddf|ddfg}t||jD]3\}}|\}	}
}}|j	|	|
f||j	||f5y)N)r=ftp_openhttp_error_302rr=rrrrrr=)r	r.rrr"zipr)
r%r{r+r,rorrexpectedgothandlerr rrs
             r+test_handledz OpenerDirectorTests.test_handledYs7
L
)*
)*		-Q	:+,
FF3K	
HQK(1+{+hqk;-GH 0	+MHc(+%GT4gt_h7TC6*	+r-cvt}g}dgdfdgdffD]E\}}Gddt}||}||_|j||j	|G|jd|j
|jdd|d|j
|jdd|dy)	Nrrr=rceZdZy)COpenerDirectorTests.test_handler_order.<locals>.MockHandlerSubclassNr&rVr-r+r'rxsr-r'rrr)r	rrrr)rr"r)r%r{r,r-rr'rGs       r+test_handler_orderz&OpenerDirectorTests.test_handler_orderss'C&Dc%J'2mQ%7%9	 E=
k
$E*A+AOOOA
MM!		
$%A4A4r-ct}dgdgg}t||}td}|jtj
j|j||j|j|dd|fifgy)N)r=rrrrrr=)
r	r.rr4r2rrOrr"r)r%r{r+r,ros     r+
test_raisezOpenerDirectorTests.test_raises|
#$
)*	-Q	:+,&,,//=HQKsfb#I"JKr-ct}dgddggddgg}t||}td}|j|t	|j
dk(sJ|dd|ff|dd|tjd	d
iffg}t||j
D]7\}}|\}}	}
|j||	f|dd|j|
|d9y)N)r=z	error 302)http_error_400rr=))rrhttp_error_303
http_errorrrrrr.r)
r	r.rrrrr	ALWAYS_EQrr")r%r{r+r,rorrrrmethod_namers           r+test_http_errorz#OpenerDirectorTests.test_http_errors

'(
(+6
 	-Q	:+,	s177|q  1+{SF31+/))3B79:!0	+MHc)1&G[$g{3S!W=T3q6*	+r-cft}ddgddgg}t||}td}|j||ddf|ddf|ddf|ddfg}t	|j
D]\}\}}}	}
|dkrL|j
||f|||j
t|	d|j|	dt\|j
||f|||j
t|	d|j|	dt|	d|j|	dty)	N)http_requestr
)
http_responserrrrrrrr)
r	r.rr	enumeraterr"rassertIsInstancer)r%r{r+r,rorrrr rrs           r+test_processorsz#OpenerDirectorTests.test_processorssV
/
1
3
/
1
3	-Q	:+,	sa[.)HQK+H
a[/*Xa[/,JL/8.@	A*A*tT1u  '4%(;  TA.%%d1gw7  '4%(;  TA.%%d1gw77&))$q'<@	Ar-N)
rTr#rUrrr}rrrrrrVr-r+rkrk<s)FJ*+45$L+.!Ar-rkc	|jdtj
j
|}tjdk(r|jdr|dd}|S#t$rtjdwxYw)Nzutf-8zpath is not encodable to utf8rz///r)
encodeUnicodeEncodeErrorunittestSkipTestr2rrrr r)r7urlpaths  r+sanepathname2urlrswAGnn))$/G	ww$7--e4!"+N
A ?@@AsAA<c>eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
ejeej$dd
dZejeej$dd
dZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%ejeej$dd
d!Z&eje'jPd"k(d#d$Z)d%Z*d&Z+d'Z,d(Z-d)Z.d*Z/d+Z0d,Z1d-Z2d.Z3d/Z4y0)1HandlerTestscGddGfddtjj}ddl}d}||}t	|_dd|jd	d	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dddd	d	dddgd	df	dd|jd	d	dgddf	fD]s\	}}}}}	}
}}}
t|}d|_|j|}|j|j||j|j|	|j|jtj||j|j ||j|j"||j|j$j&||j|j$j(|
|j+}|j|j-d|
|jt/|dt1|vy)NceZdZdZdZdZy)-HandlerTests.test_ftp.<locals>.MockFTPWrapperc||_yrrr%rs  r+rz6HandlerTests.test_ftp.<locals>.MockFTPWrapper.__init__	 	r-c||c|_|_tj|jt|jfSr)filenamefiletyperrrr)r%rrs   r+retrfilez6HandlerTests.test_ftp.<locals>.MockFTPWrapper.retrfiles2/7,
t}{{499-s499~==r-cyrrVrs r+rz3HandlerTests.test_ftp.<locals>.MockFTPWrapper.closer-N)rTr#rUrrrrVr-r+MockFTPWrapperrs
!
>
r-rc6eZdZdZej
ffd	Zy)-HandlerTests.test_ftp.<locals>.NullFTPHandlerc||_yrrrs  r+rz6HandlerTests.test_ftp.<locals>.NullFTPHandler.__init__rr-c||c|_|_||c|_|_||_|j
|_|jSr)rdpasswdrrdirsr
ftpwrapper)r%rdrrrrrrs       r+connect_ftpz9HandlerTests.test_ftp.<locals>.NullFTPHandler.connect_ftpsD)-v&	4;'+T$	49 	"0";&r-N)rTr#rUrrrr)rsr+NullFTPHandlerrs
!%+$B$B
'r-rrzrheum rhaponicumz ftp://localhost/foo/bar/baz.html	localhostrIr|r}zbaz.htmlz	text/htmlz'ftp://parrot@localhost/foo/bar/baz.htmlparrotz*ftp://%25parrot@localhost/foo/bar/baz.htmlz%parrotz,ftp://%2542parrot@localhost/foo/bar/baz.htmlz	%42parrotzftp://localhost:80/foo/bar/PDzftp://localhost/baz.gif;type=aAzbaz.gifContent-typeContent-length)r2r
FTPHandlerftplibrrFTP_PORTrrrr"rdrrr
gethostbynamerrrrrrgetrr)r%rrrrGr_rrrdrtype_rrmimetyperorr^rs                 @r+test_ftpzHandlerTests.test_ftps=				
	'V^^66
	'	!4 <0
&//2r3U^Z
67
&//8RU^Z
6:
&//9b#U^Z
6<
&//;CU^Z
6+
"b"cU^R
'.
&//2r3
D
"!O!	HJCtT65$((#,CCK

3AQVVT*QXXv.QVVV%9%9$%?@QVVT*QVVT*Q\\22H=Q\\22E:ffhGW[[8(CS)9!:;SYGC!	Hr-c	ddl}tjj}t	x}|_tj}ttjj|}d}d|zd|zdtjd|g}	tjtj}|r|j!d|||D]A}	t#|d}
		|
j%||
j'|j)t+|	}	|j-}|j/}
|j1}|j'tj2|}|j4j7|j8d	
}tj:||j=|||j=|
dd|j=|
d
d|j=|
d||j=||	Dd|zdddtjddtj>d|dtj>d|fD]}		t#|d}
	|
j%||
j'|jAtjBjD|j(t+|	tj:|tjj}t	x}|_dD]y\}	}t+|	}	|j)||jG|jH||j=|jJd|j=|jJdk(|{y#tj$rd}YwxYw#|
j'wxYw#|j'wxYw#tj:|wxYw#|
j'wxYw#tj:|wxYw#tjBjD$r|jM|YwxYw)Nrs
hello, world
zfile://localhost%sr0zfile://rrwbT)usegmtrz
text/plainrrz
Last-modifiedzfile://localhost:80%szfile:///file_does_not_exist.txtz)file://not-a-local-host.com//dir/file.txtz:80r/z'file://somerandomhost.ontheinternet.com))zfile://ftp.example.com//foo.txtF)z file://ftp.example.com///foo.txtF)zfile://ftp.example.com/foo.txtF)z"file://somehost//foo/something.txtF)z#file://localhost//foo/something.txtFftp)'email.utilsr2rFileHandlerrrrTESTFNrrr7r8rrgethostnamegaierrorrrwriter	file_openrr<rrstatutils
formatdatest_mtimeremover"getcwdr4rrOassertIsrotyperj)r%rIrGr{rrtowriteurls	localaddrr_r?rrr^respurlstatsmodifiedrros                   r+	test_filezHandlerTests.test_filesNN&&(!|#AH!!"277??6#:;# 7*'!#11+>H
	,,V-?-?-ABIKKG<=	+CVT"A
"GGG$GGIKK-668DffhGhhjGGGI ;;11%..1N		&!T7+W^4lCW%56=W_5x@Wc*/	+4
$g--7#)#7#7#D#%99;
8YY[&
"
	"C

"&GGG$GGI!!&,,"7"7"#++ws|=		&!'	"*
NN&&(!|#AH	5HC#,C
2C 

aeeS)  51SXX.4	5y	I	GGIGGI		&!*GGI
		&!*<<((
&  %
&s'N%N96*O#!0OAO#,P9O=
AP2P,N65N69OO#O  O##O:=PPP),.QQctjj}tx}|_d}dD]\}}t||ddi}d|_|jddt}|j||}|j|j|j|j|j|jdk(df|j}	|	j |	j"|j%|j||j%|j&d	|j%|j(d
|j%|j*||j%|j,d|j%|j.gd|j%|j0|d
_|j5tj6j8|j|tdd}|j5t:|j<|dg|_dD]}td|}tAddid}|j=|}
|9|jCd|jD|jCd|jDn>|j%|jDdd|j%|jDdd|j%|jDdd	|j%|jDdd|jdd|jdd|jdd|jdd|j=|}
|j%|jDdd|j%|jDdd|j%|jDdd|j%|jDddy)Nrr))GETN)POSTsblahFoor}Spameggsrrr{rr/))
Connectionr)rr}rrTbadpostr)r-Nrrr0z!application/x-www-form-urlencodedHostr|rb)#r2rAbstractHTTPHandlerrrrrrnrr;r<rrrrrr__contains__r"rrrrrrrr4rrOrqdo_request_rrassertNotInunredirected_hdrs)r%rGr{r_rrrorrhdrsnewreqs           r+	test_httpzHandlerTests.test_httpws[NN..0!|#AH#>	.LFD#teU^4CCK''7 ?D		$$A
FFAJJ
FFAHH
FFAEESL$&668DHHd''QXXZ-TYY
6TZZ+T[[&1T]]C0T--@
A
TYY--	.2$( &,,//D#F+I6)Q]]C8))	CD/6CS$B/A]]3'F|  !133H3HI  1F1FG  !6!67G!H#N  !6!6~!F@B
S226:MJS226:FC
''(8%@''>''6''6]]3'FS223CDeLS22>BEJS226:EBS226:EB1	Cr-c"tjj}tx}|_tjdd}|j}|j|jtj|t|d5}td|i}|j|}|jd}|j!|d|j#|j%ddddt|d5}td|d	d
i}|j|}|j!t'|jdd
|j#|j%ddddy#1swYxYw#1swYyxYw)Nzw+bF)modedeleterbrrTransfer-encodingchunkedrContent-Length)r2rrrrtempfileNamedTemporaryFiler rr1runlinkrrrrlr"rjrfr)	r%rGr{file_obj	file_pathr?rortes	         r+test_http_body_filez HandlerTests.test_http_body_filesc
NN..0!|#AH..E%HMM			9-
)T
"	Ba/B7C]]3'F""#67BR+V../?@A	B)T
"	Ea/5Er4JKC]]3'FS!2!23C!DErJV../BCD		E	E	B	B	E	EsA"E9A+F9FFc@tjj}tx}|_tj}td|i}|j|}|j|jdd|j|jdddi}td||}|j|}|jt|jdd|j|jd|jy)Nrrrrrrr)r2rrrrrBytesIOrrr"rlrjrfrr)r%rGr{rrorr^s       r+test_http_body_fileobjz#HandlerTests.test_http_body_fileobjs
NN..0!|#AH::<+Xr:s#**+>?K**+;<=#R(+Xw?s#V../?@A2F**+>?@r-c	@tjj}tx}|_t
jddg}iddifD]}tj|tj5}td|j|}|j|}|sC|j|jdd|j|jdd	n*|jt|jdddddy#1swYxYw)
Nz-cpassrr)stdoutrrrrr)r2rrrrsys
executable
subprocessPopenPIPErr
rr"rlr)r%rGr{cmdr^procrors        r+test_http_body_pipez HandlerTests.test_http_body_pipes
NN..0!|#AH~~tW-,b11
	)G!!#joo>	
)$3T[['Js+$$V%6%67G%H$O$$V%6%67J%K%.0$$S):):;K)L%M%')	
)	
)
	)	
)	
)s
1BDD	ctjj}tx}|_d}iddifD]}td||}|j
|}|sC|j|jdd|j|jddk|jt|jddy)Nc3Kdyw)NsonerVrVr-r+
iterable_bodyz;HandlerTests.test_http_body_iterable.<locals>.iterable_bodysLsrrrrrr)
r2rrrrrrr"rlr)r%rGr{rr^rors       r+test_http_body_iterablez$HandlerTests.test_http_body_iterables
NN..0!|#AH	,b11	OG/'JC]]3'F  !2!23C!DdK  !2!23F!G!*,  V%6%67G%H!I2N	Or-ctjj}t|_|jt
dd}|j|jdd|j|jdy)NrrrVrrr)r2rrrrrrr"rlrjrf)r%rGros   r+test_http_body_empty_seqz%HandlerTests.test_http_body_empty_seqseNN..0<mmG$92>?(;<iH(89:r-c8tjj}tx}|_tj
dgd}iddifD]J}t
d||}|j|}|jt|jddLy)Nr)rrrrrr)r2rrrrarrayrrr"rrl)r%rGr{iterable_arrayr^rors       r+test_http_body_arrayz!HandlerTests.test_http_body_arrays
NN..0!|#AHS3,b11	JG/IC]]3'FS!2!23C!DEbI	Jr-cDtjjtjj
dd5t
}t}|j||jd|j|jddddy#1swYyxYw)Nr6http://www.example.com)rpatchrprrLHTTPConnectionr	r3r)rr"_debuglevelr%r{rGs   r+#test_http_handler_global_debuglevelz0HandlerTests.test_http_handler_global_debuglevel(st
ZZ

t{{99<
K	/ A!A
MM!
FF+,Q]]A.	/	/	/ABBct}td}|j||jd|j	|j
dy)Nr5r&)r	r3r)rr"r)r*s   r+"test_http_handler_local_debuglevelz/HandlerTests.test_http_handler_local_debuglevel0sAq)	

a	'(*r-rQz)HTTPSConnection required for HTTPS tests.cDtjjtjj
dd5t
}t}|j||jd|j|jddddy#1swYyxYw)Nr6https://www.example.com)rr'rprrLrQr	rSr)rr"r)r*s   r+$test_https_handler_global_debuglevelz1HandlerTests.test_https_handler_global_debuglevel7st
ZZ

t{{::L!
L	/ A "A
MM!
FF,-Q]]A.	/	/	/r,ct}td}|j||jd|j	|j
dy)Nrr5r2)r	rSr)rr"r)r*s   r+#test_https_handler_local_debuglevelz0HandlerTests.test_https_handler_local_debuglevel@sA*	

a	()*r-cttjj}t|_d}gd}|D]}t||}|j
|}|j|jdd|jdd|j
|}|j|jddy)Nr-)z#http://example.com/foo/bar/baz.htmlz$http://example.com//foo/bar/baz.htmlz$http://example.com/foo//bar/baz.htmlz$http://example.com/foo/bar//baz.htmlrr{zsomeproxy:3128)
r2rrrrrrr"r	set_proxy)r%rGrds_urlsds_urlds_req	np_ds_reqp_ds_reqs        r+test_http_doubleslashz"HandlerTests.test_http_doubleslashHs
NN..0<
	PFVT*F

f-IY88@-P
-t4}}V,HX77?O
	Pr-cbgd}td}|D]}||_t|}|j|j	||j|j
xsd|j
|jt|j	j|jy)N)zhttp://example.com?foo=bar#bazz)http://example.com?foo=bar&spam=eggs#bashrZrZr)rfull_urlrr"rOfragmentquery)r%rrr_parseds     r+test_full_url_setterz!HandlerTests.test_full_url_settercs

()	MCAJc]FQ^^-s3
QZZ-2v?Xann&67==v||L	Mr-ctd}|`|j|j|j|j|j	|j
dy)Nr&r)rr?rkr@r"r)r%rs  r+test_full_url_deleterz"HandlerTests.test_full_url_deleterzsJ,-
J!**%!**%R(r-ctjj}t|_d}t|}|j
|}|j|jd|j|jdd}t|}|j
|}|j|jd|j|jdy)Nzhttp://www.python.org?getspamwww.python.orgz	/?getspamhttp://www.python.orgr)
r2rrrrrrr"rr)r%rG	weird_urlrorurl_without_paths      r+test_fixpath_in_weirdurlsz&HandlerTests.test_fixpath_in_weirdurlss
NN..0<3	i s#&67+62&'s#&67"-r-c*tjj}tx}|_d}t|}t
ddid|}|j||}|j|||jt|dt
ddid|}|j||}|j|||jt|dt
dd	id|}|j||}|j|||jt|dt
d
did|}|j|j|||j|jd|j|j||d
dify)
NrrrrrrAcceptedzPartial contentizBad gatewayr)r2rHTTPErrorProcessorrrrrrrrjr rkr"rr)r%rGr{r_rornewrs       r+test_errorszHandlerTests.test_errorss^NN--/!|#AH#cldBC0sA&

aG,-j"b#6sA&

aG,-/R=sA&

aG,-mRS9!//#q12&)#q#}b!ABr-c^t}tjj|}t	|_t
d}tddid}|j|}|j|j||j|j||j|jd|j|j|j||}|j|j ||j|j"||j||y)Nrrrrrr{)rr2rHTTPCookieProcessorrrrrrrrr"origin_req_hostrjunverifiablerrr)r%cjrGrorrrQs       r+test_cookieszHandlerTests.test_cookiess
_NN..r2<+,dB+$

bjj#&

bjj&),,m<))*sA&

bii%

bggq!

ar-cd}d}tjj}tx}|_dD]}dD]}t|d|z}t
||}tj|_	|jdd|$|jdtt||jd	d
	||t|dtd|i|j)|j*j-|	|j)|j*j/d|j*j6D	cgc]}	|	j9}
}	|j;d|
|j;d|
|j)|j*j6dd|j;d	|j*j6|j;d	|j*j<t
|}tj|_	|fd}t
|d}d}tj|_			|||d|dz}#tj j"$r'|j%|d
|j'|YwxYw#t0$r)|j3|j*j4YwxYwcc}	w#tj j"$r7|j)|tjjj>YnwxYwt
|d}d}tj|_			|||d|z|dz}#tj j"$r7|j)|tjjj@YywxYw)Nhttp://example.com/a.htmlzhttp://example.com/b.html)i-ri/34)Nz
blah
blah
z
http_error_%sNonsensezviking=withholdrrrBlahlocation)r[r\rzcontent-lengthzcontent-typec
T|j|tddtd|iy)Nrr^r_)rrr)rGror_s   r+rxz,HandlerTests.test_redirect.<locals>.redirects'
S(*c6(*c):;
=r-r{)rUrrrrzhttp://example.com/%d)!r2rHTTPRedirectHandlerrrgetattrrrrrrhrQrrnrrr	HTTPErrorrPassertIsNotNoner"rorO
get_methodAttributeErrorrjrr^lowerrrmax_repeatsmax_redirections)
r%from_urlto_urlrGr{rrrroxr^rxrs
             r+
test_redirectzHandlerTests.test_redirects@.,NN..0!|#AH,	BD,
B Od$:;h-$<<z+<=#NN#3ST^D++FF;/3
D&&
F';<>  !3!3!5v>1$$QUU%5%5%7?/0eemm<1779<<  !17;  9  z!:!24  7  )@)@A=
B	BDh44!'	=h
>44	TC!67	I||--/MM$
3((./&1$$QUUZZ01
=6||%%	TUFNN$F$F$R$RS	T
h
>44	RC!85!@A	||%%	RU#^^??PP
R	RsQ;I*J!K	KAJJ!.KKAL/.L/M++AN?>N?c
2d}gd}gd}d}tjj}tx}|_t|}tj|_|D]V}|dz|z}	|jtjj|j|tddtd|	iX|D]\}|dz|z}
|j|tdd	td|
i|j|j j#|
^y)
NrZ)rhttpsr)fileimapldapzexample.com/b.htmlz://rzSecurity Loopholer_That's fine)r2rrarrrrrrr4rrcrrrr"rorO)r%rj
valid_schemesinvalid_schemesschemeless_urlrGr{ror|invalid_url	valid_urls           r+test_invalid_redirectz"HandlerTests.test_invalid_redirects..
0-NN..0!|#AHh44%	<F 5.>9Kfll44a6F6FS*=[ 9:
<	<$	>F7I
S(*c=Z34
6QUU//19=		>r-c
d}d}tjj}tx}|_t|}tj|_tjj||}|j|tddtd|i|j|jj!|y)NrZz/b.htmlrrsr_)r2rrarrrrrrrurljoinrrrr"rorO)r%rjrelative_urlrGr{rorxs       r+test_relative_redirectz#HandlerTests.test_relative_redirects. NN..0!|#AHh44LL((,?		hj#}Y/0	2++-y9r-cddlm}ddlm}|}||ddt	dd}t
jj}t
jj}t
jj|}t||||}|jd|j|jjdy)	Nr)	CookieJar)interact_netscapezhttp://www.example.com/z	spam=eggsrz%Location: http://www.cracker.com/

Cookie)http.cookiejarrtest.test_http_cookiejarrrAr2rHTTPDefaultErrorHandlerrarTr1rrjrorf)	r%rrrWhhhdehhrhcpr{s	         r+test_cookie_redirectz!HandlerTests.test_cookie_redirect+s,>
["7E
$S*U
V~~557nn002
^^
/
/
3b$R0	()**845r-c6d}tdd|z}tjj}tjj	}t|||}|j
d}|j|j|jy)Nz(http://www.example.com/index.html#OK

rz
Location: r&)
rAr2rrrar1rr"rstrip)r%redirected_urlrrrr{rs       r+test_redirect_fragmentz#HandlerTests.test_redirect_fragment:sxG
$S,*G
H~~557nn002b$,
VV,
-n&:&:&<=r-cjtjjtj
jd}tj|tj
_jttj
dtdfd}|tj
j_tjjd}j|jdy)Ns(HTTP/1.1 302 Found
Location: ?query

r()z/pathz/path?querycj|tj|||g|i|d|j_y)NsHTTP/1.1 200 OK

Hello!)r"nextrrfakedata)connrr_poskw
real_classr%rs     r+rz3HandlerTests.test_redirect_no_path.<locals>.requestNsAS$t*-JtVS=3="=&FDNN#r-zhttp://python.org/pathzhttp://python.org/path?query)r1r2rr3rrLr(rfakehttpriterr6r"r)r%	response1rrrrs`   @@r+test_redirect_no_pathz"HandlerTests.test_redirect_no_pathCs	
112[[//
E	%0%9%9)%D".>
K,-	G
.5""*
^^
#
#$<
=&DEr-cGddtjj}|}tjj|}d}|D]\}}|j	t|5t
jd|zdz|_|jd}d|zdz}|j}	|j|	j|t|	dddy#1swYxYw)	NceZdZdZy)4HandlerTests.test_redirect_encoding.<locals>.Handlerc|j|j|}|jj|_t	j
d|_|S)Ns)HTTP/1.1 200 OK
Content-Length: 3

123)r;
connectionbuflast_bufrr)r%roresults   r+r=z>HandlerTests.test_redirect_encoding.<locals>.Handler.http_open[sEdoos; $ 3 3
"-"6"6#
r-N)rTr#rUr=rVr-r+HandlerrZs

r-r))s/på-dansk/s/p%C3%A5-dansk/)/spaced%20path/r)s
/spaced path/r)s/?på-dansks/?p%C3%A5-dansks!HTTP/1.1 302 Redirect
Location: s

rrsGET  )
r2rHTTPHandlerbuild_openersubTestreprrrrrrrer)
r%rrr*rIr_rrrrs
          r+test_redirect_encodingz#HandlerTests.test_redirect_encodingWs	fnn00	),,W5
#(
	MXvd8n-	
M%0%9%9"$,-0&"
";;'<="V+d2!** 2 28 <d7mL	
M	
M
	M	
M	
Ms
.A0C))C2	c
d}t|t|fD]}t}tjj	|}|j|dgg}t
||}td}|j|jd|j||j|j||j|ddfg|jDcgc]}|dd		c}ycc}w)
Nproxy.example.com:3128r)HTTP)r=rzhttp://acme.example.com/zacme.example.comrr=r)dictr	r2rProxyHandlerr)r.rr"rrr)	r%r'rxr{phr+r,rotups	         r+
test_proxyzHandlerTests.test_proxyzs$1t|+	<A A,,Q/B
MM"12I1I>H45CSXX'9:
FF3KSXXq)x{K8923'':3c!Ah:
<	<;sC2c$dtjd<t}tjjt
d}|j|td}|j|jd|j||j|jdtd}|j|jd|j||j|jdtjd=y)	Nz
python.orgno_proxyproxy.example.comrzhttp://www.perl.org/www.perl.orgrHrGrenvironr	r2rrrr)rr"rrr%r{rros    r+test_proxy_no_proxyz HandlerTests.test_proxy_no_proxys!-

:
^^
(
(3F)G
H	

b,->2	s#67-.#34	s#34JJz"r-c|dtjd<t}tjjt
d}|j|td}|j|jd|j||j|jdtjd=y)N*rrrrHrGrrs    r+test_proxy_no_proxy_allz$HandlerTests.test_proxy_no_proxy_alls!$

:
^^
(
(3F)G
H	

b-.#34	s#34JJz"r-c	t}tjjt	d}|j|dgg}t
||}td}|j|jd|j||j|jd|j|ddfg|jDcgc]}|dd	c}ycc}w)	Nrro)rWrhttps://www.example.com/www.example.comrrWr)r	r2rrrr)r.rr"rrr)r%r{rr+r,rors       r+test_proxy_httpszHandlerTests.test_proxy_httpss
^^
(
(4L)M
N	

b
./
	-Q	:01#45	s#;<8A;56./gg6s#a(6	86s	C
ct}tjjt	d}|j|t
}|j|td}|jdd|jdd|j|jd|j|j|j||jd	|jj |j#d
|jj |j%|j|j|jd|j|j'ddy)NrrrProxy-AuthorizationFooBar
User-AgentGrailr)rr)rrProxy-authorization)r	r2rrrr)rSrrhr"rrkrrrr8rrPrdrl)r%r{r
https_handlerros     r+$test_proxy_https_proxy_authorizationz1HandlerTests.test_proxy_https_proxy_authorizations#
^^
(
(4L)M
N	

b(*
	

m$01,h7|W-#45#**+	s	
:&//;;	=

-#,,88	:S--.#;<(=>Ir-darwinzonly relevant for OSXc|dgdd}dD]!}|jt||d|z#dD]!}|jt||d|z#dgd}|jtd	|dd
dgd}d}|jt||d|zd
}|jt||d|zy)NF)foo.barz	*.bar.com	127.0.0.1z10.10z10.0/16)exclude_simple
exceptions)rzwww.bar.comrz	10.10.0.1z10.0.0.1z expected bypass of %s to be True)zabc.foo.barzbar.comz	127.0.0.2z	10.11.0.1notinbypassz!expected bypass of %s to be FalseTtestz10.0.0.0/40z172.19.10.0/24z172.19.10.5z10.0.1.5)rer
rj)r%bypassrs   r+test_osx_proxy_bypassz"HandlerTests.test_osx_proxy_bypasss$&
!	GDOO8vF>E
G	G
	ID9$G@4G
I	I%);4VVDE$)+;=
4T6B:TA	C5dFC;dB	Dr-cn|j||5t}t}tjj|}dj
|dz}td|}|j||j||j||d|||dddddy#1swYyxYw)N)rcr^z
rHr_!http://acme.example.com/protected)
rr	rar2rr
joinrAr)_test_basic_auth)r%r^rcr*password_managerauth_handlerrhttp_handlers        r+check_basic_authzHandlerTests.check_basic_auths
\\w\
7	G#%F24!>>>>?OPL;;w'*4D23=L|,|,!!&,"'7G"E"E
G	G	G	GsBB++B4c
d}d}d|d}d|d}d}d|d}d|dd|dd|d	|d
||d
||d
||d
||d
|fD]}d|g}|j||tjdtf5d
|g}|j||ddd||g||g||gfD]&}	|	D
cgc]}
d|
	}}
|j||(y#1swY>xYwcc}
w)Nzrealm2@example.comz
Basic realm=""zOtherscheme xxxzDigest realm="zn", qop="auth, auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"z
Basic realm=''z", charset="UTF-8"z, zWWW-Authenticate: zBasic Auth Realm was unquotedzWWW-Authenticate: Basic realm=)rrcheck_warningsUserWarning)r%rcrealm2basicbasic2other_no_realmdigest	realm_strr^
challenges	challenges           r+test_basic_authzHandlerTests.test_basic_auths$%wa( **"6(+>?E7!$E7!$E7"45gRx gR'(b(gRx hb 
	2I,I;78G!!'51!	2&
+
+-L%0-23	27w?@G!!'51	2V
V
UO
	2J)34$,I;74G4!!'51	2	2	24sC3C"Cc
tt}tjjt	d}|j|t
}tjj|}d}tdd|z}|j||j||j||d|||ddy)Nrr
ACME Networksiz(Proxy-Authenticate: Basic realm="%s"

rz&http://acme.example.com:3128/protected)
r	r2rrrr)raProxyBasicAuthHandlerrAr)r%r*rrrrcrs       r+test_proxy_basic_authz"HandlerTests.test_proxy_basic_auth+s!
^^
(
(3K)L
M2.0~~;;<LM.?%GI<(<(fl4I#\3CF6	 r-c
Gddt}Gddtjj}Gddtjj}|}t}||}||}d}t
dd	|z}	|j||j||j|	|j||d
||	|dd|j|jdd
gdzy)NceZdZdZdZy)QHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirectorc<tj|g|_yr)r	rrecordedrs r+rzZHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.__init__Fs''- "
r-c:|jj|yr)rr)r%rs  r+recordzXHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.recordJs

$$T*r-N)rTr#rUrrrVr-r+RecordingOpenerDirectorrEs
#
+r-rceZdZdZy)OHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandlerc|jjdtjjj
|g|i|y)Nr)rrr2rHTTPDigestAuthHandlerhttp_error_401r%rrs   r+rz^HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandler.http_error_401NsA""8,44CCDL>BLFJLr-NrTr#rUrrVr-r+TestDigestAuthHandlerrMs
Lr-rceZdZdZy)NHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandlerc|jjdtjjj
|g|i|y)Nr)rrr2rr
rrs   r+rz]HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandler.http_error_401TsA""7+33BB4K=AKEIKr-NrrVr-r+TestBasicAuthHandlerrSs
Kr-rrr&WWW-Authenticate: Basic realm="%s"

r_rrrr)r	r2rrr
rarAr)rr"r)
r%rrrr*rdigest_handler
basic_handlerrcrs
          r+#test_basic_and_digest_auth_handlersz0HandlerTests.test_basic_and_digest_auth_handlers<s	+n	+	LFNN$H$H	L	K6>>#F#F	K)*.0./?@,-=>
.=EG=)>*<(	
fm_#\3CAA	 	
8W*=a*?@r-ct}tjjd}t	dd}|j||j||j
t|jdy)NrzWWW-Authenticate: Kerberos

r&)	r	r2rrrAr)r4r5r)r%r*digest_auth_handlerrs    r+$test_unsupported_auth_digest_handlerz1HandlerTests.test_unsupported_auth_digest_handlernsc!$nnBB4H.57./<(*fkk3KLr-ct}tjjd}t	dd}|j||j||j
t|jdy)NrzWWW-Authenticate: NTLM

r&)	r	r2rr
rAr)r4r5r)r%r*basic_auth_handlerrs    r+#test_unsupported_auth_basic_handlerz0HandlerTests.test_unsupported_auth_basic_handlerxsc!#^^@@F.13-.<(*fkk3KLr-c	ddl}	d\}
}|j|||
||j||j|j||j|j|
|j
|j||j|j||j|j||j|j||jt|jd|j|jdj|t|
d|d}d|	j|j!j#z}
|j|jdj%||
|j|jdj&||
dx|_|_|j)|j||jt|jd|j|jdj|y)Nrwilecoyoter:asciizBasic r)base64rr"rcr_rdrtrrgrhrrFrjrfbytesencodebytesrdecoderlrrC)r%r*rauth_headerrcrrrequest_url
protected_urlrrdrtuserpassauth_hdr_values              r+rzHandlerTests._test_basic_auths	)h	!!%dHE 0 6 67&6&:&:;/445#3#<#<=K 	
)66>)44mD	
\223Q7..q1<<[IJD(3W="x(..0779:..q1<<[I'	)..q1CCKP'	)=A@ 0 9K \223Q7..q1<<[IJr-cd\}}d}td}t}t|}|jd|||d|j	|j||j	|j|dz|j
|j|dzt}|j||j||j||j	|jy)NrrrT)is_authenticatedz/nestedplain)rYrr
rrerrjr	r)rr\)r%rdrtrrpwd_managerauth_prior_handlerr*s        r+test_basic_prior_auth_auto_sendz,HandlerTests.test_basic_prior_auth_auto_sends*h9/4241+>''+tX	(	F	
44[AB44[95LMN55kG6KLM!-.<(K 	
445r-cd\}}d}d}t}t|}|j|||||j|}|j	|t}|j
|tdddz}	|j
|	|j||j|}|j|td}	|j	|	jt}|j
||j
|	|j||j|	jy)NrrACMErrr)rr
rrrjr	r)rArrerYr\)
r%rdrtrrcr r!is_authr*rs
          r+.test_basic_prior_auth_send_after_first_successz;HandlerTests.test_basic_prior_auth_send_after_first_successs$*h9241+>''{D(K..{;!!-..=DF<(K ..{; /4556!-.<(	K 	
445r-cdD]\}}dj|}tj|j|z}tj
j
}td}d|_|j||5}|jddd|j|jjdj|y#1swYAxYw)z=Test the connection is cleaned up when the response is closed))zConnection: closedata)zTransfer-Encoding: chunkeds4
data
0

)zContent-Length: 4r(zHTTP/1.1 200 OK
{}


http://dummy/NzConnection not closed with {!r})formatrrrr2rrrrr;r<refakesockclosed)r%transferrheaderrrroresps        r+test_http_closedzHandlerTests.test_http_closeds!

	DXt
5;;HEF''

$(>?Dnn88:G/*CCKs+
t		
OODMM00188B
D
	D

sCC	cztjd}tjj	}td}d|_|jtjj5|j||ddd|j|jjdy#1swY0xYw)z;Test the connection is cleaned up after an invalid responser-r)NzConnection not closed)rrr2rrrrr4rrL
BadStatusLiner;rer+r,)r%rrros    r+test_invalid_closedz HandlerTests.test_invalid_closeds##C(..446o&


t{{88
9	'OOD#&	'

,,.EF	'	's/B11B:N)5rTr#rUrrrrr
rrrr#r+r/r
skipUnlessr rrLr3r5r=rCrErKrRrXrmryr}rrrrrrrrrrplatformrrrrrr
r
rr"r&r0r3rVr-r+rrs>H@Z5x@CDE2.),O(;J/+X.?@Bmn/o/X.?@Bmn+o+P6M.).&C2"HRT>,:
6>F(!MF<$
#	#8 X.?@BmnJoJ.X13JKDLDBG+2Z "0AdMM#KJ66&6PD"Gr-rc0eZdZdZdZdZdZdZdZy)	MiscTestsc`|jtfd|jDy)Nc3<K|]}|jk(ywrr?).0rG
handler_classs  r+	<genexpr>z/MiscTests.opener_has_handler.<locals>.<genexpr>	s"6 !KK=86s)reanyr,)r%r*r;s  `r+opener_has_handlerzMiscTests.opener_has_handlers'6%+__66	7r-c.Gddtjj}Gddtjj}Gddtjj}tjj}|||}|j|||j|||||}|j|||j||||}|j|||}|j|tjj|tjj}|j|tjj|tjj}|j|tjjGddtjj}|||}|j|||j||y)	NceZdZy)2MiscTests.test_build_opener.<locals>.MyHTTPHandlerNr&rVr-r+
MyHTTPHandlerrA
r(r-rBceZdZdZy)/MiscTests.test_build_opener.<locals>.FooHandlercyrrVrs r+foo_openz8MiscTests.test_build_opener.<locals>.FooHandler.foo_openrr-N)rTr#rUrFrVr-r+
FooHandlerrD
r-rGceZdZdZy)/MiscTests.test_build_opener.<locals>.BarHandlercyrrVrs r+bar_openz8MiscTests.test_build_opener.<locals>.BarHandler.bar_openrr-N)rTr#rUrLrVr-r+
BarHandlerrJrHr-rMceZdZy)7MiscTests.test_build_opener.<locals>.MyOtherHTTPHandlerNr&rVr-r+MyOtherHTTPHandlerrO1r(r-rP)r2rrBaseHandlerrr>)r%rBrGrMrr{rPs       r+test_build_openerzMiscTests.test_build_openers	FNN66		33		33	~~22Z0:.:.
Z\2:.:.
'=1
N6>>#=#=>3346>>#=#=>33566>>#=#=>	!;!;	
(:;=1#56r-cd}dx}x}}d}tjj|||||}|jt	|d|j|jd|jt	|d|j|jdd|jd|j}|jt||d|jd|jd	}|jt||y)
z
        Issue 13211 reveals that HTTPError didn't implement the URLError
        interface even though HTTPError is a subclass of URLError.
        zsomething bad happenedNzContent-Length: 42rNr^zHTTP Error z: z<HTTPError >)r2rrcrer r"rNr^rrrQr)r%rr_rrrrRexpected_errmsgs        r+test_HTTPError_interfacez"MiscTests.test_HTTPError_interface8s
'dR#ll$$S$T2>X./%=>Y/0&:;14377CS?325((CGGDcO4r-ctjjddddd}|jt	|ddd|j|jjty)Nr_izMETHOD NOT ALLOWED	__notes__rV)	r2rrcr"rbrrr<r)r%rls  r+
test_gh_98778zMiscTests.test_gh_98778JsRLL""5#/CT4PK4b9addiik51r-cgd}|D] \}}|jt||"|jttdfy)N)r)NNNrr)NNNrr[r\)zjoe:password@proxy.example.com)Nrsrtr)z#joe:password@proxy.example.com:3128)Nrsrtr)zhttp://proxy.example.com/)rNNr)zhttp://proxy.example.com:3128/)rNNr)z&http://joe:password@proxy.example.com/rrsrtr)z*http://joe:password@proxy.example.com:3128)rrsrtr)z1ftp://joe:password@proxy.example.com/rubbish:3128)rrsrtr)z%http://joe:password@proxy.example.comr])z&http://user/name:password@localhost:22)r	user/namertlocalhost:22)z&http://username:pass/word@localhost:22)rusername	pass/wordr_)z'http://user/name:pass/word@localhost:22)rr^rar_zfile:/ftp.example.com)r"rr4r5)r%parse_proxy_test_casestcrs    r+test_parse_proxyzMiscTests.test_parse_proxyOsM$"
N3	9LB\"-x8	9	
*l4KLMr-ct}|jt5}|jdddd|j	tjdy#1swY/xYw)Ninvalidz5Unsupported digest authentication algorithm 'invalid')rr4r5get_algorithm_implsr"rQ	exception)r%rexcs   r+test_unsupported_algorithmz$MiscTests.test_unsupported_algorithm|sZ+-


z
*	3c''	2	3

C	
	3	3sA  A)N)	rTr#rUr>rRrVrYrdrjrVr-r+r7r7s#7*7X5$2
+NZ
r-r7cveZdZGddeZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZy)RequestTestsceZdZdZy)RequestTests.PutRequestPUTN)rTr#rUrrVr-r+
PutRequestrnsr-rpctd|_tddddi|_tdd|_|j	d|_|j	dd|_y)	Nhttp://www.python.org/~jeremy/rzX-Testrr]HEAD)rr)rrpostheadrpput
force_postrs r+setUpzRequestTests.setUpsf;<<"%-v$68	<VL	??#CD//*J*r-c|jd|jj|jd|jj|jd|jj|jd|j
j|jd|jjy)Nrrrsro)r"rtrerrurvrwrs r+test_methodzRequestTests.test_methods!5!5!78 3 3 56!5!5!78 3 3 56!;!;!=>r-cb|j|jj|jd|jj	d|j_|j|jj|jd|jj	y)Nrrr)rjrrr"rerers r+	test_datazRequestTests.test_datasq' 3 3 56


&!4!4!67r-cH|jd|jj|jjdd|j	d|jjdd|j_|jd|jjy)Nr*r)rrrrnr"rrs r+.test_setting_data_should_remove_content_lengthz;RequestTests.test_setting_data_should_remove_content_lengthsx)488+E+EF(()92>TXX778HIJ
)488+E+EFr-c`|jd|jjd|j_|jj	dd|jd|jjd|j`|jd|jjy)Nrr|r)rrrrrnr"rs r+/test_deleting_data_should_remove_content_lengthz<RequestTests.test_deleting_data_should_remove_content_lengths)488+E+EF
(()91=DHH667GHIHHM)488+E+EFr-cX|jd|jjy)Nrr)r"rrOrs r+test_get_full_urlzRequestTests.test_get_full_urls#9..0	2r-c|jd|jjtd}|jd|jy)Nz	/~jeremy/zhttp://www.python.org/r/)r"rrrr<s  r+
test_selectorzRequestTests.test_selectors;dhh&7&78./cll+r-cP|jd|jjy)Nr)r"rrrs r+
test_get_typezRequestTests.test_get_types/r-cP|jd|jjy)NrG)r"rrrs r+
test_get_hostzRequestTests.test_get_hosts)488==9r-cRtd}|jd|jy)Nzhttp://www.%70ython.org/rGrr"rr<s  r+test_get_host_unquotez"RequestTests.test_get_host_unquotes"01)3884r-cx|j|jj|jjdd|j	|jj|jd|jj|jd|jjy)NrrrG)rjr	has_proxyr7rer"rUrrs r+rzRequestTests.test_proxys}++-.>62**,-)488+C+CD7r-cRtd}|jd|jy)Nz<URL:http://www.python.org>rGrr<s  r+test_wrapped_urlzRequestTests.test_wrapped_urls"34)3884r-ctd}|jd|jtd}|jd|jd}t|}|j|j|y)N-http://www.python.org/?qs=query#fragment=truez
/?qs=queryzhttp://www.python.org/#fun=truer/.http://docs.python.org/library/urllib2.html#OK)rr"rrO)r%ror_s   r+test_url_fragmentzRequestTests.test_url_fragmentsiEFs||478cll+?cl))+S1r-cgd}|D]7}t|}|j|j|j9y)N)zhttp://docs.python.orgrr)rr"rOr?)r%rr_ros    r+test_url_fullurl_get_full_urlz*RequestTests.test_url_fullurl_get_full_urlsAA	?C#,CS--/>	?r-N)rTr#rUrrprxrzr|rrrrrrrrrrrrVr-r+rlrlsVW?8GG2,
0:585	2?r-rl__main__)Arrrtest.supportrrrrrrrr!rrrurllib.requestr2rr	r
rrr
rurllib.parserryhttp.clientrrequires_working_socketTestCaserrXrrrrrrrrIOBaserrrr.r1rrr3rQrAr rLHTTPSHandlerrSrYrarkrrr7rlrTmainrVr-r+<module>rs"(		

777"t,1,8$$1,hx'x((x'v,,

#$#
	2;;	33??ryy$*
*
Z3838lD0fnn000Hfnn88H84;;)*	46>>66	4Qv~~99Q&
(
(NA(++NAb	jG8$$jGZ!}
!!}
@^?8$$^?BzHMMOr-