python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_httplib.cpython-312.opt-2.pyc

ΑexddlZddlZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlm
Z
ejZddlmZddlmZddlmZej(dej*j-eZej*j3ed	Zej*j3ed
Zej*j3edZdZd
ZdZdZ dezdzZ!dZ"dZ#ejHZ$GddZ%Gdde%Z&GddejNZ(GddejRZ*GddeZ+GddeZ,Gdd eZ-Gd!d"eZ.Gd#d$eZ/Gd%d&e/Z0Gd'd(Z1Gd)d*eZ2Gd+d,eZ3Gd-d.eZ4Gd/d0eZ5Gd1d2eZ6Gd3d4eZ7Gd5d6eZ8Gd7d8eZ9e:d9k(rejvd:;yy)<N)client
HTTPStatus)mock)support)	os_helper)
socket_helperT)modulezkeycert.pemzkeycert2.pemzselfsigned_pythontestdotnet.pemz{HTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello worl
3
d! 
8
and now 
22
for something completely different
s7hello world! and now for something completely differentz;foo=barz0
0
zX-Dummy: foo
X-Dumm2: bar
cNeZdZejddfdZdZddZdZdZ	dZ
y)	
FakeSocketNct|tr|jd}||_||_d|_d|_d|_||_||_	y)NasciirF)

isinstancestrencodetext	fileclassdata
sendall_callsfile_closedhostport)selfrrrrs     E/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_httplib.py__init__zFakeSocket.__init__5sMdC ;;w'D	"	 		rcX|xjdz
c_|xj|z
c_yN)rrrrs  rsendallzFakeSocket.sendall@s!a		T	rc|dk7r|dk7rtj|j|j|_|j
|j_|jS)Nrrb)rUnimplementedFileModerrfile
file_closeclose)rmodebufsizes   rmakefilezFakeSocket.makefileDsK3;44<..00NN499-	//		yyrcd|_y)NT)rrs rr(zFakeSocket.file_closeLs
rcyNr.s rr)zFakeSocket.closeOrcyr0r1)rleveloptnamevalues    r
setsockoptzFakeSocket.setsockoptRr2rr0)__name__
__module____qualname__ioBytesIOrr"r,r(r)r7r1rrr
r
4s+')zz4	 

rr
ceZdZdZdZdZy)EPipeSocketc>tj||||_yr0)r
rpipe_trigger)rrr@s   rrzEPipeSocket.__init__WsD$'(rc~|j|vrttjd|xj|z
c_y)Ngotcha)r@OSErrorerrnoEPIPErr!s  rr"zEPipeSocket.sendall\s/$%++x00		T	rcyr0r1r.s rr)zEPipeSocket.closear2rN)r8r9r:rr"r)r1rrr>r>Us)


rr>ceZdZ	ddZddZy)NoEOFBytesIOcftjj||}|dk(rtd|SNrzcaller tried to read past EOF)r;r<readAssertionError)rnrs   rrKzNoEOFBytesIO.readjs.zztQ'3; !@AArNcftjj||}|dk(rtd|SrJ)r;r<readlinerL)rlengthrs   rrOzNoEOFBytesIO.readlineps0zz""403; !@AArr0)r8r9r:rKrOr1rrrHrHds
rrHc0eZdZ	fdZfdZdZxZS)FakeSocketHTTPConnectioncbd|_t|	d||_|j|_y)Nrexample.com)connectionssuperrfake_socket_argscreate_connection_create_connection)rargs	__class__s  rrz!FakeSocketHTTPConnection.__init__ys.
' $"&"8"8rcL	|xjdz
c_t|	Sr)rWrXconnect)rr]s rr_z FakeSocketHTTPConnection.connects$<Aw  rc&t|jSr0)r
rY)rposkws   rrZz*FakeSocketHTTPConnection.create_connections40011r)r8r9r:rr_rZ
__classcell__)r]s@rrTrTvsJ9!
2rrTc<eZdZdZdZdZdZdZdZdZ	dZ
y	)
HeaderTestscpGddt}dD]}dD]}tjd}td|_||_d}i}|rt
t|||<|jdd	|||j|j
j|jd
y)NceZdZdZdZy);HeaderTests.test_auto_headers.<locals>.HeaderCountingBufferci|_yr0)countr.s rrzDHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.__init__s	
rc|jd}t|dkDrU|djdj}|jj|d|j|xxdz
cc<tj||y)N:r rr)splitlendecodelowerrj
setdefaultlistappend)ritemkvlcKeys    rrszBHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.appendslZZ%r7Q;qELL1779EJJ))%3JJu%*%D$'rNr8r9r:rrsr1rrHeaderCountingBufferrhs
 
(rrx)TF)Content-lengthHostzAccept-encodingrVblahblahblahspamspamspamPOST/r )rrrHTTPConnectionr
sock_bufferrrnrequestassertEqualrjrp)rrxexplicit_headerheaderconnbodyheaderss       rtest_auto_headerszHeaderTests.test_auto_headerss
	(4
	( +	HOE

H,,];&~6	35%"&)#d)nGFOVS$8  !3!3FLLN!CQG

H	HrcGddt}d}d}tj||D]\}}tjd}td|_||_|j|d||j|jjddj|d	}|D]|}tjd}td|_||_|j|dd|j|jjdd
j|~|D]|}tjd}td|_||_|j|dd|j|jjddj|~tj||D]|}tjd}td|_||_|j|dd|j|jjd
dj|~y)NceZdZdZdZy)?HeaderTests.test_content_length_0.<locals>.ContentLengthCheckerc<tj|d|_yr0)rrrcontent_lengthr.s rrzHHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.__init__s

d#&*#rc|jdd}t|dkDr.|djdk(r|dj|_t
j
||y)Nrlr rscontent-length)rmrnrpstriprrrrs)rrtrus   rrszFHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.appendsOZZa(r7Q;2a5;;=4E#E*,Q%++-D'D$'rNrwr1rrContentLengthCheckerrs
+
(rr)N)PUTr}PATCHrVr~0z%Header Content-Length incorrect on {})GETCONNECTDELETEHEADOPTIONSTRACEz.Header Content-Length set for empty body on {}r 1)
rr	itertoolsproductrrr
rrrrrformatchain)rrbodiesmethods_with_bodymethodrrmethods_without_bodys        rtest_content_length_0z!HeaderTests.test_content_length_0s	(4	(4%--.?H	LFD((7D"4(DI/1DLLLd+++T7>>vF
	 
+	F((7D"4(DI/1DLLLd+++T@GGO
	+	F((7D"4(DI/1DLLLb)++T7>>vF
	 oo&:<MN	F((7D"4(DI/1DLLLc*++T7>>vF
	rc|tjd}td|_|j	dd|jdd|j
d|j|jdd|j
d	|j|jd
d|j
d|j|jd
d|j
d|j|jddd|j
d|j|jdd|j
d|j|jdd|j
d|j|jdd|j
d|j|jdd|j
d|j|jd d!|j
d"|j|jd#d$|j
d%|j|jd&d$|j
d'|j|jd(d$|j
d)|j|jd*d$|j
d+|jy),NrVrr~ry*sContent-length: 42Fooz bar s
Foo:  bar Barz	baz	s
Bar: 	baz	
AuthorizationzBearer mytokensAuthorization: Bearer mytoken
IterHeaderIterAIterBsIterHeader: IterA
	IterBLatinHeadersLatinHeader: 
Utf8HeadersÀsUtf8Header: Àz
C1-Controls	nextlinesC1-Control: nextlinezEmbedded-Fold-Spacezis
 alloweds!Embedded-Fold-Space: is
 allowedzEmbedded-Fold-Tabzis
	allowedsEmbedded-Fold-Tab: is
	allowedz	Key Spacer6sKey Space: valuez	KeySpace sKeySpace : valuesNonbreakSpacesNonbreakSpace: valuesNonbreakSpacesNonbreakSpace: value)rrr
r
putrequest	putheaderassertInrrrs  rtest_putheaderzHeaderTests.test_putheaders$$]3t$	c"',

+T\\:ug&

mT\\2ui(

ot||4(89

6E|Wg6

5t||D}g.

*DLL9|[1

-t||<|_5

14<<@,.>?

<dllK*,=>

;T\\J{G,

)4<<8{G,

)4<<8+W5

14<<@+W5

14<<@rcd}tjd}td}||_|j	dd|j|jj|d}tjd}td}||_|j	dd|j|jj|y)NsCGET /foo HTTP/1.1
Host: [2001::]:81
Accept-Encoding: identity

z[2001::]:81rr/foosEGET /foo HTTP/1.1
Host: [2001:102A::]
Accept-Encoding: identity

z
[2001:102A::])rrr
rr
assertTruer
startswithrexpectedrrs    rtest_ipv6host_headerz HeaderTests.test_ipv6host_header	s8$$]3"~	UF#		,,X678$$_5"~	UF#		,,X67rcd}t|}tj|}|j|j	|jdd|j	|jddy)Nz4HTTP/1.1 200 OK
First: val
: nval
Second: val

FirstvalSecond)r
rHTTPResponsebeginr	getheaderrrrresps    r!test_malformed_headers_coped_withz-HeaderTests.test_malformed_headers_coped_withs\O$""4(

0%8159rc	dttddzdzttddzdz}t|}tj|}|j|j
|jdd	|j
|jdd	|j
|jd
d|j
|jd
ddjtttdd}|j
|jd
||j
|jd
||j|jd|jd|j|jd|jdfD]T}|j|jd|jd||j|j!dVy)Ns0HTTP/1.1 200 OK
!#$%&'*+-.^_`|~: value
VCHAR: !s
obs-text: sM
obs-fold: text
 folded with space
	folded with tab
Content-Length: 0

Content-Lengthr
z!#$%&'*+-.^_`|~r6rVCHARzobs-textzobs-foldrz folded with spacezfolded with tab)bytesranger
rrrrrmsgjoinmapchrassertIsNotNonerrrendswith)rrrrvcharfoldeds      rtest_parse_all_octetsz!HeaderTests.test_parse_all_octets&s
uT845
69
"%h"78
9<
	
$""4(

(893?"23S9(9:GD"34g>CtX!6780%8'*E2T^^J78

j$((+~~j1488J3GH	@FOOF--f56MM.7OOFOO,=>?	@rcTtjd}td|_|j	ddd}|D]R\}}|j||f5|j
td5|j||ddddddTy#1swYxYw#1swYkxYw)NrVrrr~))s
Invalid
Name
ValidValue)sInvalid
Namer)sInvalid
Namer)s

InvalidNamer)s
InvalidNamer)s
InvalidNamer)s InvalidNamer)s	InvalidNamer)sInvalid:Namer)s:InvalidNamer)	ValidNamesInvalid
Value)rs
Invalid
Value)rs
Invalid
Value)rsInvalidValue
)rs
InvalidValue
)rs
InvalidValue
zInvalid header)	rrr
rrsubTestassertRaisesRegex
ValueErrorr)rrcasesnamer6s     rtest_invalid_headersz HeaderTests.test_invalid_headersDs$$]3rN	s#
$!	0KD%tUm,
0++J8HI0NN4/0
0
0	000
0
0s$B,B?BBBB'	cd}t|}tj|d}tj5}|jdddj
j}|j|dd|j|dd|j|dd|j|d	d
y#1swY|xYw)Ns9HTTP/1.1 200 OK
First: val
Second: val1
Second: val2
r )
debuglevelrzreply: 'HTTP/1.1 200 OK\r\n'zheader: First: valzheader: Second: val1zheader: Second: val2)	r
rrrcaptured_stdoutrgetvalue
splitlinesr)rrrroutputliness      rtest_headers_debuglevelz#HeaderTests.test_headers_debuglevelbs
 	
$""4A6

$
$
&	&JJL	!,,.q#CDq#78q#9:q#9:
		sCCN)r8r9r:rrrrrrrrr1rrreres0H:@D AD8&:@<0<;rreceZdZdZy)HttpMethodTestscd}|D]Y}|jtd5tjd}t	d|_|j
|dddd[y#1swYfxYw)N)	zGET
zPOST
zPUT

z
POST
Valuez
POST
HOST:abczGET
rHost:abc
zPOST
Remainder:
z
GET
HOST:
z
PUTz'method can't contain control charactersrVr~)rurl)rrrrr
rr)rmethodsrrs    rtest_invalid_method_namesz)HttpMethodTests.test_invalid_method_namesusu

	5F'' IK
5,,];&t,	F4	
5
5	5
5
5s9A""A+	N)r8r9r:rr1rrrrts5rrc<eZdZdZdZdZdZdZd
dZdZ	dZ
y	)TransferEncodingTestsIt's just a flesh woundc`tjd}td|_|j	dd|j|j
d|j|jj\}}}|j|}|j||jy)NrVrr}r~T)encode_chunked)rrr
rr
endheaders
_make_body_parse_requestr_parse_chunkedr
expected_body)rr_rs    rtest_endheaders_chunkedz,TransferEncodingTest.test_endheaders_chunkeds$$]3sO	$)$?((8
1d""4(t112rcxtjd}td|_|j	dd|jddi|j
|jj\}}}|jd|jDcgc]}|jc}|j|dd|j||jtjd}td|_|j	dd|jjdddi|j
|jj\}}}|jd|jDcgc]}|jc}|j|dd|j||jtjd}td|_|j	dddd	id
|j|j
|jj\}}}|jd|Dcgc]}|jc}|j|dd	|j|j||jycc}wcc}wcc}w)NrVrr}r~Transfer-Encodingchunkedcontent-lengthlatin-1z
gzip, chunkedT)rrr)rrr
rrrrrassertNotInkeysrprrrorrrrrrks      rtest_explicit_headersz*TransferEncodingTest.test_explicit_headerssH$$]3sO		
C*-@),L	N ..tyy~~>7D)w||~+N!AGGI+NO!45yAt112$$]3sO	C++229=
 ),	. ..tyy~~>7D)w||~+N!AGGI+NO!45yAt112$$]3sO	VS(/:"		$ ..tyy~~>7D)w+G!AGGI+GH!45G,,T2D4F4FG5,O,O,HsJ-
;J2
J7
c	dD]}tjd}td|_|j	dd|j||j
|jj\}}}|j|}|j||j|j|dd|jd	|Dcgc]}|jc}ycc}w)
N)FTrVrr}r~)empty_linesrrr)
rrr
rrrrrrrrrrp)rr	rrrrrs       rtest_requestz!TransferEncodingTest.test_requests)
	MK((7D"3DILLT___E
G $22499>>BAw&&t,DT4#5#56W%899E
-7/Ka	/KL
	M0Ls	C*cztjd}td|_|j	ddd|j|jj\}}}|j|dd|jd|Dcgc]}|jc}|j|d	ycc}w)
NrVrr}r~r1rrrs0

)
rrr
rrrrrrrprs      rtest_empty_bodyz$TransferEncodingTest.test_empty_bodys$$]3sO	VS"%..tyy~~>7D!45yA)w+G!AGGI+GH|,,HsB8
c#K|jjd}t|D]-\}}|r	|dzrd|t|dz
kr|dz*|/yw)N rrr )rrm	enumeratern)rr	ridxlines     rrzTransferEncodingTest._make_bodysa""((."5)	ICsQw	SZ!^#Tk!
	sAAc|jd}|d}i}d}|t|krt||dkDr}||jd\}}|jdj}|jdj||<|dz
}|t|krt||dkDr}||dj	||dzdfS)N
rr rlr)rmrnrorr)rrrrrrMkeyrs        rrz#TransferEncodingTest._parse_requests

7#(
#e*nU1X!2Qx~~d+HC**Y'--/C::i0668GCL
FA	#e*nU1X!2eAEFm!<<<rcg}i}d}|jd}	|||dz\}}t|d}|dk(r|dz
}nA|j|t||j	||dz
}|t|kDrncdj|S)Nrrrr r)rmintrrnrsr)rrrtrailersrMrsizechunks        rrz#TransferEncodingTest._parse_chunkeds


7#!A#,KD%tR=DqyQT3u:.KK
FA3u:~!$xx~rN)F)r8r9r:rrrr
rrrrr1rrrrs-.M3$HLM -	=rrcJeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7y6)7	BasicTestc
f|jhdtttdky)N>rr6phrasedescription)rsetdirrr.s r&test_dir_with_added_behavior_on_statusz0BasicTest.test_dir_with_added_behavior_on_statuss#Bc#jY\oJ^F__`rcjGddtj}tj|ty)Nc^eZdZ	dFdZedZedZedZedZedZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Z<d:Z=d;Z>d<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdDZGyE)G;BasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatusc\tj||}||_||_||_|Sr0)r__new___value_rr)clsr6rrobjs     rr(zCBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.__new__#s,kk#u-##
"-
rc"d|cxkxrdkScS)Ndr1r.s ris_informationalzLBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_informational+d)c))))rc"d|cxkxrdkScS)N+r1r.s r
is_successzFBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_success/r0rc"d|cxkxrdkScS)N,r1r.s ris_redirectionzJBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_redirection3r0rc"d|cxkxrdkScS)Nr1r.s ris_client_errorzKBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_client_error7r0rc"d|cxkxrdkScS)NWr1r.s ris_server_errorzKBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_server_error;r0r)r-Continuez!Request received, please continue)ezSwitching Protocolsz.Switching to new protocol; obey Upgrade header)f
Processing)gzEarly Hints)r2OKz#Request fulfilled, document follows)CreatedzDocument created, URL follows)Acceptedz/Request accepted, processing continues off-line)zNon-Authoritative InformationzRequest fulfilled from cache)z
No Contentz"Request fulfilled, nothing follows)z
Reset Contentz"Clear input form for further input)zPartial ContentzPartial content follows)zMulti-Status)zAlready Reported)zIM Used)r6zMultiple Choicesz,Object has several resources -- see URI list)i-zMoved Permanently(Object moved permanently -- see URI list)i.Found(Object moved temporarily -- see URI list)i/z	See Otherz'Object moved -- see Method and URL list)i0zNot Modifiedz)Document has not changed since given time)i1z	Use Proxyz@You must use proxy specified in Location to access this resource)i3zTemporary RedirectrT)i4zPermanent RedirectrR)r:zBad Requestz(Bad request syntax or unsupported method)Unauthorizedz*No permission -- see authorization schemes)izPayment Requiredz"No payment -- see charging schemes)i	Forbiddenz0Request forbidden -- authorization will not help)r 	Not FoundzNothing matches the given URI)izMethod Not Allowedz-Specified method is invalid for this resource)izNot Acceptablez%URI not available in preferred format)izProxy Authentication Requiredz7You must authenticate with this proxy before proceeding)izRequest Timeoutz"Request timed out; try again later)iConflictzRequest conflict)iGonez5URI no longer exists and has been permanently removed)izLength Requiredz"Client must specify Content-Length)izPrecondition Failedz Precondition in headers is false)izRequest Entity Too LargezEntity is too large)izRequest-URI Too LongzURI is too long)izUnsupported Media Typez!Entity body in unsupported format)izRequested Range Not SatisfiablezCannot satisfy request range)izExpectation Failedz'Expect condition could not be satisfied)izI'm a Teapotz5Server refuses to brew coffee because it is a teapot.)izMisdirected Requestz(Server is not able to produce a response)izUnprocessable Entity)iLocked)izFailed Dependency)iz	Too Early)izUpgrade Required)izPrecondition Requiredz8The origin server requires the request to be conditional)izToo Many RequestszOThe user has sent too many requests in a given amount of time ("rate limiting"))izRequest Header Fields Too LargezVThe server is unwilling to process the request because its header fields are too large)izUnavailable For Legal ReasonszOThe server is denying access to the resource as a consequence of a legal demand)r>zInternal Server ErrorzServer got itself in trouble)izNot Implementedz&Server does not support this operation)izBad Gatewayz+Invalid responses from another server/proxy)izService Unavailablez8The server cannot process the request due to a high load)izGateway Timeoutz4The gateway server did not receive a timely response)izHTTP Version Not SupportedzCannot fulfill request)izVariant Also Negotiates)izInsufficient Storage)iz
Loop Detected)izNot Extended)izNetwork Authentication Requiredz7The client needs to authenticate to gain network accessN)r)Hr8r9r:r(propertyr/r4r8r<r@CONTINUESWITCHING_PROTOCOLS
PROCESSINGEARLY_HINTSrFCREATEDACCEPTEDNON_AUTHORITATIVE_INFORMATION
NO_CONTENT
RESET_CONTENTPARTIAL_CONTENTMULTI_STATUSALREADY_REPORTEDIM_USEDMULTIPLE_CHOICESMOVED_PERMANENTLYFOUND	SEE_OTHERNOT_MODIFIED	USE_PROXYTEMPORARY_REDIRECTPERMANENT_REDIRECTBAD_REQUESTUNAUTHORIZEDPAYMENT_REQUIRED	FORBIDDEN	NOT_FOUNDMETHOD_NOT_ALLOWEDNOT_ACCEPTABLEPROXY_AUTHENTICATION_REQUIREDREQUEST_TIMEOUTCONFLICTGONELENGTH_REQUIREDPRECONDITION_FAILEDREQUEST_ENTITY_TOO_LARGEREQUEST_URI_TOO_LONGUNSUPPORTED_MEDIA_TYPEREQUESTED_RANGE_NOT_SATISFIABLEEXPECTATION_FAILEDIM_A_TEAPOTMISDIRECTED_REQUESTUNPROCESSABLE_ENTITYLOCKEDFAILED_DEPENDENCY	TOO_EARLYUPGRADE_REQUIREDPRECONDITION_REQUIREDTOO_MANY_REQUESTSREQUEST_HEADER_FIELDS_TOO_LARGEUNAVAILABLE_FOR_LEGAL_REASONSINTERNAL_SERVER_ERRORNOT_IMPLEMENTEDBAD_GATEWAYSERVICE_UNAVAILABLEGATEWAY_TIMEOUTHTTP_VERSION_NOT_SUPPORTEDVARIANT_ALSO_NEGOTIATESINSUFFICIENT_STORAGE
LOOP_DETECTEDNOT_EXTENDEDNETWORK_AUTHENTICATION_REQUIREDr1rrCheckedHTTPStatusr&s#
$

*
*
*
*
*
*
*
*
*
*LH#F*J,KABEGCH-Q)PJVMOO.L6$G @!<LESI=LTI"<"<<K>L 6DI1I"A9N-K)6O:HID6O#4('$$# &5"/0+";IK#<#> "F 8(I6%L!!</(+-?)
%0!:O?K#LHO**&&D##> 0M.L/K+rr)enumIntEnum_test_simple_enumr)rrs  rtest_simple_httpstatusz BasicTest.test_simple_httpstatuss*`	K`	KB	
0*=rc	tjjD]&}|j|d|j	|d(y)Nr-r?)r__members__valuesassertGreaterEqualassertLessEqual)rmembers  rtest_httpstatus_rangezBasicTest.test_httpstatus_rangesC? ,,335	.F##FC0  -	.rc	d}tjjD]L}|D]E\\}}}t||}||cxkr|krnn|j	|5|j|GNy)N)))r-r.r/))r2r3r4))r6r7r8))r:r;r<))r>r?r@)rrrgetattrrassertFalse)r
categoriesrrpuppercategorycategory_indicators       rtest_httpstatus_categoryz"BasicTest.test_httpstatus_categoryszH

!,,335	9F,6
9(%,VX%>"F+e+OO$67$$%78
9	9rcd}t|}tj|}|j|j	|jdd|j
|j|j
|j|j	|jd|j|j|j
|j|j|j|jd}t|}tj|}|jtj|jy)NHTTP/1.1 200 Ok

TextrrTextzHTTP/1.1 400.100 Not Ok

Text)
r
rrrrrKrisclosedclosedrr)assertRaises
BadStatusLiners    rtest_status_lineszBasicTest.test_status_liness-$""4(

1s+)%g.

(%

$4$""4(&..

;rcdtjd}|jt|dy)NrzBadStatusLine("''"))rrrrepr)rexcs  rtest_bad_status_reprzBasicTest.test_bad_status_reprs'""2&c$=>rcd}t|}tj|}|j|j	|jdd|j
|j|j	|jdd|j|j|j
|j|j|j|jyN*HTTP/1.1 200 Ok
Content-Length: 4

TextrTextr
rrrrrKrrrrr)rs    rtest_partial_readszBasicTest.test_partial_readssB$""4(

1u-)1u-

(%

$rcd}t|}tj|}|j|j	|jd|j
|j|j	|jd|j|j|j
|j|j|j|jy)Nz4HTTP/1.1 200 Ok
Content-Length: 13

Text
AnothersText
sAnother)r
rrrrrOrrrKrrr)rs    rtest_mixed_readszBasicTest.test_mixed_readssN$""4(

+6)j1

(%

$rc~d}t|}tj|}|jt	d}|j|}|j
|d|j
t|d|j|j|j|}|j
|d|j
t|d|j|j|j|j|j|j|jyr
r
rrr	bytearrayreadintorrrrrrr)rrrrbrMs      rtest_partial_readintosz BasicTest.test_partial_readintossB$""4(

aLMM!Aq5))MM!Aq5)

(%

$rctd}t|}tj|}|j|j	|jdd|j
|j|j|j|j|j
|jy)Nr
rr
rrrrrKrrrrr)rs    rtest_partial_reads_past_endz%BasicTest.test_partial_reads_past_endsA$""4(

20

(%

$rcd}t|}tj|}|jt	d}|j|}|j
|d|j
t|ddd|j|j|j|j|j|j|jy)Nrrr)
r
rrrrrrrrrrrr)rs      rtest_partial_readintos_past_endz)BasicTest.test_partial_readintos_past_end#sA$""4(

bMMM!Aq"1w/

(%

$rc6d}t|}tj|}|j|j	|jdd|j
|j|j	|jdd|j	|jdd|j|j|j
|j|j|j|jy)Nrrrrr rrrs    r$test_partial_reads_no_content_lengthz.BasicTest.test_partial_reads_no_content_length2s-$""4(

1u-)1u-1s+

(%

$rc8d}t|}tj|}|jt	d}|j|}|j
|d|j
t|d|j|j|j|}|j
|d|j
t|d|j|}|j
|d|j|jy)Nrrrrr)r
rrrrrrrrrrrs      r(test_partial_readintos_no_content_lengthz2BasicTest.test_partial_readintos_no_content_lengthBs-$""4(

aLMM!Aq5))MM!Aq5)MM!A

(rcd}t|}tj|}|j|j	|jdd|j
|j|j	|jdd|j	|jdd|j|jy)N+HTTP/1.1 200 Ok
Content-Length: 10

Textrrrr r)	r
rrrrrKrrrrs    r"test_partial_reads_incomplete_bodyz,BasicTest.test_partial_reads_incomplete_bodyUsC$""4(

1u-)1u-1s+

(rcd}t|}tj|}|jt	d}|j|}|j
|d|j
t|d|j|j|j|}|j
|d|j
t|d|j|}|j
|d|j|j|j|j|j|j|jy)Nrrrrrrrs      r&test_partial_readintos_incomplete_bodyz0BasicTest.test_partial_readintos_incomplete_bodybs	C$""4(

aLMM!Aq5))MM!Aq5)MM!A

(%

$rc dD]1}|jtjtj|3dD]S\}}}tj|}|j	||j
|j	||jUy)Nzwww.python.org:abczuser:password@www.python.org)z[fe80::207:e9ff:fe9b]:8000fe80::207:e9ff:fe9bi@)zwww.python.org:80www.python.orgP)www.python.org:rr)rrr)[fe80::207:e9ff:fe9b]rr)[fe80::207:e9ff:fe9b]:rr)rr
InvalidURLrrrrrhphpcs     rtest_host_portzBasicTest.test_host_portxsI	LBf//1F1FK	LP		(HB1%%b)AQ'Q'		(rcd}d}t|}tj|}|j|j	d}|j||y)NzHTTP/1.1 200 OK
Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"
Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"

No body
zrCustomer="WILE_E_COYOTE"; Version="1"; Path="/acme", Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"z
Set-Cookie)r
rrrrr)rrhdrsr$cookiess      rtest_response_headerszBasicTest.test_response_headerssTO
t"		++l+#&rctdt}tj|d}|j	|jr|j
dyy)N*HTTP/1.1 200 OK
Content-Length: 14432

rr)Did not expect response from HEAD request)r
rHrrrrKfailrrrs   rtest_read_headzBasicTest.test_read_headsP

	
""47

99;IIABrctdt}tj|d}|j	td}|j
|dk7r|jd|jt|dy)Nrrrrr)
r
rHrrrrrrrr)rrrrs    rtest_readinto_headzBasicTest.test_readinto_headsp

	
""47

aL==q IIABq9-rcdjdttjdzDdz}d|z}t	|}tj
|}|j
tjd|jy)Nrc3&K|]	}d|zyw)z
Header%d: fooNr1).0is  r	<genexpr>z2BasicTest.test_too_many_headers.<locals>.<genexpr>sF"#.1Fsr zHTTP/1.1 200 OK
zgot more than \d+ headers)	rrr_MAXHEADERSr
rr
HTTPExceptionr)rrrrr$s     rtest_too_many_headerszBasicTest.test_too_many_headerss}++F',V-?-?!-C'DFFHNO%/t"v33;QWW	Frc	Rd}ttd5}tjd}t	|}||_|j
dd||j|jj||jdt|d|dddy#1swYyxYw)Ns_GET /foo HTTP/1.1
Host: example.com
Accept-Encoding: identity
Transfer-Encoding: chunked

r%rVrrz != )open__file__rrr
rrrrrrnrrrrrs     rtest_send_filezBasicTest.test_send_files
(D
!	;T((7Dd#DDILL-OODII00:YY~H
.=:
;	;	;	;sBBB&cd}tjd}td}||_|j	||j||jd|_|j	tjd||j||jd|_|j	tj||j||jy)Ns"this is a test this is only a testrVrr)
rrr
rsendrrarrayr;r<rs    r	test_sendzBasicTest.test_sends8$$]3$			(499-			%++c8,-499-			"**X&'499-rcdGfddtj}d}tjd}t	d}||_|j
||j|j|y)Nc3$Kdddyw)Nrdata_twor1r1rrrz/BasicTest.test_send_updating_file.<locals>.datasLJc*eZdZdZWZddZy)7BasicTest.test_send_updating_file.<locals>.UpdatingFiler$c,t|jSr0)nextd)r	blocksizes  rrKz<BasicTest.test_send_updating_file.<locals>.UpdatingFile.readsDFF|#rNrQ)r8r9r:r*rrK)rsrUpdatingFilersDA
$rrsdatarVr)	r;
TextIOBaserrr
rrrr)rrrrrrs     @rtest_send_updating_filez!BasicTest.test_send_updating_filesa	
	$2==	$$$]3"~			,.!H-rcd}d}tjd}td}||_|j	dd|ddi|j|j|y)	NsbGET /foo HTTP/1.1
Host: example.com
Accept-Encoding: identity
Content-Length: 11

onetwothreec3$Kdddyw)Nsonestwosthreer1r1rrrz&BasicTest.test_send_iter.<locals>.bodysLLNrrVrrrr11)rrr
rrrrrs     rtest_send_iterzBasicTest.test_send_iters^&	
$$]3"~	UFDF-=t,DEH-rcX	d}tjd|}td}||_d|zdz}|j	ddtj|dd	i|j|jd
|jjddd}|j||y)
NrVrabrr~r9r

r )rrr
rrr;r<rrrrm)rrrrrrs      rtest_blocksize_requestz BasicTest.test_blocksize_requestsF	$$]iH$	)#d*UCH!58H#7NO++Q/yy{A.q1x(rc$	d}tjd|}td}||_d|zdz}|j	tj||j|jd|j|j|y)NrrVrrr r)
rrr
rrr;r<rrr)rrrrrs     rtest_blocksize_sendzBasicTest.test_blocksize_send
s{C	$$]iH$	)#d*		"**X&'++Q/H-rctjd}td|_|j	t
5|j
dd|dddy#1swYyxYw)NrVrr}test)rrr
rr	TypeErrorrrs  rtest_send_type_errorzBasicTest.test_send_type_errorsP$$]3rN	


y
)	/LL.	/	/	/sAA!cXt}tttztz}tj|d}|j|j|j||jtddD]}tttztz}tj|d}|j|j|j||j|z|jz||jdD]m}tt|z}tj|d}|j	|j|jd|joy#t
j$rj}|j|j|dt|z}|jt!|||jt#||Yd}~d}~wwxYw#|jwxYw)Nrrr rzfoo
IncompleteRead expectedIncompleteRead(%d bytes read))chunked_expectedr

chunked_start
last_chunkchunked_endrrrrrKr)rrIncompleteReadpartialrnrr)rrrrrMxrexpected_messages        rtest_chunkedzBasicTest.test_chunkeds#-*4{BC""46

h/

q"	Amj8;FGD&&tE:DJJLTYYq\DIIaL8499;FQJJL	!	Ama/0D&&tE:DJJL

				34

	((
;  H5#BS]#R   a*:;  Q)9::	
;

s1#F3HH*A H
HHHH)ct}t|}td}ttt
ztz}tj|d}|j|j|}|j|d|||j|||jtddD]}ttt
ztz}tj|d}|jt|}|j|d|}||j||||zz
}||j||dz
}|j|d|||j|||jdD]n}	tt|	z}tj|d}|j	|j|}|jd|jpy#tj $rj}|j|j"|d	t|z}
|jt%||
|jt'||
Yd}~d}~wwxYw#|jwxYw)
Nrrrr r+rr,r-r.)r/rnrr
r0r1r2rrrrrr)r
memoryviewrr3r4rr)rr	nexpectedrrrrMmrr5r6s           rtest_readinto_chunkedzBasicTest.test_readinto_chunked?s'#M	cN-*4{BC""46

MM!:I1I&

q"
	Amj8;FGD&&tE:DJJL1
A

a!f%A
q1q5z**A
qu%%AQz	]H5Q	*JJL
	!	Ama/0D&&tE:DJJL

MM!$		34

	((
;  H5#BS]#R   a*:;  Q)9::	
;

s1G9I99I6A I1,I91I66I99Jcd}t|tztz}tj|d}|j|j
|jd|j
|jd|j
|jd|j|j|j|j|j|j|jy)NEHTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello world
1
d
rrrr2rF)r
r1r2rrrrrKstatusreasonrrrrr))rr0rrs    rtest_chunked_headzBasicTest.test_chunked_headjs
	-*4{BC""47

c*c*d+

(%

$rcTd}t|tztz}tj|d}|jt
d}|j|}|j|d|jt|d|j|jd|j|jd|j|j|j|j|j!|j|jy)	Nr>rrrrrr2rF)r
r1r2rrrrrrrr?r@rrrrr))rr0rrrrMs      rtest_readinto_chunked_headz$BasicTest.test_readinto_chunked_head~s
	-*4{BC""47

aLMM!Aq9-c*d+

(%

$rctd}tj|d}|j|j	|jd|j
|jy)Nz.HTTP/1.1 200 OK
Content-Length: -1

Hello
rrHello
)r
rrrrrKrrrs   rtest_negative_content_lengthz&BasicTest.test_negative_content_lengthsSDF""46

l3

(rctd}tj|d}|j	|j	|jdy#tj$r{}|j|jd|jt|d|jt|d|j|jYd}~yd}~wwxYw)Nz.HTTP/1.1 200 OK
Content-Length: 10

Hello
rrr-rEz-IncompleteRead(7 bytes read, 3 more expected))
r
rrrrKrr3rr4rrrr)rrrrs    rtest_incomplete_readzBasicTest.test_incomplete_readsRS""46


	1IIK
II/0$$	-QYY5T!WL
NSVL
NOODMMO,,
	-sAC$)A1CC$c"tdd}tjd|_|j	t
fdj
}|jd|j|jd|jdy)NzgHTTP/1.0 401 Authorization Required
Content-type: text/html
WWW-Authenticate: Basic realm="example"
sContent-LengthrVc*jdddS)Nr/urlr)r)rsr<lambda>z&BasicTest.test_epipe.<locals>.<lambda>s$,,uff"ErrUzBasic realm="example"zwww-authenticate)
r>rrrrrCgetresponserr?r)rrrrs   @r
test_epipezBasicTest.test_epipes
<
	
$$]3	'E	G!dkk*2(:;	=rcdddzzdz}tjt|}|jtjtj
f|jy)NHTTP/1.1 200 Okrr)rrr
rLineTooLongrrrrrs   rtest_overflowing_status_linez&BasicTest.test_overflowing_status_linesO 3;.7"":d#346--v/C/CDdjjQrcdddzzdz}tjt|}|jtj|j
y)NzHTTP/1.1 200 OK
X-Foo: barr$rQz

)rrr
rrRrrSs   rtest_overflowing_header_linez&BasicTest.test_overflowing_header_linesQ
;
')3
4	
"":d#34&,,djj9rcfddz}tjt|}|jtj5}|jddd|j
dtj|j
dt|jy#1swYTxYw)NzHTTP/1.1 100 OK
r
izgot more than r)	rrr
rrrrr	exception)rrrcms    r'test_overflowing_header_limit_after_100z1BasicTest.test_overflowing_header_limit_after_100s

	
"":d#34


v33
4	JJL		


&BLL(9:

iR\\!23		sB''B0cdddzzdz}tjt|}|j|j	tj
|jy)Nz/HTTP/1.1 200 OK
Transfer-Encoding: chunked

r
rQza
hello world
0

)rrr
rrrRrKrSs   rtest_overflowing_chunked_linez'BasicTest.test_overflowing_chunked_lines\
1Ek

	
"":d#34

&,,dii8rcrd}t|}tj|}|j|j	|jd|j
|j|j|j|j|j
|jy)NrPrrrs    rtest_early_eofzBasicTest.test_early_eofs} $""4(

c*

(%

$rctjd}dGfddtj}||_t	d|_|j
dd|jtj|j|jj|j|j
jy)NrVceZdZfdZy)+BasicTest.test_error_leak.<locals>.ResponsecP|tjj|g|i|yr0)rrr)rrarbresponses   rrz4BasicTest.test_error_leak.<locals>.Response.__init__s&##,,T>C>2>rN)r8r9r:r)rcsrResponseras
?rrdzInvalid status linerr~)
rrrresponse_classr
rrrrrMrrr)rrrdrcs   @rtest_error_leakzBasicTest.test_error_leaks$$]3	?v**	?
'45	UC &..0@0@A(		--.rcd}tdz}tt|ztztz}tj|d}|j|j|j||jy)Nz3;foo=bar
abc
sabcrr)r/r
r0last_chunk_extendedr2rrrrrKr))rextrarrrs     rtest_chunked_extensionz BasicTest.test_chunked_extensionse+#f,-%/2EEST""46

h/

rc	t}tttz}t	j
|d}|j
|j|j||jyNrr)
r/r
r0r1rrrrrKr)rrrrs    rtest_chunked_missing_endz"BasicTest.test_chunked_missing_endsSG#-*45""46

h/

rc\	t}tttztzt
z}t
j|d}|j|j|j||j|jjd|jy)Nrrr)
r/r
r0r1rr2rrrrrKr'r)rms    rtest_chunked_trailerszBasicTest.test_chunked_trailerssx4#-*4x?+MN""46

h/)3/

rc	t}d}tttztzt
z|z}t
j|d}|j|j|j||j|jj|jd|jy)N	extradatarrr)r/r
r0r1rr2rrrrrKr'rr))rrrrrrs     rtest_chunked_synczBasicTest.test_chunked_syncsR#	-*4x?+MPYYZ""46

h/)9+;+;G+DE

rc2	d}d}td|z|z}tj|d}|j|j	|j||j	|jj||jy)N	extradata
Hello123
'HTTP/1.1 200 OK
Content-Length: 10

rr)r
rrrrrKr'r)rrrrrrs     rtest_content_length_syncz"BasicTest.test_content_length_sync+szP 	"JXUXaab""46

h/)95

rc4d}d}td|z|z}tj|d}|j|j	|jd|g|j	|jj||jyNrurvrwrri)	r
rrrr	readlinesr'rKr)rxs     rtest_readlines_content_lengthz'BasicTest.test_readlines_content_length7s| 	"JXUXaab""46

-z:)95

rc2d}d}td|z|z}tj|d}|j|j	|jd||j	|jj||jyr{)	r
rrrrread1r'rKr)rxs     rtest_read1_content_lengthz#BasicTest.test_read1_content_lengthBsz 	"JXUXaab""46

D)84)95

rctd}d}td|z|z}tj|d}|j|j	|jd||j	|jdd|j	|jj||jy)Nrurvrwrrrr)	r
rrrrrOr'rKr)rxs     r"test_readline_bound_content_lengthz,BasicTest.test_readline_bound_content_lengthMs 	"JXUXaab""46

r*H5r*C0)95

rc~d}d}td|dzz|z}tj|d}|j|j	|jd|dz|j	|j
||j	|jj
||jy)	Nrurvs'HTTP/1.1 200 OK
Content-Length: 30

rrrr)	r
rrrrrrKr'r)rxs     rtest_read1_bound_content_lengthz)BasicTest.test_read1_bound_content_lengthYs 	"JXVWZWZccd""46

B!4h/)95

rcztjtdf|jjdfd}tj|}|j|j|jtdtjj}|jdd|j}	|j|j tj"tj|j%}	|j'd|j)	|j	|j	|j|jdy#|j)wxYw#|j	|j	wxYw)	Nrc0j\}}|5|jd5}	|j}|jdsn#|j	d|jddddddy#1swYxYw#1swYyxYw)Nr%rs'HTTP/1.1 200 Connection established

)acceptr,rOrstripr"rK)raddressreaderrresultservs    r
run_serverz2BasicTest.test_response_fileno.<locals>.run_serverks"kkmOT7
't}}T*
'f!??,D;;w/KL
'
'
'
'
'
's#BAB/BB		BB)targetr rz
dummy:1234)filenos
proxied data
)socket
create_serverHOST
addCleanupr)	threadingThreadstartrfloatrrgetsocknamerrMrr?rFrr"detach)rrthreadrrcrrrs      @@rtest_response_filenozBasicTest.test_response_filenoes2##T1I.

#
	'!!4U1X.$$d&6&6&89Y-##%		X__fii8

X__%67A
		+,
NNJJL
!23
NNJJLs%AFF/FFF"F:c	Gddtj}|d}td|_|j	ddy)NceZdZdZy)RBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnectioncyr0r1rrs  r_validate_pathzaBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnection._validate_pathrN)r8r9r:rr1rrUnsafeHTTPConnectionr
rrrVrrz/rrr
rrrrrs   r*test_putrequest_override_domain_validationz4BasicTest.test_putrequest_override_domain_validations>		6#8#8	$M2rN	w'rcGddtj}|d}td|_|j	dddy)	NceZdZdZy)PBasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnectioncyr0r1rs  r_validate_hostz_BasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnection._validate_hostrrN)r8r9r:rr1rrrrrrrz
example.com
rrr~r )	skip_hostrrs   r(test_putrequest_override_host_validationz2BasicTest.test_putrequest_override_host_validations@	6#8#8	$$56rN		
sa0rc	Gddtj}|d}td|_|j	ddy)NceZdZdZy)IBasicTest.test_putrequest_override_encoding.<locals>.UnsafeHTTPConnectionc$|jdS)Nutf-8)r)rstr_urls  r_encode_requestzYBasicTest.test_putrequest_override_encoding.<locals>.UnsafeHTTPConnection._encode_requests~~g..rN)r8r9r:rr1rrrrs
/rrrVrru/☃rrs   r!test_putrequest_override_encodingz+BasicTest.test_putrequest_override_encodings>	
	/6#8#8	/$M2rN	v&rN)8r8r9r:r#rrrrrrrrrrrrrrrrrrrrr
rrr#r%r)r7r<rArCrFrHrNrTrVrZr\r^rfrjrnrprsryr}rrrrrrrr1rrrr
sab>H.9$<*?
%
%%(
%
%% )&)%,("'$C
.F;..*. 
)	./@)V%(%.)1 
="R
:49
%/ 	

		

#4J(	1'rrceZdZ	dZeej	ddjdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZy)ExtendedReadTestzOHTTP/1.1 200 OK

hello world!
and now 
for something completely different
foohelloNrHTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello worl
3
d!

9
and now 

23
for something completely different

3
foo
0

ct|j}tj|d}|j	tj|j|_||_yrl)	r
rrrrr;BufferedReaderfprrs   rsetUpzExtendedReadTest.setUpsH$**%""46

##DGG,	rc|j}|jjdfd	}||j_g}	|jd}|r|jt	|d|j}|jt	|t	||j
|j||jt	|}|j||n!|j}|j||j||sn|jdj||jy)Nc2|}|dk\r|d|S|ddS)Nrrr1)rMroldpeeks  rmypeekz*ExtendedReadTest.test_peek.<locals>.mypeeks)
AAv!uSb6MrrrrrQ)rrpeek
assertGreaterrnrrrrKrrrsrlines_expected)rrrallrp2rrs       @r	test_peekzExtendedReadTest.test_peeksyy'',,	
		!A""3q61-YY[''BQ8

a 01yyR)  r*yy{  &JJt!"	
#(;(;<rc||j}|j|jj|jyr0)r_verify_readlinerOr)rrs  r
test_readlinezExtendedReadTest.test_readlines+yydii00$2E2EFrcg}	|d}|r3|dk7r.t|dkr |j|jd|j||snR|j	dj||y)Nrfoo
r)rnrrrsrr)rrOrrrs     rrz!ExtendedReadTest._verify_readlinesmA;Dt9q=OODMM%$89JJt	
#1rcjfd}t|}j|jjy)Nc`jd}jt|d|S)Nr)rrrn)resrrs rr$z&ExtendedReadTest.test_read1.<locals>.r
s)**Q-C  S1-Jr)r	ReadlinerrrOr)rr$	readlinerrs`  @r
test_read1zExtendedReadTest.test_read1s8yy	aL	i00$2E2EFrc|j}g}	|j}|sn|j|%|jdj	||j
yNr)rrrsrrrrrrrs    rtest_read1_unboundedz%ExtendedReadTest.test_read1_unboundedsUyy::<DJJt	
	
#(;(;<rc|j}g}	|jd}|sn-|jt|d|j	|A|jdj
||jy)Nrr)rrrrnrsrrrrs    rtest_read1_boundedz#ExtendedReadTest.test_read1_boundedskyy::b>D  TB/JJt	
#(;(;<rcZ|j|jjddy)Nrr)rrrr.s rtest_read1_0zExtendedReadTest.test_read1_0&s+S1rcp|jjd}|jdt|yNr)rrrrn)rrs  rtest_peek_0zExtendedReadTest.test_peek_0)s(IINN1QA'r)r8r9r:rfindrr
lines_chunkedrrrrrrrrrr1rrrrsm	
5::g./077@N
	"=>G2G=	=2(rrceZdZ	dZy)ExtendedReadTestChunkedrN)r8r9r:rr1rrrr.s
	
rrceZdZ	dZdZy)rc ||_d|_yr)readfunc	remainder)rrs  rrzReadliner.__init__Hs 
rctg}d}|j}		|jd}|dk7rn@|t|z|k\r||z
dz
}|j||j	}|sd}nW|dz
}|j|d|||d|_dj|S#dj||_xYw)NrrrRr r)rrrnrsrr)rlimitrdatalenrKrs      rrOzReadliner.readlineLs~~	ii&"9SY&%/'/A-CD!}}C
1HCKKTc
#!#$ZDN88D>!	 XXd^DNsBBB7N)r8r9r:rrOr1rrrrDsrrceZdZdZdZdZy)OfflineTestc
dh}ddh}ttD]J}|jds||vrtt|}t|dddk(s:|j	|L|jtj|y)N	responsesHTTPMessage
parse_headersrr9zhttp.client)r"rrraddassertCountEqual__all__)rrdenylistr
module_objects     rtest_allzOfflineTest.test_allgs}="?3K	#Ds#tx'7#FD1M}lD9]JT"	#	
fnnh7rcf|jtjtjdy)NrX)rrrrvr.s rtest_responseszOfflineTest.test_responsesus#))&*:*:;[Ircgd}|D]<}|j|5|jtt|ddd>y#1swYIxYw)N):r]r^r_rFrarbrcrdrerfrgrirjrkrlrmrnrorprrrsrtrurvrwrxryrzr{r|r}r~rrrrrrrrrrrrrrrrrrrrrrrrr`r)constant)rrhasattrr)rrconsts   rtest_client_constantsz!OfflineTest.test_client_constantsxsV;
x	8Eu-
8 67
8
8	8
8
8s AA	N)r8r9r:rrrr1rrrrfs8J@8rrc`eZdZdZdZdZejee	dddZ
y)SourceAddressTestc.tjtjtj|_t	j
|j|_t	j|_|jjd|_
yr0)rAF_INETSOCK_STREAMrr	bind_portrfind_unused_portsource_portlistenrr.s rrzSourceAddressTest.setUps\MM&..&2D2DE	!++DII6	(99;			rc|jr!|jjd|_|jjd|_yr0)rr)rr.s rtearDownzSourceAddressTest.tearDowns399IIOODI			rc(tjt|jd|jf|_|j
j
|j|j
jjd|jy)Nrsource_addressr )
rrrrrrr_rrrr.s rtestHTTPConnectionSourceAddressz1SourceAddressTest.testHTTPConnectionSourceAddresssf))$		 "D$4$457			335a8$:J:JKrHTTPSConnectionz'http.client.HTTPSConnection not definedcrtjt|jd|jf|_y)Nrr)rrrrrrr.s r testHTTPSConnectionSourceAddressz2SourceAddressTest.testHTTPSConnectionSourceAddresss,**4 "D$4$457	rN)r8r9r:rr	r
unittestskipIfrrrr1rrrrsCLX__):;;>@7@7rrc"eZdZdZdZdZdZy)TimeoutTestNctjtjtj|_t	j
|jt_|jjyr0)	rrrrrrrPORTrr.s rrzTimeoutTest.setUpsEMM&..&2D2DE	(22499=		rcF|jjd|_yr0)rr)r.s rr	zTimeoutTest.tearDowns			rcX|jtjtjd	t	j
ttj}|jtjd|j|jjd|j|jtjtjd	t	j
ttjd}|jtjd|j|jjd|jt	j
ttjd}|j|j|jjd|jy#tjdwxYw#tjdwxYwN)timeout)assertIsNonergetdefaulttimeoutsetdefaulttimeoutrrrrrr_rr
gettimeoutr))rhttpConns  rtestTimeoutAttributez TimeoutTest.testTimeoutAttributes
	
&2245  $	+,,T;3C3CDH$$T*113R8	
&2245  $	+,,T;3C3C6:<H$$T*113T:(({/?/?L113R8)
$$T*
$$T*s8G8::H8HH))r8r9r:rrr	r!r1rrrrsD
rrceZdZdZdZdZy)PersistenceTestcd}|D]"\}}}|j||5dj||}t|}|j|j|jdd|j
5}|j|jdu||jddd|j|jdu||j|jd|jdd|j|j|rdndddd%y#1swYxYw#1swY=xYw)	N))1.0rF)r%zConnection: keep-alive
T)1.1rT)r&zConnection: close
F)r%zConnection: keep-ALIVE
T)r&zConnection: cloSE
F)versionrz4HTTP/{} 200 OK
{}Content-Length: 12

Dummy body
rz/open-connectionr z/subsequent-requestr)
rrrTrrrrMrrKrW)rtestsr'rreuserrrcs        rtest_reuse_reconnectz$PersistenceTest.test_reuse_reconnect
s:
',	F"GVUgf=
F%
&&)
04!!$)),U$67%%'$8$$TYY$%6E	BMMO$  d!2I>  !1!115U$9:  !1!111E#
F
F	F$$
F
Fs%AD8;0D,+A5D8,D51D88E	cd}tjtjf|tff}|D]\}}|j|5t
d|}|jdd|j||j|j|j|jdd|j|jddddy#1swYxYw)Ncr	tj|fd}|_tjS)Ncftjj|}|dk(r
t|Sr)r;r<rConnectionResetError)bufferrstreams  rrzNPersistenceTest.test_disconnected.<locals>.make_reset_reader.<locals>.readinto-s.zz**66:19.00r)r;r<rr)rrr0s  @rmake_reset_readerz<PersistenceTest.test_disconnected.<locals>.make_reset_reader*s3EZZ%F

'FO$$V,,r)rXrrz
/eof-response
/reconnectr)r;r<rRemoteDisconnectedr.rrTrrrMrrrrW)rr1r(stream_factoryrXrs      rtest_disconnectedz!PersistenceTest.test_disconnected(s		-ZZ223
 45
*/	6%NI	2
6/^DUO4!!)T-=-=>!!$)),UL1  !1!115
6
6	6
6
6s
BCC	c,td}|jddddi|jtj|j
|j
|j|jdd|j|jdy)	NsHTTP/1.1 100 Continue

rr~Expectz100-continuerr2r)
rTrrrr3rMrrrrWrs  rtest_100_closezPersistenceTest.test_100_closeCs|'


	
UC(N)CD&33T5E5EF$))$UL)))1-rN)r8r9r:r*r5r9r1rrr#r#sF<66
.rr#ceZdZdZdZdZdZdZejdZ
dZejdd	Z
d
ZdZdZej$eed
ddZdZy)	HTTPSTestcHttds|jdyy)Nrzssl support required)rrskipTestr.s rrzHTTPSTest.setUpRsv01MM012rc"ddlm}|||S)Nr)make_https_server)certfile)test.ssl_serversr?)rr@r?s   rmake_serverzHTTPSTest.make_serverVs6 99rctjttjd}|j|jdyr)rrrrrrr)rrs  rtest_attributeszHTTPSTest.test_attributesZs0""4)9)92FB'rcddl}tjdtjd5tjdd}|j|j5}|jddddd|jjjddddy#1swY8xYw#1swYyxYw)Nrnetworkself-signed.pythontest.netrr~CERTIFICATE_VERIFY_FAILED)
sslrrequiresrtransient_internetrrrSSLErrorrrrXr@)rrJrexc_infos    rtest_networkedzHTTPSTest.test_networked_s#

-
-.J
K	U&&'CSIA""3<<0
&H		%%
&X//668ST		U	U
&
&	U	Us#2B7!B+4.B7+B4	0B77Ccddl}tjdtjd5|j}t
jdd|}|jdd|j}|j|jd|jd	|jdddy#1swYyxYw)
NrrFrGrHcontextrr~nginxserver)
rJrrKrrL_create_unverified_contextrrrrMr)rr)rrJrRrrs     rtest_networked_noverificationz'HTTPSTest.test_networked_noverificationis#

-
-.J
K	446G&&'CS/68A
IIeS!==?D
GGIMM'4>>(#;<JJL			sBCC
cxtjdtjd5t	j
dd}|j
dd|j}|jd}|j|j|jd|dddy#1swYyxYw)NrFrrHrr~zcontent-typez	text/html)rrKrrLrrrrMrr)r)rrrcontent_types    r&test_networked_trusted_by_default_certz0HTTPSTest.test_networked_trusted_by_default_certws	#

-
-.>
?	5&&'7=A
IIeS!==?D>>.9LJJL
GGIMM+|4	5	5	5sA<B00B9c	ddl}tjdd}tj|5|j|j}|j|j|j|j|jd|jt	tj|d|}|jdd|j!}|j/d
}|j1|j1|j3d|dddy#|j"$rC}t%|}t'j(d	|rt+j,d
|d|dd}~wwxYw#1swYyxYw)NrrFrGTrHrQrr~z(?i)key.too.weakzGot z trying to connect to z). See https://bugs.python.org/issue36816.rTrS)rJrrKrrL
SSLContextPROTOCOL_TLS_CLIENTrverify_mode
CERT_REQUIREDcheck_hostnameload_verify_locations CERT_selfsigned_pythontestdotnetrrrrMrMrresearchrSkipTestrr)r)	rrJselfsigned_pythontestdotnetrRrrssl_errssl_err_str
server_strings	         rtest_networked_good_certz"HTTPSTest.test_networked_good_certse#&B#

-
-.I
J	2nnS%<%<=GW00#2C2CDW33T:))*JK
**+F3:<		%%}}!NN84MJJL
GGIMM'=15	2	2<<
!'l990+>"++{m,9:;BBCC
	2	2s1A3F%:D+AF+E=:>E88E==FF	walltimecddl}tjdtjd5|j|j}|jttjdd|}|j|j5}|jddddd|jjj ddddy#1swY8xYw#1swYyxYw)	NrrFrGrHrQrr~rI)rJrrKrrLr[r\r`CERT_localhostrrrrMrrrXr@)rrJrRrrNs     rtest_networked_bad_certz!HTTPSTest.test_networked_bad_certs	#

-
-.J
K	UnnS%<%<=G)).9&&'CSRYZA""3<<0
&H		%%
&X//668ST
	U	U
&
&		U	Us$A$C)C&.C)C&	"C))C2cFddl}|jt}tjd|j
}|j
|j5}|jddddd|jjjdy#1swY0xYw)Nr	localhostrr~rI)rJrBrlrrrrrMrrrXr@)rrJrTrrNs     rtest_local_unknown_certz!HTTPSTest.test_local_unknown_certs!!.1"";<


s||
,	"
IIeS!	"++224OP	"	"sBB cddl}|jt}|j|j}|jtt
jd|j|}|j|j|jdd|j}|j|j|j|jdy)NrrorQr/nonexistentr )rJrBrlr[r\r`rrrrr)rrMrr?rrJrTrRrrs      rtest_local_good_hostnamez"HTTPSTest.test_local_good_hostnames!!.1..!8!89%%n5"";WM 			%(}}

#c*rcBddl}|jt}|j|j}|jtt
jd|j|}|j|j5|jdddddd|_t
jd|j|}|j|j5|jdddddd|_t
jd|j|}|jdd|j}|j|j|j|j d	y#1swYxYw#1swYxYw)
NrrorQrr~TFrrr )rJrBCERT_fakehostnamer[r\r`rrrrCertificateErrorrr_rMr)rr?rss      rtest_local_bad_hostnamez!HTTPSTest.test_local_bad_hostnamesB!!"34..!8!89%%&78"";WM


s33
4	"
IIeS!	""&"";WM


s33
4	"
IIeS!	""'"";WM			%(}}

		c*!	"	"	"	"sF	&F	FFrz)http.client.HTTPSConnection not availablec dD]1}|jtjtj|3dD]S\}}}tj|}|j	||j
|j	||jUy)Nr)r)zwww.python.org:443rrH)rrrH)rrrH)rrrH)rrrH)rrrrrrrrs     rrzHTTPSTest.test_host_ports
I	MBf//1G1GL	M#
	(HB1&&r*AQ'Q'
	(rcddl}|js|jdtjdd}|j|jj|j|j}|j|jtjdd|}|j|j||j|jj|j|jt}d|_tjdd|}|j|jjy)NrzTLS 1.3 support requiredrorHrQ)	cert_fileT)
rJHAS_TLSv1_3r=rrr_contextpost_handshake_authr[r\rassertIsrl)rrJrrRs    rtest_tls13_phazHTTPSTest.test_tls13_phasMM45"";4

667..!8!89445"";WE

ajj'*778..!8!8N.S&*#"";WE

667rN)r8r9r:rrBrDrOrVrsystem_must_validate_certrYrirequires_resourcermrprtrxrrrrrrr1rrr;r;Ps2:(
U
&&
5'
52BWz*
U+
UQ++2X__):;;@B(B($8rr;cDeZdZ	dZdZdZdZdZdZdZ	dZ
d	Zy
)RequestBodyTestctjd|_tdx|j_|_|j|j_y)NrVr)rrrr
rr.s rrzRequestBodyTest.setUps9))-8	%/^3				rctj|jj}|j	tj|}||fSr0)r;r<rrrOrrrfmessages   rget_headers_and_fpz"RequestBodyTest.get_headers_and_fps;JJtyy~~&	

&&q)zrcddgdfdf}|D]\}}|j|5tjd|_t	dx|j_|_|jj
dd||j\}}|jd	||jd
||j|jdd|j||jdddy#1swYxYw)
Nrbar3
foo
3
bar
0

))rrrrVrrrKzContent-Typerrr)rrrrr
rrrrrgetrK)rrrrrrs      rtest_list_bodyzRequestBodyTest.test_list_bodys
f
CDD
$
	5ND(d#	
5"11-@	-7^;				!!%6002Q  5  !137  )<!=yI  16684	
5	
5
	5	
5	
5sCC>>D	c|jjdddddi|j\}}|jd|j	d|jdt|j
y)NrrKrr42rr)rrrrrrnrKrrrs   rtest_manual_content_lengthz*RequestBodyTest.test_manual_content_length+sj	
		%+T2	4,,.
w{{+;<=CM*rcd|jjddd|j\}}|jd|j	|j|j
|jd|jd|jd|jy)NrrKr
text/plain4rsbody	rrrrget_content_typerget_charsetrrKrs   rtest_ascii_bodyzRequestBodyTest.test_ascii_body4s		%0,,.
w'?'?'AB'--/0gkk*:;<!&&(+rcd|jjddd|j\}}|jd|j	|j|j
|jd|jd|jd|jy)NrrKubodyÁr5rbodyrrs   rtest_latin1_bodyz RequestBodyTest.test_latin1_body<s		%4,,.
w'?'?'AB'--/0gkk*:;<affh/rcd|jjddd|j\}}|jd|j	|j|j
|jd|jd|jd|jy)NrrKrrrrrrs   rtest_bytes_bodyzRequestBodyTest.test_bytes_bodyDs		%5,,.
w'?'?'AB'--/0gkk*:;<affh/rc|jtjtjt	tjdd5}|jddddt	tjd5}|jjdd||j\}}|jd|j|j|j|j|jd|jd	|jd
|jd|jdddy#1swYxYw#1swYyxYw)Nwr)encodingrrrKrrrztransfer-encodings4
body
0

)rrunlinkTESTFNrwriterrrrrrrrrKrs   rtest_text_file_bodyz#RequestBodyTest.test_text_file_bodyLs$	(()*:*:;
)""C'
:	a
GGFO	
)""W
5		BIIeVQ/002JGQ\7+C+C+EFg1134
gkk*:;<Y4G(HI6A		B		B				B		BsECE&E#&E/c|jtjtjt	tjd5}|jddddt	tjd5}|jjdd||j\}}|jd|j|j|j|jd|jd|jd	||jd
|jdddy#1swYxYw#1swYyxYw)Nwbrr%rrKrrrrs5
body
0

)rrrrrrrrrrrrrrrrKrs   rtest_binary_file_bodyz%RequestBodyTest.test_binary_file_body[s	(()*:*:;
)""D
)	!Q
GGK 	!
)""D
)	FQIIeVQ/002JGQ\7+C+C+EFg1134Y4G(HI-w7:AFFHE	F	F	!	!	F	Fs	E	=CE	EEN)r8r9r:rrrrrrrrrr1rrrr	s4=#
5(+,00
BFrrc0eZdZdZdZdZdZdZdZy)HTTPResponseTestcd}t|}tj||_|jj	y)NzXHTTP/1.1 200 Ok
My-Header: first-value
My-Header:                 second-value

Text)r
rrrr)rrrs   rrzHTTPResponseTest.setUpks3*$''-			rc|jjd}|j|d|jjdd}|j|dy)Nz	My-Headerzfirst-value, second-valuezsome defaultrrrrrs  rtest_getting_headerz$HTTPResponseTest.test_getting_headerrsN$$[1!<=$$[.A!<=rc`|jjdd}|j|dy)NNo-Such-Headerz
default-valuerrs  r3test_getting_nonexistent_header_with_string_defaultzDHTTPResponseTest.test_getting_nonexistent_header_with_string_defaultys)$$%5G1rc|jjdddg}|j|d|jjdd}|j|dy)Nrdefaultrzdefault, values)rrrrs  r5test_getting_nonexistent_header_with_iterable_defaultzFHTTPResponseTest.test_getting_nonexistent_header_with_iterable_default}sX$$%5	87LM!23$$%57LM!23rc^|jjd}|j|dy)Nrrrs  r/test_getting_nonexistent_header_without_defaultz@HTTPResponseTest.test_getting_nonexistent_header_without_defaults'$$%56&rcb|jjdd}|j|dy)Nrr)rrrs  rtest_getting_header_defaultintz/HTTPResponseTest.test_getting_header_defaultints,$$%5b$A$rN)	r8r9r:rrrrrrr1rrrris >24'%rrc~eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZy)TunnelTestscd}d|_tj|_tj|j|_|j
||j
_y)Nz:HTTP/1.1 200 OK

HTTP/1.1 200 OK
Content-Length: 42

z	proxy.com)rr	HTTP_PORTrrrr[)r
response_texts  rrzTunnelTests.setUpsO
)	
 	$$	))$))4	'+'>'>}'M		$rc8|jjyr0)rr)r.s rr	zTunnelTests.tearDowns		rcdfd	}|S)Nc,t|d|dS)Nrr rrr
)rrrrs   rrZz9TunnelTests._create_connection.<locals>.create_connectionsm'!*71:NNrNNr1)rrrZs ` rr[zTunnelTests._create_connections	O  rcd}d}ddi}|j}d||fz|d<|jj||||jjdd	d
|j	|jj
j|j|j	|jj
j|j|j	|jj||j	|jj||j	|jj|y)Ndestination.com"
User-Agent!Mozilla/5.0 (compatible, MSIE 11)%s:%drzrrrr~r)copyr
set_tunnelrrrrr_tunnel_host_tunnel_port_tunnel_headers)rtunnel_hosttunnel_porttunnel_headerstunnel_headers_afters     r2test_set_tunnel_host_port_headers_add_host_missingz>TunnelTests.test_set_tunnel_host_port_headers_add_host_missings'&(KL-224'.+{1K'KV$		[{%3		5		&#r*,,dii8,,dii8//=//=224HIrcbd}d}dd||fzd}|jj||||jjddd	|j|jjj
|j
|j|jjj|j|j|jj||j|jj||j|jj|y)
Nrrrrrrzrrr~r
rrrrrrrrrrrrrrs    r4test_set_tunnel_host_port_headers_set_host_identicalz@TunnelTests.test_set_tunnel_host_port_headers_set_host_identicals'(K")[+,F"FH		[{%3		5		&#r*,,dii8,,dii8//=//=22NCrc^d}d}dddzd}|jj||||jjdd	d
|j|jjj
|j
|j|jjj|j|j|jj||j|jj||j|jj|y)Nrrrr)rVihrrrr~rrrs    r4test_set_tunnel_host_port_headers_set_host_differentz@TunnelTests.test_set_tunnel_host_port_headers_set_host_differents'(K"),A"AC		[{%3		5		&#r*,,dii8,,dii8//=//=22NCrc|jj|jt|jjdy)Nr)rr_rRuntimeErrorrr.s r&test_disallow_set_tunnel_after_connectz2TunnelTests.test_disallow_set_tunnel_after_connects1		,		(<(<+	-rcrdtjd}|jj|dj	d|jjddd|j
|jjj|j|j
|jjj|j|jd|z|jjj|jd	|z|jjjy
Ndestination.comhostportrrrr~r?CONNECT %(host)s:%(port)d HTTP/1.1
Host: %(host)s:%(port)d

!HEAD / HTTP/1.1
Host: %(host)s
rrrrrorrrrrrrrrs  rtest_connect_with_tunnelz$TunnelTests.test_connect_with_tunnel'%%
	
		QwZ..w78		&#r*,,dii8,,dii8

9;<=iinn))	+	


>Biinn))	+rc|dtjd}|jj|dj	d|d|jjddd	|j
|jjj|j|j
|jjj|j|jd
|z|jjj|jd|z|jjjy)Nrrrrrrrr~rrrrrs  r*test_connect_with_tunnel_with_default_portz6TunnelTests.test_connect_with_tunnel_with_default_ports'%%
	
		QwZ..w7ajI		&#r*,,dii8,,dii8

9;<=iinn))	+	


>Biinn))	+rc`ddd}|jj|djd|d|jjdd	d
|j	|jj
j|j|j	|jj
j|j|jd|z|jj
j|jd|z|jj
jy)
Nrrrrrrrrr~rrs*HEAD / HTTP/1.1
Host: %(host)s:%(port)d
)
rrrorrrrrrrrs  r.test_connect_with_tunnel_with_nonstandard_portz:TunnelTests.test_connect_with_tunnel_with_nonstandard_ports'
	
		QwZ..w7ajI		&#r*,,dii8,,dii8

9;<=iinn))	+	


G!Kiinn))	+rcddtjd}|jj|dj	dd|dj	di|jjd	d
d|j
|jjj|j|j
|jjj|j|jd|z|jjj|jd
|z|jjjy)Nrsexample.com:9876)rtunnel_host_headerrrrrrr8rr~rsDCONNECT %(host)s:%(port)d HTTP/1.1
HOST: %(tunnel_host_header)s

rrrs  r3test_connect_with_tunnel_with_different_host_headerz?TunnelTests.test_connect_with_tunnel_with_different_host_header	s'#6%%

	
		
gJg&Q45<<WEF		H	
		&#r*,,dii8,,dii8

>@ABiinn))	+	


>Biinn))	+rcrdtjd}|jj|dj	d|jjddd|j
|jjj|j|j
|jjj|j|jd|z|jjj|jd	|z|jjjyrrrs  r'test_connect_with_tunnel_different_hostz3TunnelTests.test_connect_with_tunnel_different_host	rrcd}d|jdtjfz}d||fz}|jj	||jjddd|j
|jjj|j|j
|jjjtj|j||jjjy)Nu	δπθ.grs%s:%didnas!CONNECT %s HTTP/1.1
Host: %s

rr~r)rrrrrrrrrrrr)rdest	dest_portrs    rtest_connect_with_tunnel_idnaz)TunnelTests.test_connect_with_tunnel_idna"	s&F 3V5E5EFF	=yA""		T"		&#r*,,dii8,,f.>.>?

h		 3 34rcF	tjj|jd5}|jj	d|jj|jj
dddddj|jt|jdd|j|jddd}|jd	||j|jd
d|y#1swYxYw)Nrrrr~r z!unexpected number of send calls: )rrsCONNECT destination.comr"zunexpected proxy data sent )rpatchobjectrrr_r
assert_calledrrn
mock_callsrrr)r	mock_sendproxy_setup_data_sents   r0test_tunnel_connect_single_send_connection_setupz<TunnelTests.test_tunnel_connect_single_send_connection_setup-	sF
ZZ

tyy&
1	*YII  !23IIIIeS)	*	!I(()17	8L8L7MN		P!* 4 4Q 7 :1 =

02GH%..{;12G1JK		M	*	*sADD crdtjd}|jj|dj	d|jjddd|j
|jjj|j|j
|jjj|j|jd|z|jjj|jd	|z|jjjy)
Nrrrrrr~rrs PUT / HTTP/1.1
Host: %(host)s
rrs  rtest_connect_put_requestz$TunnelTests.test_connect_put_request>	s'%%
	
		QwZ..w78		%b),,dii8,,dii8

9;<=iinn))	+	


=Aiinn))	+rcd}dj|}|jjd|j||j_|jj	dtj5}|jjddddddjj}|jdj||y#1swYIxYw)	Nz
X-Dummy: 1zHTTP/1.0 200 OK
{}

r rrr~rz
header: {})rrset_debuglevelr[rrrrrrr)rexpected_headerrrrs     rtest_tunnel_debuglogz TunnelTests.test_tunnel_debuglogM	s&7>>O
		  #'+'>'>}'M		$		./

$
$
&	.&IIeS"-	.!,,.

l))/:EB	.	.s>C$$C-cld}djdj|}|j||j_|jj	d|jjddd|jj
}|j||jy)NzX-Dummy1HTTP/1.0 200 OK
{0}

:rrr~r)	rrr[rrrget_proxy_response_headersritemsrr	rrs    rtest_proxy_response_headersz'TunnelTests.test_proxy_response_headersZ	s*
 &/!:;	
(,'>'>}'M		$		./		%b)))668

ow}}7rcd}djdj|}|j||j_|jj	ddd|jj}|j
|y)Nrrrrr~r)rrr[rrrrrs    rtest_no_proxy_response_headersz*TunnelTests.test_no_proxy_response_headersh	ss*
 &/!:;	
(,'>'>}'M		$		%b)))668'"rc6ddfd	}||j_|jjdd}	|jjddd|j||j
jy#t$r}|}Yd}~=d}~wwxYw)Nc0td|d|dS)NzHTTP/1.1 404 NOT FOUND

rr rr)rrrrs   rr[z8TunnelTests.test_tunnel_leak.<locals>._create_connectionx	s%0QZQZD
Krrrr~rr)rr[rrrCrrr)rr[rers    @rtest_tunnel_leakzTunnelTests.test_tunnel_leaku	s	(:		$		./	IIfc2.	
S!(()		C	sB	BBBN)r8r9r:rr	r[rrrrrrrrrrrrr
rrrr1rrrrsg	N!

JDD-
+
+
+$+$
+	5M"
+C8#*rr__main__r)	verbosity)<rrDhttprrr;rosr	rbrrrrTestCaser'rtest.supportrrrequires_working_socketpathdirnamerhererrlrvrar0r/chunk_extensionr1rhrr2rr
r>r<rHrrTrerrrrrrrrrr#r;rrrr8mainr1rr<module>r&s	#			
"&t,	wwx dM2GGLL~6#%77<<6W#X 	-N

O+f4-

B

*

2::$2v442"j;(j;Z5h5,}8}@d'd'Nz(xz(z.,DR8(R8j77>+(+\E.hE.Pv8v8r]Fh]F@!%x!%F~*(~*BzHMMAr