python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_urllib2.cpython-311.opt-1.pyc

e6ddlZddlmZddlmZddlmZddlmZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZmZmZmZmZmZddlmZddlZddlZejd	
GddejZGd
dejZ GddZ!GddZ"Gdde#Z$Gdde	j%Z&GddZ'GddZ(Gdde	j)Z*GddZ+Gdd Z,d!Z-d"Z.Gd#d$ej/j0Z1Gd%d&ej/j2Z3Gd'd(ej/j0Z4Gd)d*Z5Gd+d,ejZ6d-Z7Gd.d/ejZ8Gd0d1ejZ9Gd2d3ejZ:e;d4krej<dSdS)5N)support)	os_helper)
socket_helper)warnings_helper)test_urllib)RequestOpenerDirectorHTTPBasicAuthHandlerHTTPPasswordMgrWithPriorAuth_parse_proxy_proxy_bypass_macosx_sysconfAbstractDigestAuthHandler)urlparseT)modulec&eZdZdZdZdZdZdS)TrivialTestscdD]}i}td|z||d=|dkrptjdkr`|d|d}}||jd||jd|D]1\}}||jd	|z|d
|d|j2dS)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.11.7/bootstrap/lib/python3.11/test/test_urllib2.pytest___all__zTrivialTests.test___all__%sL	/	/FG*V3W==='""rw${{>22GKK4O4O1  |<<<  |<<<


/
/1  {V/CQQ.////
/	/	/c
|tjj|t
tjjdtj	tjj
tjd}tj
dkrd|z}nd|z}tj|5}|ddddS#1swxYwYdS)Nz	bogus url/rz
file:///%s	file://%s)
addCleanupurllibr
urlcleanupassertRaises
ValueErrorurlopenrpathabspath__file__replacesepr read)r%fnamefile_urlfs    r+test_trivialzTrivialTests.test_trivial4s		
1222*fn&<kJJJ 788@@MM
7d??#e+HH"U*H
^
#
#H
-
-	
FFHHH																		sC88C<?C<cdgdfdddgfdgdfdgd	fg}|D]8\}}|tj||9dS)
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_listGs
ooo&
),?+KL
*
8
8
8
:
/
/
/
/
12"	K	KLFDV^;;FCCTJJJJ	K	Kr-ctjd}||jt|dS)Nreason)r2rURLErrorassertInrNstr)r%errs  r+test_URLError_reasonstrz$TrivialTests.test_URLError_reasonstrRs9l##H--

cj#c((+++++r-N)__name__r#__qualname__r,r@rLrSr-r+rr#sS
/
/
/&	K	K	K,,,,,r-rc&eZdZdZdZdZdZdS)RequestHdrsTestscd}|t|ddijdd|t|ddijdddS)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_dictYs#*5v)>####*;89?	A	A	A	
*5v)>####*;89?	A	A	A	A	Ar-cd}t|ddi}||d||dg|dd|t
|ddg||d	||	d	||	d	d
d
|
d||d|dd||d|
d||dd
S)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#8999{33444))++.C-DEEEy%((( 0 0 2 233,.CD	F	F	F44555#..55666Y??KKK+&&&44555##$7@@@':;;<<<-...(;<<=====r-cntj}|j}|j}|dddd|dddd|dddd	|dd
dd|dd
dd||ddd||ddd||ddd||ddd||ddd||ddd|d	ddd|d	ddd|d	ddd||d	dd||d	dd||d	dd||d	dd||d	d d||d	d!d"|d	d#d$d%||d	d&d"||d	d#d'||d	d(d'|d)dd*d+|d)dd,d-||d)dd.|d/dd0d/||d/dd1||d/d2d"||dd3d"||dd4d5||ddd5||dd
d6||dd
d7dS)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$n,,../L/
CCCL14>>>L5sC@@@L/3444L.S999	
mDD,	.	.	.6MNN,	.	.	.6JKK,	.	.	.6KLL,	.	.	.(ACC,	.	.	.	
(FHH,	.	.	.	C)5$777C)5&999C-xAAA-EFF&	(	(	(-EFF(	*	*	*-FGG&	(	(	(-IJJ&	(	(	(-IJJ&	(	(	(-HII%	'	'	'	C*E8<<<-EFF%	'	'	'-FGG*	,	,	,-IJJ*	,	,	,
	C&888C&&999-BCC+	-	-	-
	C%sC000-BCC#	%	%	%	
-DEE%	'	'	'
	
oFF%	'	'	'6JKK#	%	%	%N<)DEE				
oFF#	%	%	%6JKK#	%	%	%	%	%r-ctj}|j}|j}|dddd|dddd|d	d
dd|d
ddd||ddd||ddd||ddd||ddd||ddd||ddd||ddd||ddd||ddd||d	dd||d	d
d||d	dd||d
dd||d
d d||d
d!d||d
d"dd#S)$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n,,../C*D#666C's333C#T3///C$,,,-@AA%	'	'	'-?@@$	&	&	&_==%	'	'	'-GHH%	'	'	'-FGG$	&	&	&-CDD$	&	&	&_=={KKK-?@@+NNN-FGG$	&	&	&_==|LLL-?@@+NNN-FGG$	&	&	&_=={KKK-?@@%	'	'	'-CDD$	&	&	&-FGG%	'	'	'	'	'r-N)rTr#rUr`rprrrVr-r+rXrXWsXAAA*">">">HT%T%T%l''''''''''r-rXc.eZdZgZdejfdZdZdS)
MockOpenerNc2|||c|_|_|_dSN)rodatatimeout)r%rorrs    r+openzMockOpener.opens,/w)$)T\\\r-c$||c|_|_dSr)protoargs)r%rrs   r+rzMockOpener.errors %t
DIIIr-)rTr#rU
addheaderssocket_GLOBAL_DEFAULT_TIMEOUTrrrVr-r+rrsDJ!6+I????,,,,,r-rc$eZdZddZddZdZdS)MockFileNcdSrrVr%counts  r+r<z
MockFile.readr-cdSrrVrs  r+readlinezMockFile.readline rr-cdSrrVr%s r+closezMockFile.close#rr-r)rTr#rUr<rrrVr-r+rrsK












r-rceZdZdZdS)MockHeaderscDt|Sr)rKvalues)r%r s  r+
getheaderszMockHeaders.getheaders(sDKKMM"""r-N)rTr#rUrrVr-r+rr's######r-rc"eZdZddZdZdZdS)MockResponseNctj||||||f\|_|_|_|_dSr)ioStringIO__init__codemsgr^r_)r%rrr^rr_s      r+rzMockResponse.__init__-s=
T4(((6:C#6M3	48T\4888r-c|jSrr]rs r+infozMockResponse.info1s
|r-c|jSrr_rs r+geturlzMockResponse.geturl4	xr-r)rTr#rUrrrrVr-r+rr,sJNNNNr-rceZdZdZdZdS)
MockCookieJarc||_dSr)ach_req)r%rs  r+add_cookie_headerzMockCookieJar.add_cookie_header9s
r-c$||c|_|_dSr)ec_reqec_r)r%rrs   r+extract_cookieszMockCookieJar.extract_cookies<s!((TYYYr-N)rTr#rUrrrVr-r+rr8s233333r-rceZdZdZdZdS)
FakeMethodc0||_||_||_dSr)	meth_namehandleaction)r%rrrs    r+rzFakeMethod.__init__As"r-c4|j|j|jg|RSr)rrr)r%rs  r+__call__zFakeMethod.__call__Fs"t{4>4;>>>>>r-N)rTr#rUrrrVr-r+rr@s2
?????r-rc&eZdZdZdZdZdZdS)MockHTTPResponsecL||_||_||_||_d|_dS)N)fprstatusrNr)r%rrrrNs     r+rzMockHTTPResponse.__init__Ks)			r-cdS)NrVrs r+r<zMockHTTPResponse.readRsrr-ciSrrVrs r+rzMockHTTPResponse.infoUs	r-c|jSrrrs r+rzMockHTTPResponse.geturlXrr-N)rTr#rUrr<rrrVr-r+rrJsPr-rcPeZdZdZejfdZdZddZddddZ	d	Z
d
ZdS)
MockHTTPClasscZd|_g|_d|_d|_d|_i|_dS)NrF)levelreq_headersrraise_on_endheaderssock_tunnel_headersrs r+rzMockHTTPClass.__init__]s5
	#( 	!r-c"||_||_|Sr)hostr)r%rrs   r+rzMockHTTPClass.__call__es	r-c||_dSr)r)r%rs  r+set_debuglevelzMockHTTPClass.set_debugleveljs



r-Ncj||_||_|r	||_dS|jdSr)_tunnel_host_tunnel_portrclear)r%rportr^s    r+
set_tunnelzMockHTTPClass.set_tunnelmsC  	)#*D    &&(((((r-F)encode_chunkedc||_||_|"|xj|z
c_|j|r||_||_|jrtdSr)	methodselectorrr$sortrrrOSError)r%rr_bodyr^rs      r+rzMockHTTPClass.requestus|


/	DI,#	))O		r-c>ttiddS)NrOK)rrrs r+getresponsezMockHTTPClass.getresponses

BT:::r-cdSrrVrs r+rzMockHTTPClass.closerr-r)rTr#rUrrrrrrrrrrVr-r+rr\s"""&,%C
))))$;;;




r-rc6eZdZdZdZdZdZdZdZdZ	dS)	MockHandlerc0||dSr)_define_methods)r%methodss  r+rzMockHandler.__init__sW%%%%%r-c|D]K}t|dkr|\}}n|d}}t|||j}t|j||LdS)N)lenrrsetattr	__class__)r%rspecr rmeths      r+rzMockHandler._define_methodssh	0	0D4yyA~~#ff#TfdFDK88DDND$////
	0	0r-c&|jj||||f|dS|dkr|S|dkrtddid}|S|dkrt	dS|drx||d	d
zd}	t|}n#t$rYnwxYwtddid}|j	d|d||diS|d
krtj	ddS)Nreturn selfreturn responserrrreturn requestzhttp://blah/r httprraiser\)parentcallsappendrr
startswithrfindintr5rr2rO)r%fn_namerrkwdsresrs       r+rzMockHandler.handlesE  $t!<===>4
}
$
$K
(
(
(sD"b11CJ
'
'
'>***


w
'
'		0&,,s++A-../D
4yy



sD"b11C;$$VT!Wc4RHHH
w

,''///
sB%%
B21B2cdSrrVrs r+rzMockHandler.closerr-c,||_g|j_dSr)rr)r%rs  r+
add_parentzMockHandler.add_parentsr-cFt|dsdS|j|jkS)N
handler_orderT)hasattrr)r%others  r+__lt__zMockHandler.__lt__s*uo..	4!E$777r-N)
rTr#rUrrrrrrr"rVr-r+rrsuM&&&000.


88888r-rcg}d}|D]t}Gddt}||}|xj|z
c_|||dz}||||u|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.

    rceZdZdS)6add_ordered_mock_handlers.<locals>.MockHandlerSubclassNrTr#rUrVr-r+MockHandlerSubclassr%Dr-r'r)rrrradd_handler)opener	meth_spechandlersrmethsr'rGs       r+add_ordered_mock_handlersr.s&H
E							+			
 &&	5 	V	1Or-cVt}|D]}|||Sr)r	r))handler_instancesr*rGs   r+build_test_openerr1s8


F
1Mr-c eZdZdZdZdZdS)MockHTTPHandlercJ||_||_|dSr)rr^reset)r%rr^s   r+rzMockHTTPHandler.__init__s!	

r-c"d|_g|_dS)Nr)_countrequestsrs r+r5zMockHTTPHandler.resets


r-cddl}ddl}|j|||jdkru|jdz|_tjj|j	}|
|j}|j
d|t|j	||S||_|
d}t!dd|d|S)Nrrr

rrr)emailcopyr8rdeepcopyr7rclient	responsesrmessage_from_stringr^rrrrorget_full_url)r%ror;r<r rs      r+	http_openzMockHTTPHandler.http_opens
T]]3//000;!+/DK;(3D++DL99C;$$XZZD#??
?DH++J77CT3C4D4D4F4FGGGr-NrTr#rUrr5rBrVr-r+r3r3sF
HHHHHr-r3ceZdZddZdZdS)MockHTTPSHandlerrcxtjj||t	|_dS)N
debuglevel)r2rAbstractHTTPHandlerrrhttpconn)r%rHs  r+rzMockHTTPSHandler.__init__s/*33DZ3PPP%


r-c8||j|Sr)do_openrJr%ros  r+
https_openzMockHTTPSHandler.https_opens||DM3///r-N)r)rTr#rUrrNrVr-r+rErEs7((((00000r-rEc eZdZdZdZdZdS)MockHTTPHandlerCheckAuthc"||_d|_dSNF)rhas_auth_header)r%rs  r+rz!MockHTTPHandlerCheckAuth.__init__s	$r-cd|_dSrR)rSrs r+r5zMockHTTPHandlerCheckAuth.resets$r-c|drd|_tjj|j}t
|j|td|S)N
AuthorizationTr)	rfrSrr>r?rrrrA)r%ror s   r+rBz"MockHTTPHandlerCheckAuth.http_opensW>>/**	(#'D {$TY/DItXZZS=M=M=O=OPPPr-NrCrVr-r+rPrPsF%%%%%%QQQQQr-rPceZdZdZdZdS)MockPasswordManagerc>||_||_||_||_dSr)realmr_userrt)r%rZurir[rts     r+rz MockPasswordManager.add_password$s"
	 


r-c:||_||_|j|jfSr)target_realm
target_urlr[rt)r%rZauthuris   r+rz&MockPasswordManager.find_user_password*s !!y$-''r-N)rTr#rUrrrVr-r+rXrX#s2!!!(((((r-rXc8eZdZdZdZdZdZdZdZdZ	dS)	OpenerDirectorTestscGddt}|ttj|dS)NceZdZdS)<OpenerDirectorTests.test_add_non_handler.<locals>.NonHandlerNr&rVr-r+
NonHandlerre3r(r-rf)objectr4	TypeErrorr	r))r%rfs  r+test_add_non_handlerz(OpenerDirectorTests.test_add_non_handler2si								)(**6

	F	F	F	F	Fr-cddlm}t}ddgdgg}t|||t
jdD]!}|||j	|dz"dS)Nr)rO)rLr)
proxy_openr)redirect_requestr)doproxyredirectz://example.com/)
urllib.errorrOr	r.r)r2rUnknownHandlerr4r)r%rOor+schemes     r+test_badly_named_methodsz,OpenerDirectorTests.test_badly_named_methods8s	*)))))
')FG
01		"!Y///	

fn3355666/	J	JFh7H0HIIII	J	Jr-ct}gddgdgdgg}t||}td}||}|||d|ddf|ddfg}t||jD];\}}|\}	}
}}||	|
f||||f<dS)N)rBftp_openhttp_error_302rvrBrrrrrrB)r	r.rrr"zipr)
r%rrr+r,rorrexpectedgothandlerr rrs
             r+test_handledz OpenerDirectorTests.test_handledMs777
L
)*
)*		-Q	::+,,
FF3KK	
HQK(((1+{+hqk;-GH 00	+	+MHc(+%GT4gt_h777TC6****	+	+r-ct}g}dgdfdgdffD]T\}}Gddt}||}||_||||U|d||jdd|d||jdd|ddS)	NrxrrBrceZdZdS)COpenerDirectorTests.test_handler_order.<locals>.MockHandlerSubclassNr&rVr-r+r'rlsr-r'rrr)r	rrrr)rr"r)r%rrr,r-rr'rGs       r+test_handler_orderz&OpenerDirectorTests.test_handler_ordergs'C&Dc%J'2mQ%7%9		 E=




k


$#E**A+AOOOA
MM!	$%%%A444A44444r-ct}dgdgg}t||}td}|tjj|j|||j	|dd|fifgdS)N)rBrrxrrrrB)
r	r.rr4r2rrOrr"r)r%rrr+r,ros     r+
test_raisezOpenerDirectorTests.test_raiseys
#$
)*	-Q	::+,,&,/===HQKsfb#I"JKKKKKr-ct}dgddggddgg}t||}td}|||dd|ff|dd|tjd	d
iffg}t
||jD]G\}}|\}}	}
|||	f|dd||
|dHdS)N)rBz	error 302)http_error_400rrB))rwrhttp_error_303
http_errorrwrrrr.r)	r	r.rrr	ALWAYS_EQryrr")r%rrr+r,rorr{r|r}method_namers           r+test_http_errorz#OpenerDirectorTests.test_http_errors

'(
(+6


 	-Q	::+,,	s1+{SF31+/)3B79:!00	+	+MHc)1&G[$g{3S!W===T3q6****	+	+r-ct}ddgddgg}t||}td}|||ddf|ddf|ddf|ddfg}t	|jD]\}\}}}	}
|dkrc|||f|||t|	d||	dts|||f|||t|	d||	dt|	d!||	dtdS)	N)http_requestr
)
http_responserrrrrrrr)
r	r.rr	enumeraterr"rassertIsInstancer)r%rrr+r,rorrr}r rrs           r+test_processorsz#OpenerDirectorTests.test_processorss
/
1
3
/
1
3	-Q	::+,,	sa[.)HQK+H
a[/*Xa[/,JL/8.@.@	A	A*A*tT1uu  '4%(;;;  TA...%%d1gw7777  '4%(;;;  TA...%%d1gw7777&))$q'<@@@	A	Ar-N)
rTr#rUrirtr~rrrrrVr-r+rbrb0sFFFJJJ*+++4555$LLL+++.!A!A!A!A!Ar-rbc	|dn"#t$rtjdwxYwtj|}tjdkr|	dr
|dd}|S)Nzutf-8zpath is not encodable to utf8rz///r)
encodeUnicodeEncodeErrorunittestSkipTestr2rrrr r)r7urlpaths  r+sanepathname2urlrsAGAAA ?@@@An))$//G	w$7--e44!""+Ns7c>eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZej e!j"dkddZ#d Z$d!Z%d"Z&d#Z'd$Z(d%Z)d&Z*d'Z+d(Z,d)Z-d*Z.d+S),HandlerTestscvGddGfddtjj}ddl}d}||}t	|_dd|jd	d	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dd|jdd	d
ddgd
df	dddd	d	dddgd	df	dd|jd	d	dgddf	fD]\	}}}}}	}
}}}
t|}d|_|	|}|
|j||
|j|	|
|j
tj||
|j||
|j||
|jj||
|jj|
|}|
|d|
|
t/|dt1|dS)Nc eZdZdZdZdZdS)-HandlerTests.test_ftp.<locals>.MockFTPWrapperc||_dSrrr%rs  r+rz6HandlerTests.test_ftp.<locals>.MockFTPWrapper.__init__
 			r-cz||c|_|_tj|jt|jfSr)filenamefiletyperrrr)r%rrs   r+retrfilez6HandlerTests.test_ftp.<locals>.MockFTPWrapper.retrfiles1/7,
t}{49--s49~~==r-cdSrrVrs r+rz3HandlerTests.test_ftp.<locals>.MockFTPWrapper.closer-N)rTr#rUrrrrVr-r+MockFTPWrapperrsA
!
!
!
>
>
>




r-rc.eZdZdZejffd	ZdS)-HandlerTests.test_ftp.<locals>.NullFTPHandlerc||_dSrrrs  r+rz6HandlerTests.test_ftp.<locals>.NullFTPHandler.__init__rr-c||c|_|_||c|_|_||_|j|_|jSr)r[passwdrrdirsr
ftpwrapper)r%r[rrrrrrs       r+connect_ftpz9HandlerTests.test_ftp.<locals>.NullFTPHandler.connect_ftpsE)-v&	4;'+T$	49 	"0.";";&r-N)rTr#rUrrrr)rsr+NullFTPHandlerrsJ
!
!
!%+$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_PORTrrrvr"r[rrr
gethostbynamerrrrrrgetrr)r%rrrrGr_rrr[rtype_rrmimetyperorzr^rs                 @r+test_ftpzHandlerTests.test_ftps																
	'
	'
	'
	'
	'
	'
	'V^6
	'
	'
	'	


!N4  <<0
&/2r3U^Z
67
&/8RU^Z
6:
&/9b#U^Z
6<
&/;CU^Z
6+
"b"cU^R
'.
&/2r3
D
"!O!	H!	HJCtT65$((#,,CCK

3AQVT***QXv...QVV%9$%?%?@@@QVT***QVT***Q\2H===Q\2E:::ffhhGW[[88(CCCS)9!:;;SYYGGGGC!	H!	Hr-c	V	ddl}tj}t	x}|_tj}ttj
|}d}d|zd|zdtj
d|g}	tj
tj}n#tj$rd}YnwxYw|r|d|||D]}	t#|d}
		|
||
n#|
wxYw|t+|	}	|}|}
|}|n#|wxYwtj|}|j|jd	
}tj|n#tj|wxYw|||||
dd||
d
d||
d||||	d|zdddtj
ddtjd|dtjd|fD]}		t#|d}
	|
||
n#|
wxYw| tj!j"|jt+|	tj|#tj|wxYwtj}t	x}|_dD]\}	}t+|	}	|||#|j$|||j%dn/#tj!j"$r|&|YnwxYw||j%dk|dS)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%r;rGrrrrtowriteurls	localaddrr_r?rzrr^respurlstatsmodifiedrros                   r+	test_filezHandlerTests.test_filesN&&((!||#AH!"27??6#:#:;;# 7*'!!#1+>>>H
	,V-?-A-ABBII			III		>KKKGG<===	+	+CVT""A
"GGG$$$GGIIIIAGGIIIIKK--6688DffhhGhhjjGGGIIIIAGGIIII ;11%.1NN	&!!!!	&!!!!T7+++W^4lCCCW%56===W_5x@@@Wc****
$g--77#)#7#D#D#D#D#%9;;;;
8
8Y[[[[&&
"
	"	"C

"&&GGG$$$GGIIIIAGGIIII!!&,"7"#+ws||===	&!!!!	&!!!!N&&((!||#AH	5	5HC#,,C
2C   

aeS)))  51111	<(
&
&
&  %%%%%
&

SX.4444	5	5s~%B;;CCD/H/E%H+<F<'H<G8HH5
N+M0N+M;N++OQ)RRctj}tx}|_d}dD]w\}}t||ddi}d|_|ddt}|	||}|j
|j|j|j
|j|jdkdf|}	|	j|	j||
|||jd	||jd
||j|||jd||jgd||j|yd
|_|tjj|j	||tdd}|t:|j|dg|_dD]}td|}tAddid}||}
|7|!d|j"|!d|j"nB||j"dd||j"dd||j"dd	||j"dd|dd|dd|dd|dd||}
||j"dd||j"dd||j"dd||j"dddS)Nrr))GETN)POSTsblahFoor}Spameggsrrr{rr/))
Connectionr)rr}rrTbadpostr)r-Nrrr0z!application/x-www-form-urlencodedHostr|rb)#r2rrIrrrrrnrrLr<rrrrrr__contains__r"rrrrrrrr4rrOrhdo_request_rrassertNotInunredirected_hdrs)r%rGrrr_rrrorrzhdrsnewreqs           r+	test_httpzHandlerTests.test_httpksN..00!||#AH#>	.	.LFD#teU^44CCK''777 ??D		$$$A
FFAJJ
FFAHH
FAESL$&&6688DHHd''QXXZZ---TY
666TZ+++T[&111T]C000T-@@@
A
A
A
TY----$( &,/D#FFF+I66)Q]C888))	C	CD/66CS$B//A]]3''F|  !133HIII  1FGGGG  !67G!H#NNN  !6~!F@BBB
S26:MJJJS26:FCCC
''(8%@@@''>>>''666''666]]3''FS23CDeLLLS2>BEJJJS26:EBBBS26:EBBBB1	C	Cr-ctj}tx}|_tjdd}|j}||	tj|t|d5}td|i}||}|d}||d||ddddn#1swxYwYt|d5}td|d	d
i}||}|t'|dd
||dddddS#1swxYwYdS)Nzw+bF)modedeleterbrrTransfer-encodingchunkedrContent-Length)r2rrIrrtempfileNamedTemporaryFiler rr1runlinkrrrrlr"rjrfr)	r%rGrrfile_obj	file_pathr?rortes	         r+test_http_body_filez HandlerTests.test_http_body_filesJ
N..00!||#AH.E%HHHM		9---
)T
"
"	Ba/B77C]]3''F""#677BR+++V../?@@AAA	B	B	B	B	B	B	B	B	B	B	B	B	B	B	B)T
"
"	Ea/5Er4JKKC]]3''FS!2!23C!D!DEErJJJV../BCCDDD		E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	E	Es&A:DD"D6BG

GGctj}tx}|_tj}td|i}||}|	|
dd||dddi}td||}||}|	t|
dd||d|dS)Nrrrrrrr)r2rrIrrrBytesIOrrr"rlrjrfrr)r%rGrrrrorr^s       r+test_http_body_fileobjz#HandlerTests.test_http_body_fileobjs0
N..00!||#AH:<<+Xr::s##**+>??KKK**+;<<===#R(+Xw??s##V../?@@AA2FFF**+>??@@@r-c	xtj}tx}|_t
jddg}iddifD]}tj|tj	5}td|j|}||}|sS|
|dd|
|dd	n6|
t|dddddn#1swxYwYdS)
Nz-cpassrr)stdoutrrrrr)r2rrIrrsys
executable
subprocessPopenPIPErrrr"rlr)r%rGrrcmdr^procrors        r+test_http_body_pipez HandlerTests.test_http_body_pipes}
N..00!||#AH~tW-,b11
	)
	)G!#jo>>>	
)$3T['JJs++)$$V%6%67G%H%H$OOO$$V%6%67J%K%K%.0000$$S):):;K)L)L%M%M%')))	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)	
)
	)
	)s+B7D..D2	5D2	ctj}tx}|_d}iddifD]}td||}||}|sS||dd||dd|t|dddS)Nc3KdVdS)NsonerVrVr-r+
iterable_bodyz;HandlerTests.test_http_body_iterable.<locals>.iterable_bodysLLLLLr-rrrrrr)
r2rrIrrrrr"rlr)r%rGrrrr^rors       r+test_http_body_iterablez$HandlerTests.test_http_body_iterables
N..00!||#AH			,b11	O	OG/'JJC]]3''F
O  !2!23C!D!DdKKK  !2!23F!G!G!*,,,,  V%6%67G%H%H!I!I2NNNN	O	Or-cPtj}t|_|t
dd}||dd|	|
ddS)NrrrVrrr)r2rrIrrrrr"rlrjrf)r%rGros   r+test_http_body_empty_seqz%HandlerTests.test_http_body_empty_seqsN..00<<mmG$92>>??(;<<iHHH(899:::::r-cdtj}tx}|_tjdgd}iddifD]^}t
d||}||}|t|
dd_dS)Nr)rrrrrr)r2rrIrrarrayrrr"rrl)r%rGrriterable_arrayr^rors       r+test_http_body_arrayz!HandlerTests.test_http_body_arrays
N..00!||#AHS33,b11	J	JG/IIC]]3''FS!2!23C!D!DEEbIIII	J	Jr-ct}td}|||d||jddS)NrrGzhttps://www.example.com)r	rEr)rr"_debuglevel)r%rrrGs   r+test_http_handler_debuglevelz)HandlerTests.test_http_handler_debuglevels`***	

a	()))*****r-ctj}t|_d}gd}|D]}t||}||}||jdd|	dd||}||jdddS)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)
r2rrIrrrrr"r	set_proxy)r%rGrds_urlsds_urlds_req	np_ds_reqp_ds_reqs        r+test_http_doubleslashz"HandlerTests.test_http_doubleslash#s
N..00<<
	P
	PFVT**F

f--IY8@-PPP
-t444}}V,,HX7?OOOO
	P
	Pr-ctgd}td}|D]}||_t|}|||||jpd|j|t|j|jdS)N)zhttp://example.com?foo=bar#bazz)http://example.com?foo=bar&spam=eggs#bashrZrZr)rfull_urlrr"rAfragmentquery)r%rrzr_parseds     r+test_full_url_setterz!HandlerTests.test_full_url_setter>s



())	M	MCAJc]]FQ^^--s333
QZ-2v???Xann&6&677=v|LLLL	M	Mr-ctd}|`||j||j||jddS)Nhttp://www.example.comr)rr&rkr'r"r)r%rzs  r+test_full_url_deleterz"HandlerTests.test_full_url_deleterUs_,--
J!*%%%!*%%%R(((((r-ctj}t|_d}t|}||}||jd||j	dd}t|}||}||jd||j	ddS)Nzhttp://www.python.org?getspamwww.python.orgz	/?getspamhttp://www.python.orgr)
r2rrIrrrrr"rr)r%rG	weird_urlrorurl_without_paths      r+test_fixpath_in_weirdurlsz&HandlerTests.test_fixpath_in_weirdurls\s
N..00<<3	i  s##&6777+6662&''s##&6777"-----r-ctj}tx}|_d}t|}t
ddid|}|||}||||	t|dt
ddid|}|||}||||	t|dt
dd	id|}|||}||||	t|dt
d
did|}||||||j
d||j||d
difdS)
NrrrrrrAcceptedzPartial contentizBad gatewayr)r2rHTTPErrorProcessorrrrrrrrjr rkr"rr)r%rGrrr_rorznewrs       r+test_errorszHandlerTests.test_errorsosN--//!||#AH#clldBC00sA&&

aG,,---j"b#66sA&&

aG,,---/R==sA&&

aG,,---mRS99!//#q11222&)))#q#}b!ABBBBBr-ct}tj|}t	|_t
d}tddid}||}|	|j
||	|j
|||jd|
|j|||}|	|j||	|j||	||dS)Nrrrrrr{)rr2rHTTPCookieProcessorrrrrrrrr"origin_req_hostrjunverifiablerrr)r%cjrGrorzrr9s       r+test_cookieszHandlerTests.test_cookiess
__N..r22<<+,,dB++$$

bj#&&&

bj&))),m<<<)***sA&&

bi%%%

bgq!!!

ar-c>d}d}tj}tx}|_dD]@}dD]9}t|d|z}t
||}tj|_	|
dd|0|
dtt||
d	d
	||t|dtd|inE#tjj$r.||d
||YnwxYw||j|	||jdn/#t0$r"||jjYnwxYwd|jjD}	|d|	|d|	||jjdd|d	|jj|d	|jj;Bt
|}tj|_	|fd}
t
|d}d}tj|_			|
||d|dz}#tjj$r-||tjjjYnwxYwt
|d}d}tj|_			|
||d|z|dz}#tjj$r.||tjjjYdSwxYw)Nhttp://example.com/a.htmlzhttp://example.com/b.html)i-ri/34)Nz
blah
blah
z
http_error_%sNonsensezviking=withholdrrrBlahlocation)rCrDrc6g|]}|SrV)lower).0xs  r+
<listcomp>z.HandlerTests.test_redirect.<locals>.<listcomp>s <<<17799<<<r-zcontent-lengthzcontent-typec
n||tddtd|idS)NrrFrG)rwrr)rGror_s   r+roz,HandlerTests.test_redirect.<locals>.redirects@
S(**c6(*c):;;
=
=
=
=
=r-r{)r=rrrrzhttp://example.com/%d) r2rHTTPRedirectHandlerrrgetattrrrrrrhrQrrnrrr	HTTPErrorrPassertIsNotNoner"rorA
get_methodAttributeErrorrjrr^rrmax_repeatsmax_redirections)r%from_urlto_urlrGrrrrrror^rors            r+
test_redirectzHandlerTests.test_redirects.,N..00!||#AH,	B	BD,
B
B Od$:;;h--$<z+<===#NN#3ST^^DDD++FF;;;/F3

D&&
F';<<>>>>|-///MM$
333((...../  !3!3!5!5v>>>1$$QU%5%5%7%7????%111$$QUZ000001
=<aem<<<  !17;;;  999  z!:!2444  777  )@AAAA=
BBh4!'	=	=	=	=h
>>>4	T
"C!6777	
"|%	T	T	TUFN$F$RSSSSS	T
h
>>>4	R
"C!85!@AAA	
"|%	R	R	RU#^?P
R
R
R
R
R
R	RsH*D?EE3-F!!)G
G
K>LLM>NNc
Nd}gd}gd}d}tj}tx}|_t|}tj|_|D]T}|dz|z}	|	tj
j|j|tddtd|	iU|D]k}|dz|z}
||tdd	td|
i||j|
ldS)
NrB)rhttpsr)fileimapldapzexample.com/b.htmlz://rzSecurity LoopholerGThat's fine)r2rrNrrrrrrr4rrPrwrrr"rorA)r%rV
valid_schemesinvalid_schemesschemeless_urlrGrrrorsinvalid_url	valid_urls           r+test_invalid_redirectz"HandlerTests.test_invalid_redirectsD....
000-N..00!||#AHh4%	<	<F 5.>9Kfl4a6FS*=[ 9::
<
<
<
<$	>	>F7I
S(**c=Z344
6
6
6QU//119====		>	>r-c
d}d}tj}tx}|_t|}tj|_tj	
||}||tddtd|i||j|dS)NrBz/b.htmlrr^rG)r2rrNrrrrrrrurljoinrwrrr"rorA)r%rVrelative_urlrGrrrorcs       r+test_relative_redirectz#HandlerTests.test_relative_redirects. N..00!||#AHh4L((,??		hjj#}Y/00	2	2	2++--y99999r-cddlm}ddlm}|}||ddt	dd}t
j}t
j}t
j	|}t||||}|d||j
ddS)	Nr)	CookieJar)interact_netscapezhttp://www.example.com/z	spam=eggsrz%Location: http://www.cracker.com/

Cookie)http.cookiejarrjtest.test_http_cookiejarrkr3r2rHTTPDefaultErrorHandlerrNr<r1rrjrorf)	r%rjrkr?hhhdehhrhcprrs	         r+test_cookie_redirectz!HandlerTests.test_cookie_redirects,,,,,,>>>>>>
Y[["7EEE
S"M
N
N~5577n0022
^
/
/
3
3b$R00	()))**84455555r-chd}tdd|z}tj}tj}t|||}|d}|||	dS)Nz(http://www.example.com/index.html#OK

rz
Location: r,)
r3r2rrorNr1rr"rstrip)r%redirected_urlrprqrrrrrs       r+test_redirect_fragmentz#HandlerTests.test_redirect_fragmentsG
S,"?
@
@~5577n0022b$,,
VV,
-
-n&:&:&<&<=====r-ctjjtjjd}tj|tj_ttjdtdfd}|tjj_tjd}|
ddS)Ns(HTTP/1.1 302 Found
Location: ?query

HTTPConnection)z/pathz/path?queryc|tj|||g|Ri|d|j_dS)NsHTTP/1.1 200 OK

Hello!)r"nextrrfakedata)connrr_poskw
real_classr%rs     r+rz3HandlerTests.test_redirect_no_path.<locals>.request)sVS$t**---JtVS=3==="===&FDN###r-zhttp://python.org/pathzhttp://python.org/path?query)r1r2rr3rr>rzrfakehttpriterr6r"r)r%	response1rrrrs`   @@r+test_redirect_no_pathz"HandlerTests.test_redirect_no_paths	
1222[/
E	%0%9)%D%D".>
KKK,--	G	G	G	G	G	G	G
.5"*
^
#
#$<
=
=&DEEEEEr-cGddtjj}|}tj|}d}|D]\}}|t|5t
jd|zdz|_|	d}d|zdz}|j
}	||	|t|	dddn#1swxYwYdS)	NceZdZdZdS)4HandlerTests.test_redirect_encoding.<locals>.Handlerc||j|}|jj|_t	jd|_|S)Ns)HTTP/1.1 200 OK
Content-Length: 3

123)rL
connectionbuflast_bufrr)r%roresults   r+rBz>HandlerTests.test_redirect_encoding.<locals>.Handler.http_open6sCdos;; $ 3
"-"6##
r-N)rTr#rUrBrVr-r+Handlerr5s#









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%rr}r*rIrGrrr{rs
          r+test_redirect_encodingz#HandlerTests.test_redirect_encoding2s|					fn0			')),,W55
#(
	M
	MXvd8nn--	
M	
M%0%9"$,-0&&"
";;'<=="V+d2!* 2 28 < <d7mmLLL	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M	
M
	M
	Ms2A:C88C<	?C<	cd}t|t|fD]}t}tj|}||dgg}t
||}td}||j	d|
|||j	|||ddfgd	|jDdS)
Nproxy.example.com:3128r)HTTP)rBrzhttp://acme.example.com/zacme.example.comrrBc"g|]}|dd
SrrrVrJtups  r+rLz+HandlerTests.test_proxy.<locals>.<listcomp>es :::3c!A#h:::r-)dictr	r2rProxyHandlerr)r.rr"rrr)r%r'rxrrphr+r,ros        r+
test_proxyzHandlerTests.test_proxyUs$1t|||+	<	<A  A,,Q//B
MM"12I1I>>H455CSX'9:::
FF3KKKSXq)))x{K89::!':::
<
<
<
<	<	<r-cFdtjd<t}tjt
d}||td}|	|j
d|||	|j
dtd}|	|j
d|||	|j
dtjd=dS)	Nz
python.orgno_proxyproxy.example.comrzhttp://www.perl.org/www.perl.orgr0r/renvironr	r2rrrr)rr"rrr%rrrros    r+test_proxy_no_proxyz HandlerTests.test_proxy_no_proxygs!-
:
^
(
(3F)G)G)G
H
H	

b,-->222	s#6777-..#3444	s#3444Jz"""r-cdtjd<t}tjt
d}||td}|	|j
d|||	|j
dtjd=dS)N*rrrr0r/rrs    r+test_proxy_no_proxy_allz$HandlerTests.test_proxy_no_proxy_allvs!$
:
^
(
(3F)G)G)G
H
H	

b-..#3444	s#3444Jz"""r-ct}tjt	d}||dgg}t
||}td}||j	d|
|||j	d||ddfgd|jDdS)	NrrZ)rNrhttps://www.example.com/www.example.comrrNc"g|]}|dd
SrrVrs  r+rLz1HandlerTests.test_proxy_https.<locals>.<listcomp>s 666s#ac(666r-)r	r2rrrr)r.rr"rrr)r%rrrr+r,ros      r+test_proxy_httpszHandlerTests.test_proxy_httpss
^
(
(4L)M)M)M
N
N	

b
./
	-Q	::011#4555	s#;<<<8A;5666ag666	8	8	8	8	8r-c2t}tjt	d}||t
}||td}|dd|dd|	|j
d||j|
||d	|jj|d
|jj||j|	|j
d|	|dddS)NrrrProxy-AuthorizationFooBar
User-AgentGrailr)rr)rrProxy-authorization)r	r2rrrr)rErrhr"rrkrrrrJrrPrQrl)r%rrr
https_handlerros     r+$test_proxy_https_proxy_authorizationz1HandlerTests.test_proxy_https_proxy_authorizationst
^
(
(4L)M)M)M
N
N	

b(**
	

m$$$011,h777|W---#4555#*+++	s	
:&/;	=	=	=

-#,8	:	:	:S-...#;<<<(=>>IIIIIr-darwinzonly relevant for OSXcdgdd}dD])}|t||d|z*dD])}|t||d|z*dgd}|td	|dd
dgd}d}|t||d|zd
}|t||d|zdS)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_bypasssn$&&&

!	G	GDOO8vFF>E
G
G
G
G	I	ID9$GG@4G
I
I
I
I%);;4VVDDEEE$)+;=

4T6BB:TA	C	C	C5dFCC;dB	D	D	D	D	Dr-c|||5t}t}tj|}d|dz}td|}|||||	||d|||ddddddS#1swxYwYdS)N)rZr^z
r:rV!http://acme.example.com/protected)
rr	rXr2rr
joinr3r)_test_basic_auth)r%r^rZr*password_managerauth_handlerrhttp_handlers        r+check_basic_authzHandlerTests.check_basic_auths9
\\w\
7
7	G	G#%%F244!>>>?OPPL;;w''*4D*355L|,,,|,,,!!&,"'7G"E"E
G
G
G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	GsB*CCCc
d}d}d|d}d|d}d}d|d}d|dd|dd|d	|d
||d
||d
||d
||d
|fD]}d|g}|||tjdtf5d
|g}|||dddn#1swxYwY||g||g||gfD]$}	d|	D}|||%dS)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, WWW-Authenticate: zBasic Auth Realm was unquotedzWWW-Authenticate: Basic realm=cg|]}d|S)rrV)rJ	challenges  r+rLz0HandlerTests.test_basic_auth.<locals>.<listcomp>s0444$8I77444r-)rrcheck_warningsUserWarning)
r%rZrealm2basicbasic2other_no_realmdigest	realm_strr^
challengess
          r+test_basic_authzHandlerTests.test_basic_auths$%((((*****?6???
%E$$$$E$$$
6E555    ((((((((        
	2	2I8I778G!!'51111
+-L%0-233	2	2???@G!!'5111	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2V
V
UO
	2	2J
44(2444G!!'51111	2	2sB++B/2B/c
t}tjt	d}||t
}tj|}d}tdd|z}|||||	||d|||dddS)Nrr
ACME Networksiz(Proxy-Authenticate: Basic realm="%s"

rz&http://acme.example.com:3128/protected)
r	r2rrrr)rXProxyBasicAuthHandlerr3r)r%r*rrrrZrs       r+test_proxy_basic_authz"HandlerTests.test_proxy_basic_auths!!
^
(
(3K)L)L)L
M
M2.00~;;<LMM&?%GII<(((<(((fl4I#\3CF6	 	 	 	 	 r-c
Gddt}Gddtjj}Gddtjj}|}t}||}||}d}t
dd	|z}	||||||	|||d
||	|dd|	|j
dd
gdzdS)NceZdZdZdZdS)QHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirectorc<tj|g|_dSr)r	rrecordedrs r+rzZHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.__init__ s'--- "


r-c:|j|dSr)rr)r%rs  r+recordzXHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.record$s
$$T*****r-N)rTr#rUrrrVr-r+RecordingOpenerDirectorrs2
#
#
#
+
+
+
+
+r-rceZdZdZdS)OHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandlercx|jdtjjj|g|Ri|dS)Nr)rrr2rHTTPDigestAuthHandlerhttp_error_401r%rrs   r+rz^HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandler.http_error_401(sa""8,,,4CDL>BLLLFJLLLLLr-NrTr#rUrrVr-r+TestDigestAuthHandlerr's(
L
L
L
L
Lr-rceZdZdZdS)NHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandlercx|jdtjjj|g|Ri|dS)Nr)rrr2rr
rrs   r+rz]HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandler.http_error_401.sa""7+++3B4K=AKKKEIKKKKKr-NrrVr-r+TestBasicAuthHandlerr-s(
K
K
K
K
Kr-rrr&WWW-Authenticate: Basic realm="%s"

rVrrrr)r	r2rrr
rXr3r)rr"r)
r%rrrr*rdigest_handler
basic_handlerrZrs
          r+#test_basic_and_digest_auth_handlersz0HandlerTests.test_basic_and_digest_auth_handlerss	+	+	+	+	+n	+	+	+	L	L	L	L	LFN$H	L	L	L	K	K	K	K	K6>#F	K	K	K)(**.00../?@@,,-=>>
&=EGG=)))>***<(((	
fm_#\3CAA	 	 	 	
8W*=a*?@@@@@r-ct}tjd}t	dd}|||||t|jddS)NrzWWW-Authenticate: Kerberos

r,)	r	r2rrr3r)r4r5r)r%r*digest_auth_handlerrs    r+$test_unsupported_auth_digest_handlerz1HandlerTests.test_unsupported_auth_digest_handlerHs!!$nBB4HH&577.///<(((*fk3KLLLLLr-ct}tjd}t	dd}|||||t|jddS)NrzWWW-Authenticate: NTLM

r,)	r	r2rr
r3r)r4r5r)r%r*basic_auth_handlerrs    r+#test_unsupported_auth_basic_handlerz0HandlerTests.test_unsupported_auth_basic_handlerRs!!#^@@FF&133-...<(((*fk3KLLLLLr-c	ddl}	d\}
}||||
||||j|||j||
|j|||j||||j|||j	||t|jd||jd
|t|
d|d}d|	|z}
||jd||
||jdj||
dx|_|_||||t|jd||jd
|dS)Nrwilecoyoter:asciizBasic r)base64rr"rZr_r[rtrr^r_rr8rjrfbytesencodebytesrvdecoderlrr5)r%r*rauth_headerrZrrrequest_url
protected_urlrr[rtuserpassauth_hdr_values              r+rzHandlerTests._test_basic_auth\sf	


)h	!!%dHEEE 0 6777&6&:;;;/4555#3#<===K   	
)6>>>)4mDDD	
\233Q777.q1<<[IIJJJDDD((3W=="x((..007799:.q1<<[II'	)	)	).q1CKP'	)	)	)=A@ 0 9K   \233Q777.q1<<[IIJJJJJr-cjd\}}d}td}t}t|}|d|||d||||||dz|||dzt}|||||	|||j
dS)NrrrT)is_authenticatedz/nestedplain)rPrr
rrerrjr	r)rrS)r%r[rtrrpwd_managerauth_prior_handlerr*s        r+test_basic_prior_auth_auto_sendz,HandlerTests.test_basic_prior_auth_auto_sends4*h9/442441+>>''+tX	(	F	F	F	
44[AABBB44[95LMMNNN55kG6KLLMMM!!-...<(((K   	
455555r-c
d\}}d}d}t}t|}|||||||}||t}||tdddz}	||	||||}|	|td}	||	jt}||||	|||	|	jdS)NrrACMErrr)rr
rrrjr	r)r3rrerPrS)
r%r[rtrrZrris_authr*rs
          r+.test_basic_prior_auth_send_after_first_successz;HandlerTests.test_basic_prior_auth_send_after_first_successs*h92441+>>''{D(KKK..{;;!!!!!-...&=DFF<(((K   ..{;;   /445666!!-...<(((	K   	
455555r-cdD]\}}d|}tj||z}tj}td}d|_|	||5}|
dddn#1swxYwY||jj
d|dS)z=Test the connection is cleaned up when the response is closed))zConnection: closedata)zTransfer-Encoding: chunkeds4
data
0

)zContent-Length: 4rzHTTP/1.1 200 OK
{}


http://dummy/NzConnection not closed with {!r})formatrrrr2rrIrrrLr<refakesockclosed)r%transferrheaderr~r}roresps        r+test_http_closedzHandlerTests.test_http_closeds)!

	D
	DXt
5;;HEEF'

$(>??Dn88::G/**CCKs++
t		














OODM0188BB
D
D
D
D
	D
	DsB11B5	8B5	cztjd}tj}td}d|_|tj	j
5|||dddn#1swxYwY||j
jddS)z;Test the connection is cleaned up after an invalid responser-rNzConnection not closed)rrr2rrIrrr4rr>
BadStatusLinerLrerr)r%r~r}ros    r+test_invalid_closedz HandlerTests.test_invalid_closeds#C((.4466o&&


t{8
9
9	'	'OOD#&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'
,.EFFFFFs-BBBN)/rTr#rUrrrrrrrrrrr$r*r-r3r:r@rXrdrhrtrxrrrrrrrr
skipUnlessrplatformrrrrrrrrrrr"r%rVr-r+rrs>H>H>H@Z5Z5Z5x@C@C@CDEEE2.))),OOO(;;;JJJ+++PPP6MMM.)))...&CCC2"HRHRHRT>>>,:::
6
6
6>>>FFF(!M!M!MF<<<$
#
#
#	#	#	#888 JJJ.X13JKKDDLKDBGGG+2+2+2Z   "0A0A0AdMMMMMM#K#K#KJ6666&6&6&6PDDD"GGGGGr-rc2eZdZdZdZdZdZdZdZdS)	MiscTestscn|tfd|jDdS)Nc3.K|]}|jkVdSr)r)rJrG
handler_classs  r+	<genexpr>z/MiscTests.opener_has_handler.<locals>.<genexpr>s>66 !K=8666666r-)reanyr,)r%r*r,s  `r+opener_has_handlerzMiscTests.opener_has_handlersW6666%+_66666	7	7	7	7	7r-c&Gddtjj}Gddtjj}Gddtjj}tjj}|||}|||||||||}||||||||}||||}||tjj|tjj}||tjj|tj}||tjjGddtjj}|||}||||||dS)	NceZdZdS)2MiscTests.test_build_opener.<locals>.MyHTTPHandlerNr&rVr-r+
MyHTTPHandlerr2r(r-r3ceZdZdZdS)/MiscTests.test_build_opener.<locals>.FooHandlercdSrrVrs r+foo_openz8MiscTests.test_build_opener.<locals>.FooHandler.foo_openrr-N)rTr#rUr7rVr-r+
FooHandlerr5#




r-r8ceZdZdZdS)/MiscTests.test_build_opener.<locals>.BarHandlercdSrrVrs r+bar_openz8MiscTests.test_build_opener.<locals>.BarHandler.bar_openrr-N)rTr#rUr=rVr-r+
BarHandlerr;r9r-r>ceZdZdS)7MiscTests.test_build_opener.<locals>.MyOtherHTTPHandlerNr&rVr-r+MyOtherHTTPHandlerr@r(r-rA)r2rrBaseHandlerrr/)r%r3r8r>rrrrAs       r+test_build_openerzMiscTests.test_build_openersI					FN6								3								3			~2LZ00:...:...
LZZ\\22:...:...
L''=111
LNN6>#=>>>L3446>#=>>>L3355666>#=>>>					!;			
L(:;;=111#566666r-c.d}dx}x}}d}tj|||||}|t	|d||jd|t	|d||jdd|jd|j	}|t||d|jd|j	d	}|t||dS)
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 >)r2rrPrer r"rNr^rrrQr)r%rr_rrrrRexpected_errmsgs        r+test_HTTPError_interfacez"MiscTests.test_HTTPError_interfaces
'dR#l$$S$T2>>X..///%=>>>Y//000&:;;;;14377CS?333325(((CGGGDcO44444r-ctjddddd}|t	|ddd||jtdS)Nr_izMETHOD NOT ALLOWED	__notes__rV)	r2rrPr"rOrrr<r)r%rKs  r+
test_gh_98778zMiscTests.test_gh_98778$shL""5#/CT4PPK44b999adiikk511111r-cgd}|D](\}}|t||)|ttdfdS)N)r)NNNrr)NNNrrLrM)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.comrN)z&http://user/name:password@localhost:22)r	user/namertlocalhost:22)z&http://username:pass/word@localhost:22)rusername	pass/wordrP)z'http://user/name:pass/word@localhost:22)rrOrRrPzfile:/ftp.example.com)r"rr4r5)r%parse_proxy_test_casestcr{s    r+test_parse_proxyzMiscTests.test_parse_proxy)sm$"
$"
$"
N3	9	9LB\"--x8888*l4KLLMMMMr-ct}|t5}|ddddn#1swxYwY|t|jddS)Ninvalidz5Unsupported digest authentication algorithm 'invalid')rr4r5get_algorithm_implsr"rQ	exception)r%r}excs   r+test_unsupported_algorithmz$MiscTests.test_unsupported_algorithmVs+--


z
*
*	3c''	222	3	3	3	3	3	3	3	3	3	3	3	3	3	3	3
C	
	
	
	
	
sAAAN)	rTr#rUr/rCrGrJrUr[rVr-r+r)r)ss777*7*7*7X555$222
+N+N+NZ




r-r)c~eZdZGddeZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdS)RequestTestsceZdZdZdS)RequestTests.PutRequestPUTN)rTr#rUrrVr-r+
PutRequestr_asr-ractd|_tddddi|_tdd|_|d|_|dd|_dS)	Nhttp://www.python.org/~jeremy/rzX-Testrr]HEAD)rr)rrpostheadraput
force_postrs r+setUpzRequestTests.setUpds;<<<"%-v$6888	<VLLL	??#CDD//*J*r-c|d|j|d|j|d|j|d|j|d|jdS)Nrrrdr`)r"rerRrrfrgrhrs r+test_methodzRequestTests.test_methodns!5!5!7!7888 3 3 5 5666!5!5!7!7888 3 3 5 5666!;!;!=!=>>>>>r-cN||jj|d|jd|j_||jj|d|jdS)Nrrr)rjrrr"rRrers r+	test_datazRequestTests.test_dataus''' 3 3 5 5666

&&&!4!4!6!677777r-c |d|jj|jdd|d|jjdd|j_|d|jjdS)Nr*r)rrrrnr"rrs r+.test_setting_data_should_remove_content_lengthz;RequestTests.test_setting_data_should_remove_content_lengths)48+EFFF(()92>>>TX78HIJJJ
)48+EFFFFFr-c.|d|jjd|j_|jdd|d|jjd|j`|d|jjdS)Nrr|r)rrrrrnr"rs r+/test_deleting_data_should_remove_content_lengthz<RequestTests.test_deleting_data_should_remove_content_lengths)48+EFFF
(()91===DH67GHIIIHM)48+EFFFFFr-c`|d|jdS)Nrc)r"rrArs r+test_get_full_urlzRequestTests.test_get_full_urls89..00	2	2	2	2	2r-c|d|jjtd}|d|jdS)Nz	/~jeremy/zhttp://www.python.org/r/)r"rrrrMs  r+
test_selectorzRequestTests.test_selectorsIdh&7888.//cl+++++r-cF|d|jjdS)Nr)r"rrrs r+
test_get_typezRequestTests.test_get_types"/////r-cF|d|jjdS)Nr/)r"rrrs r+
test_get_hostzRequestTests.test_get_hosts#)48=99999r-cZtd}|d|jdS)Nzhttp://www.%70ython.org/r/rr"rrMs  r+test_get_host_unquotez"RequestTests.test_get_host_unquotes/011)3844444r-cl||j|jdd||j|d|jj|d|jjdS)Nrrr/)rjr	has_proxyrrer"r=rrs r+rzRequestTests.test_proxys++--...>6222**,,---)48+CDDD77777r-cZtd}|d|jdS)Nz<URL:http://www.python.org>r/r|rMs  r+test_wrapped_urlzRequestTests.test_wrapped_urls/344)3844444r-c td}|d|jtd}|d|jd}t|}|||dS)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"rrA)r%ror_s   r+test_url_fragmentzRequestTests.test_url_fragmentsEFFs|444788cl+++?cll))++S11111r-cgd}|D]>}t|}|||j?dS)N)zhttp://docs.python.orgrr)rr"rAr&)r%rr_ros    r+test_url_fullurl_get_full_urlz*RequestTests.test_url_fullurl_get_full_urlscAAA	?	?C#,,CS--//>>>>	?	?r-N)rTr#rUrrarirkrmrprrrtrvrxrzr}rrrrrVr-r+r]r]`sW???888GGGGGG222,,,
000:::555888555	2	2	2?????r-r]__main__)=rrrtest.supportrrrrrrrrrrrurllib.requestr2rr	r
rrr
rurllib.parserrphttp.clientrrequires_working_socketTestCaserrXrrrrrrrrIOBaserrrr.r1rrBr3rIrErPrXrbrrr)r]rTmainrVr-r+<module>rs+""""""&&&&&&((((((								







777777777777777777"!!!!!t,,,,1,1,1,1,1,8$1,1,1,hx'x'x'x'x'x(x'x'x'v,,,,,,,,







#####$###
					2;			33333333????????ry$*
*
*
*
*
*
*
*
Z3838383838383838lDHHHHHfn0HHH8	0	0	0	0	0v~9	0	0	0QQQQQv~9QQQ&
(
(
(
(
(
(
(
(NANANANANA(+NANANAb			PGPGPGPGPG8$PGPGPGf }
}
}
}
}
!}
}
}
@^?^?^?^?^?8$^?^?^?BzHMOOOOOr-