python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_httplib.cpython-312.opt-1.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_y)N)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rcyr/r0)rleveloptnamevalues    r
setsockoptzFakeSocket.setsockoptRr1rr/)__name__
__module____qualname__ioBytesIOrr!r+r'r(r6r0rrr
r
4s+')zz4	 

rr
ceZdZdZdZdZy)EPipeSocketc>tj||||_yr/)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	rcyr/r0r-s rr(zEPipeSocket.closear1rN)r7r8r9rr!r(r0rrr=r=Us)


rr=c eZdZdZddZddZy)NoEOFBytesIOzLike BytesIO, but raises AssertionError on EOF.

    This is used below to test that http.client doesn't try to read
    more from the underlying file than it should.
    cftjj||}|dk(rtd|SNrzcaller tried to read past EOF)r:r;readAssertionError)rnrs   rrJzNoEOFBytesIO.readjs.zztQ'3; !@AArNcftjj||}|dk(rtd|SrI)r:r;readlinerK)rlengthrs   rrNzNoEOFBytesIO.readlineps0zz""403; !@AArr/)r7r8r9__doc__rJrNr0rrrGrGds
rrGc2eZdZdZfdZfdZdZxZS)FakeSocketHTTPConnectionz@HTTPConnection subclass using FakeSocket; counts connect() callscbd|_t|	d||_|j|_y)Nrexample.com)connectionssuperrfake_socket_argscreate_connection_create_connection)rargs	__class__s  rrz!FakeSocketHTTPConnection.__init__ys.
' $"&"8"8rcJ|xjdz
c_t|	S)z.Count the number of times connect() is invokedr)rWrXconnect)rr]s rr_z FakeSocketHTTPConnection.connects!Aw  rc&t|jSr/)r
rY)rposkws   rrZz*FakeSocketHTTPConnection.create_connections40011r)r7r8r9rRrr_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|_yr/)countr-s rrzDHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.__init__s	
rc|jd}t|dkDrU|djdj}|jj|d|j|xxdz
cc<tj||y)N:rrr)splitlendecodelowerrj
setdefaultlistappend)ritemkvlcKeys    rrszBHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.appendslZZ%r7Q;qELL1779EJJ))%3JJu%*%D$'rNr7r8r9rrsr0rrHeaderCountingBufferrhs
 
(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|_yr/)rrrcontent_lengthr-s rrzHHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.__init__s

d#&*#rc|jdd}t|dkDr.|djdk(r|dj|_t
j
||y)Nrlrrscontent-length)rmrnrpstriprrrrs)rrtrus   rrszFHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.appendsOZZa(r7Q;2a5;;=4E#E*,Q%++-D'D$'rNrwr0rrContentLengthCheckerrs
+
(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 Spacer5sKey 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!#$%&'*+-.^_`|~r5rVCHARzobs-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)rrcasesnamer5s     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)r7r8r9rrrrrrrrr0rrreres0H:@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)r7r8r9rr0rrrrts5rrc<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~r0rrrs0

)
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
rrrlr)rmrnrorr)rrrrrrLkeyrs        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)Nrrrrr)rmintrrnrsr)rrrtrailersrLrsizechunks        rrz#TransferEncodingTest._parse_chunkeds


7#!A#,KD%tR=DqyQT3u:.KK
FA3u:~!$xx~rN)F)r7r8r9rrrr
rrrrr0rrrrs-.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>rr5phrasedescription)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`eZdZdZdGdZedZedZedZedZ	edZ
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@ZCdAZDdBZEdCZFdDZGdEZHyF)H;BasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatusaHTTP status codes and reason phrases

            Status codes from the following RFCs are all observed:

                * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616
                * RFC 6585: Additional HTTP Status Codes
                * RFC 3229: Delta encoding in HTTP
                * RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518
                * RFC 5842: Binding Extensions to WebDAV
                * RFC 7238: Permanent Redirect
                * RFC 2295: Transparent Content Negotiation in HTTP
                * RFC 2774: An HTTP Extension Framework
                * RFC 7725: An HTTP Status Code to Report Legal Obstacles
                * RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
                * RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)
                * RFC 8297: An HTTP Status Code for Indicating Hints
                * RFC 8470: Using Early Data in HTTP
            c\tj||}||_||_||_|Sr/)r__new___value_rr)clsr5rrobjs     rr(zCBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.__new__#s,kk#u-##
"-
rc"d|cxkxrdkScS)Ndr0r-s ris_informationalzLBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_informational+d)c))))rc"d|cxkxrdkScS)N+r0r-s r
is_successzFBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_success/r0rc"d|cxkxrdkScS)N,r0r-s ris_redirectionzJBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_redirection3r0rc"d|cxkxrdkScS)Nr0r-s ris_client_errorzKBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_client_error7r0rc"d|cxkxrdkScS)NWr0r-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)Ir7r8r9rRr(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_REQUIREDr0rrCheckedHTTPStatusr&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*=rctjjD]&}|j|d|j	|d(y)z1Checks that the statuses are in the 100-599 ranger-r?N)r__members__valuesassertGreaterEqualassertLessEqual)rmembers  rtest_httpstatus_rangezBasicTest.test_httpstatus_rangesB!,,335	.F##FC0  -	.rcd}tjjD]L}|D]E\\}}}t||}||cxkr|krnn|j	|5|j|GNy)z:Checks that the statuses belong to the standard categories)))r-r.r/))r2r3r4))r6r7r8))r:r;r<))r>r?r@N)rrrgetattrrassertFalse)r
categoriesrrpuppercategorycategory_indicators       rtest_httpstatus_categoryz"BasicTest.test_httpstatus_categorysw

!,,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
rrrrrJrisclosedclosedrr(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
rrrrrJrrrrr(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
rrrrrNrrrJrrr(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(rrrrbrLs      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
rrrrrJrrrrr(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)Nrrrrrrrrs    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

Textrrrrr)	r
rrrrrJrrrrs    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
rGrrrrJfailrrrs   rtest_read_headzBasicTest.test_read_headsP

	
""47

99;IIABrctdt}tj|d}|j	td}|j
|dk7r|jd|jt|dy)Nrrrrr)
r
rGrrrrrrrr)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: fooNr0).0is  r	<genexpr>z2BasicTest.test_too_many_headers.<locals>.<genexpr>sF"#.1FsrzHTTP/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_twor0r0rrrz/BasicTest.test_send_updating_file.<locals>.datasLJc*eZdZdZWZddZy)7BasicTest.test_send_updating_file.<locals>.UpdatingFiler#c,t|jSr/)nextd)r	blocksizes  rrJz<BasicTest.test_send_updating_file.<locals>.UpdatingFile.readsDFF|#rNrP)r7r8r9r)rrJ)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)Nsonestwosthreer0r0rrrz&BasicTest.test_send_iter.<locals>.bodysLLNrrVrrrr11)rrr
rrrrrs     rtest_send_iterzBasicTest.test_send_iters^&	
$$]3"~	UFDF-=t,DEH-rcVd}tjd|}td}||_d|zdz}|j	ddtj|d	d
i|j|jd|jjdd
d
}|j||y)z8Check that request() respects the configured block size.rVrNabrr~r9r

r)rrr
rrr:r;rrrrm)rrrrrrs      rtest_blocksize_requestz BasicTest.test_blocksize_requests	$$]iH$	)#d*UCH!58H#7NO++Q/yy{A.q1x(rc"d}tjd|}td}||_d|zdz}|j	tj||j|jd|j|j|y)z5Check that send() respects the configured block size.rrVrNrr r)
rrr
rrr:r;rrr)rrrrrs     rtest_blocksize_sendzBasicTest.test_blocksize_send
sx	$$]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_endrrrrrJr(rrIncompleteReadpartialrnrr)rrrrrLxrexpected_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)
Nrrrrr+rr,r-r.)r/rnrr
r0r1r2rrrrrr(r
memoryviewrr3r4rr)rr	nexpectedrrrrLmrr5r6s           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
r1r2rrrrrJstatusreasonrrrrr()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()rr0rrrrLs      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
rrrrrJrrrs   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
rrrrJrr3rr4rrrr)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=rrrrrBgetresponserr?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
rrrRrJrSs   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|yr/)rrr)rrarbresponses   rrz4BasicTest.test_error_leak.<locals>.Response.__init__s&##,,T>C>2>rN)r7r8r9r)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_extendedr2rrrrrJr()rextrarrrs     rtest_chunked_extensionz BasicTest.test_chunked_extensionse+#f,-%/2EEST""46

h/

rct}tttz}t	j
|d}|j
|j|j||jy)z9some servers may serve up a short chunked encoding streamrrN)
r/r
r0r1rrrrrJr(rrrrs    rtest_chunked_missing_endz"BasicTest.test_chunked_missing_endsP#-*45""46

h/

rcZt}tttztzt
z}t
j|d}|j|j|j||j|jjd|jy)z&See that trailers are read and ignoredrrrN)
r/r
r0r1rr2rrrrrJr&r(rls    rtest_chunked_trailerszBasicTest.test_chunked_trailerssu#-*4x?+MN""46

h/)3/

rct}d}tttztzt
z|z}t
j|d}|j|j|j||j|jj|jd|jy)zDCheck that we don't read past the end of the chunked-encoding stream	extradatarrrN)r/r
r0r1rr2rrrrrJr&rr()rrrqrrs     rtest_chunked_synczBasicTest.test_chunked_syncs#	-*4x?+MPYYZ""46

h/)9+;+;G+DE

rc0d}d}td|z|z}tj|d}|j|j	|j||j	|jj||jy)zBCheck that we don't read past the end of the Content-Length stream	extradata
Hello123
'HTTP/1.1 200 OK
Content-Length: 10

rrN)r
rrrrrJr&r(rrqrrrs     rtest_content_length_syncz"BasicTest.test_content_length_sync+sw 	"JXUXaab""46

h/)95

rc4d}d}td|z|z}tj|d}|j|j	|jd|g|j	|jj||jyNrtrurvrri)	r
rrrr	readlinesr&rJr(rws     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||jyrz)	r
rrrrread1r&rJr(rws     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)Nrtrurvrrrr)	r
rrrrrNr&rJr(rws     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)	Nrtrus'HTTP/1.1 200 OK
Content-Length: 30

rrrr)	r
rrrrr~rJr&r(rws     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+rNrstripr!rJ)raddressreaderrresultservs    r
run_serverz2BasicTest.test_response_fileno.<locals>.run_serverks"kkmOT7
't}}T*
'f!??,D;;w/KL
'
'
'
'
'
's#BAB/BB		BB)targetrrz
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:cGddtj}|d}td|_|j	ddy)zv
        It should be possible to override the default validation
        behavior in putrequest (bpo-38216).
        ceZdZdZy)RBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnectioncyr/r0rrs  r_validate_pathzaBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnection._validate_pathrN)r7r8r9rr0rrUnsafeHTTPConnectionr
rrrVrrz/Nrrr
rrrrrs   r*test_putrequest_override_domain_validationz4BasicTest.test_putrequest_override_domain_validations9
	6#8#8	$M2rN	w'rcGddtj}|d}td|_|j	dddy)	NceZdZdZy)PBasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnectioncyr/r0rs  r_validate_hostz_BasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnection._validate_hostrrN)r7r8r9rr0rrrrrrrz
example.com
rrr~r)	skip_hostrrs   r(test_putrequest_override_host_validationz2BasicTest.test_putrequest_override_host_validations@	6#8#8	$$56rN		
sa0rcGddtj}|d}td|_|j	ddy)z
        It should be possible to override the default encoding
        to transmit bytes in another encoding even if invalid
        (bpo-36274).
        ceZdZdZy)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)r7r8r9rr0rrrrs
/rrrVrru/☃Nrrs   r!test_putrequest_override_encodingz+BasicTest.test_putrequest_override_encodings9	/6#8#8	/$M2rN	v&rN)8r7r8r9r#rrrrrrrrrrrrrrrrrrrrr
rrr#r%r)r7r<rArCrFrHrNrTrVrZr\r^rfrjrmrorrrxr|rrrrrrrr0rrrr
sab>H.9$<*?
%
%%(
%
%% )&)%,("'$C
.F;..*. 
)	./@)V%(%.)1 
="R
:49
%/ 	

		

#4J(	1'rrceZdZdZdZeejddj
dZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZy)ExtendedReadTestz*
    Test peek(), read1(), readline()
    zOHTTP/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|_||_y)Nrr)	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)Nrrr0)rLroldpeeks  rmypeekz*ExtendedReadTest.test_peek.<locals>.mypeeks)
AAv!uSb6MrrrrrP)rrpeek
assertGreaterrnrrrrJrrrsrlines_expected)rrrallrp2rrs       @r	test_peekzExtendedReadTest.test_peeksyy'',,	
		!A""3q61-YY[''BQ8

a 01yyR)  r*yy{  &JJt!"	
#(;(;<rc||j}|j|jj|jyr/)r_verify_readlinerNr)rrs  r
test_readlinezExtendedReadTest.test_readlines+yydii00$2E2EFrcg}	|d}|r3|dk7r.t|dkr |j|jd|j||snR|j	dj||y)Nrfoo
r)rnrrrsrr)rrNrrrs     rrz!ExtendedReadTest._verify_readlinesmA;Dt9q=OODMM%$89JJt	
#1rcjfd}t|}j|jjy)Nc`jd}jt|d|S)Nr)r~rrn)resrrs rr#z&ExtendedReadTest.test_read1.<locals>.r
s)**Q-C  S1-Jr)r	ReadlinerrrNr)rr#	readlinerrs`  @r
test_read1zExtendedReadTest.test_read1s8yy	aL	i00$2E2EFrc|j}g}	|j}|sn|j|%|jdj	||j
yNr)rr~rsrrrrrrrs    rtest_read1_unboundedz%ExtendedReadTest.test_read1_unboundedsUyy::<DJJt	
	
#(;(;<rc|j}g}	|jd}|sn-|jt|d|j	|A|jdj
||jy)Nrr)rr~rrnrsrrrrs    rtest_read1_boundedz#ExtendedReadTest.test_read1_boundedskyy::b>D  TB/JJt	
#(;(;<rcZ|j|jjddy)Nrr)rrr~r-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)r7r8r9rRrfindrr
lines_chunkedrrrrrrrrrr0rrrrsm	
5::g./077@N
	"=>G2G=	=2(rrceZdZdZdZy)ExtendedReadTestChunkedz:
    Test peek(), read1(), readline() in chunked mode
    rN)r7r8r9rRrr0rrrr.s
	
rrceZdZdZdZdZy)rzT
    a simple readline class that uses an arbitrary read function and buffering
    c ||_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)NrrrQrr)rrrnrsrr)rlimitrdatalenrJrs      rrNzReadliner.readlineLs~~	ii&"9SY&%/'/A-CD!}}C
1HCKKTc
#!#$ZDN88D>!	 XXd^DNsBBB7N)r7r8r9rRrrNr0rrrrDsrrceZdZdZdZdZy)OfflineTestc
dh}ddh}ttD]J}|jds||vrtt|}t|dddk(s:|j	|L|jtj|y)N	responsesHTTPMessage
parse_headersrr8zhttp.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)r7r8r9rrrr0rrrrfs8J@8rrc`eZdZdZdZdZejee	dddZ
y)SourceAddressTestc.tjtjtj|_t	j
|j|_t	j|_|jjd|_
yr/)rAF_INETSOCK_STREAMrr	bind_portrfind_unused_portsource_portlistenrr-s rrzSourceAddressTest.setUps\MM&..&2D2DE	!++DII6	(99;			rc|jr!|jjd|_|jjd|_yr/)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
)rr
rrrrr-s r testHTTPSConnectionSourceAddressz2SourceAddressTest.testHTTPSConnectionSourceAddresss,**4 "D$4$457	rN)r7r8r9rrrunittestskipIfrrrr0rrrrsCLX__):;;>@7@7rrc"eZdZdZdZdZdZy)TimeoutTestNctjtjtj|_t	j
|jt_|jjyr/)	rrrrrrrPORTrr-s rrzTimeoutTest.setUpsEMM&..&2D2DE	(22499=		rcF|jjd|_yr/)rr(r-s rrzTimeoutTest.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))r7r8r9rrrr r0rrrrsD
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-connectionrz/subsequent-requestr)
rrrTrrrrMrrJrW)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)Ncptj|fd}|_tjS)z3Return BufferedReader that raises ECONNRESET at EOFcftjj|}|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)rrr/s  @rmake_reset_readerz<PersistenceTest.test_disconnected.<locals>.make_reset_reader*s0ZZ%F

'FO$$V,,r)rXrrz
/eof-response
/reconnectr)r:r;rRemoteDisconnectedr-rrTrrrMrrrrW)rr0r'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-continuerr1r)
rTrrrr2rMrrrrWrs  rtest_100_closezPersistenceTest.test_100_closeCs|'


	
UC(N)CD&33T5E5EF$))$UL)))1-rN)r7r8r9r)r4r8r0rrr"r"sF<66
.rr"ceZdZdZdZdZdZdZejdZ
dZejdd	Z
d
ZdZdZej$eed
ddZdZy)	HTTPSTestcHttds|jdyy)Nr
zssl 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)rr
rrrrr)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_internetrr
rSSLErrorrrrXr@)rrIrexc_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)
NrrErFrGcontextrr~nginxserver)
rIrrJrrK_create_unverified_contextrr
rrMr(rr)rrIrQrrs     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)NrErrGrr~zcontent-typez	text/html)rrJrrKrr
rrMrr(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)NrrErFTrGrPrr~z(?i)key.too.weakzGot z trying to connect to z). See https://bugs.python.org/issue36816.rSrR)rIrrJrrK
SSLContextPROTOCOL_TLS_CLIENTrverify_mode
CERT_REQUIREDcheck_hostnameload_verify_locations CERT_selfsigned_pythontestdotnetrr
rrMrLrresearchrSkipTestrr(r)	rrIselfsigned_pythontestdotnetrQrrssl_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)	NrrErFrGrPrr~rH)rIrrJrrKrZr[r_CERT_localhostrr
rrLrrrXr@)rrIrQrrMs     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~rH)rIrArkrr
rrrLrrrXr@)rrIrSrrMs     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)NrrnrPr/nonexistentr )rIrArkrZr[r_rr
rrr(rrMrr?rrIrSrQrrs      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)
NrrnrPrr~TFrqr )rIrACERT_fakehostnamerZr[r_rr
rrCertificateErrorrr^rMr(rr?rrs      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	FFr
z)http.client.HTTPSConnection not availablec dD]1}|jtjtj|3dD]S\}}}tj|}|j	||j
|j	||jUy)Nr)r)zwww.python.org:443rrG)rrrG)rrrG)rrrG)rrrG)rrrr
rrrrs     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 requiredrnrGrP)	cert_fileT)
rIHAS_TLSv1_3r<rr
r_contextpost_handshake_authrZr[rassertIsrk)rrIrrQs    rtest_tls13_phazHTTPSTest.test_tls13_phasMM45"";4

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

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

667rN)r7r8r9rrArCrNrUrsystem_must_validate_certrXrhrequires_resourcerlrorsrwrrrrrrr0rrr:r:Ps2:(
U
&&
5'
52BWz*
U+
UQ++2X__):;;@B(B($8rr:cFeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
Zy)RequestBodyTestz3Test cases where a request includes a message body.ctjd|_tdx|j_|_|j|j_y)NrVr)rrrr
rr-s rrzRequestBodyTest.setUps9))-8	%/^3				rctj|jj}|j	tj|}||fSr/)r:r;rrrNrrrfmessages   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
rrrrrgetrJ)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)rrrrrrnrJrrrs   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_charsetrrJrs   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

)rrunlinkTESTFNrwriterrrrrrrrrJrs   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

)rrrrrrrrrrrrrrrrJrs   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)
r7r8r9rRrrrrrrrrrr0rrrr	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)	r7r8r9rrrrrrr0rrrris >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|jjyr/)rr(r-s rrzTunnelTests.tearDowns		rcdfd	}|S)Nc,t|d|dS)Nrrrrr
)rrrrs   rrZz9TunnelTests._create_connection.<locals>.create_connectionsm'!*71:NNrNNr0)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_headerrrrrrr7rr~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 34rcDtjj|jd5}|jj	d|jj|jj
dddddj|jt|jdd|j|jd	dd	}|jd
||j|jdd|y#1swYxYw)
z8Regresstion test for https://bugs.python.org/issue43332.rrrr~Nrz!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-	s
ZZ

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

02GH%..{;12G1JK		M	*	*sADDcrdtjd}|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
{}

rrrr~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_headersritemsrrrrs    rtest_proxy_response_headersz'TunnelTests.test_proxy_response_headersZ	s*
 &/!:;	
(,'>'>}'M		$		./		%b)))668

ow}}7rcd}djdj|}|j||j_|jj	ddd|jj}|j
|y)Nrr
rrr~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

rrrr)rrrrs   rr[z8TunnelTests.test_tunnel_leak.<locals>._create_connectionx	s%0QZQZD
Krrrr~rr)rr[rrrBrrr)rr[rers    @rtest_tunnel_leakzTunnelTests.test_tunnel_leaku	s	(:		$		./	IIfc2.	
S!(()		C	sB	BBBN)r7r8r9rrr[rrrrrrrrrrrrr	rrrr0rrrrsg	N!

JDD-
+
+
+$+$
+	5M"
+C8#*rr__main__r)	verbosity)<rrChttprrr:rosr	rarrrrTestCaser'rtest.supportrrrequires_working_socketpathdirnamerhererrkrur`r0r/chunk_extensionr1rhrr2rr
r=r;rGrrTrerrrrrrrrrr"r:rrrr7mainr0rr<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