+
    BiÇ                       ^ RI t ^ RIt^ RIHtHt ^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIHt ]P                  t^ RIHt ^ RIHt ^ RIHt ]P(                  ! RR7       ]P*                  P-                  ]4      t]P*                  P3                  ]R	R
4      t]P*                  P3                  ]R	R4      t]P*                  P3                  ]R	R4      tRtRtRtRt R],           R,           t!Rt"Rt#]PH                  t$ ! R R4      t% ! R R]%4      t& ! R R]PN                  4      t( ! R R]PR                  4      t* ! R R]4      t+ ! R R]4      t, ! R  R!]4      t- ! R" R#]4      t. ! R$ R%]4      t/ ! R& R']/4      t0 ! R( R)]/4      t1 ! R* R+4      t2 ! R, R-]4      t3 ! R. R/]4      t4 ! R0 R1]4      t5 ! R2 R3]4      t6 ! R4 R5]4      t7 ! R6 R7]4      t8 ! R8 R9]4      t9 ! R: R;]4      t:];R<8X  d   ]Px                  ! ^R=7       R# R# )>    N)client
HTTPStatus)mock)support)	os_helper)socket_helperT)modulecertdatazkeycert.pemzkeycert2.pemzselfsigned_pythontestdotnet.pemz{HTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello worl
3
d! 
8
and now 
22
for something completely different
s7   hello world! and now for something completely differentz;foo=barz0
0
zX-Dummy: foo
X-Dumm2: bar
c                   f   a  ] tR t^6t o ]P
                  RR3R ltR tR	R ltR t	R t
R tRtV tR# )

FakeSocketNc                    \        V\        4      '       d   VP                  R 4      pWn        W n        RV n        ^ V n        RV n        W0n        W@n	        R# )ascii    FN)

isinstancestrencodetext	fileclassdatasendall_callsfile_closedhostport)selfr   r   r   r   s   &&&&&(/usr/lib/python3.14/test/test_httplib.py__init__FakeSocket.__init__7   sH    dC  ;;w'D	"	 		r   c                j    V ;P                   ^,          un         V ;P                  V,          un        R# )   N)r   r   r   r   s   &&r   sendallFakeSocket.sendallB   s!    a		T	r   c                    VR 8w  d   VR8w  d   \         P                  ! 4       hV P                  V P                  4      V n        V P
                  V P                  n        V P                  # )rrb)r   UnimplementedFileModer   r   file
file_closeclose)r   modebufsizes   &&&r   makefileFakeSocket.makefileF   sK    3;44<..00NN499-	//		yyr   c                    R V n         R# )TN)r   r   s   &r   r*   FakeSocket.file_closeN   s
    r   c                    R # N r1   s   &r   r+   FakeSocket.closeQ       r   c                    R # r4   r5   )r   leveloptnamevalues   &&&&r   
setsockoptFakeSocket.setsockoptT   r7   r   )r   r)   r   r   r   r   r   r   r4   )__name__
__module____qualname____firstlineno__ioBytesIOr   r#   r.   r*   r+   r<   __static_attributes____classdictcell____classdict__s   @r   r   r   6   s3     ')zz4 	  r   r   c                   2   a  ] tR t^Wt o R tR tR tRtV tR# )EPipeSocketc                <    \         P                  W4       W n        R # r4   )r   r   pipe_trigger)r   r   rK   s   &&&r   r   EPipeSocket.__init__Y   s    D'(r   c                    V P                   V9   d   \        \        P                  R 4      hV ;P                  V,          un        R# )gotchaN)rK   OSErrorerrnoEPIPEr   r"   s   &&r   r#   EPipeSocket.sendall^   s/    $%++x00		T	r   c                    R # r4   r5   r1   s   &r   r+   EPipeSocket.closec   r7   r   )rK   N)	r>   r?   r@   rA   r   r#   r+   rD   rE   rF   s   @r   rI   rI   W   s     )

 r   rI   c                   8   a  ] tR t^ft o RtRR ltRR ltRtV tR# )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.
c                h    \         P                  P                  W4      pVR 8X  d   \        R4      hV# r   zcaller tried to read past EOF)rB   rC   readAssertionError)r   nr   s   && r   rY   NoEOFBytesIO.readl   s,    zzt'3; !@AAr   Nc                h    \         P                  P                  W4      pVR 8X  d   \        R4      hV# rX   )rB   rC   readlinerZ   )r   lengthr   s   && r   r^   NoEOFBytesIO.readliner   s.    zz""403; !@AAr   r5   r4   )	r>   r?   r@   rA   __doc__rY   r^   rD   rE   rF   s   @r   rV   rV   f   s     
 r   rV   c                   H   a a ] tR t^xt oRtV 3R ltV 3R ltR tRtVt	V ;t
# )FakeSocketHTTPConnectionz@HTTPConnection subclass using FakeSocket; counts connect() callsc                b   < ^ V n         \        SV `	  R4       Wn        V P                  V n        R# )r   example.comN)connectionssuperr   fake_socket_argscreate_connection_create_connection)r   args	__class__s   &*r   r   !FakeSocketHTTPConnection.__init__{   s,    ' $"&"8"8r   c                R   < V ;P                   ^,          un         \        SV `	  4       # )z.Count the number of times connect() is invoked)rh   ri   connect)r   rn   s   &r   rq    FakeSocketHTTPConnection.connect   s!    Aw  r   c                (    \        V P                  !  # r4   )r   rj   )r   poskws   &*,r   rk   *FakeSocketHTTPConnection.create_connection   s    40011r   )rl   rh   rj   )r>   r?   r@   rA   rc   r   rq   rk   rD   rE   __classcell__)rn   rG   s   @@r   re   re   x   s     J9!
2 2r   re   c                   P   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	tV tR
# )HeaderTestsc                    ! R  R\         4      pR F  pR	 F  p\        P                  ! R4      p\        R4      Vn        V! 4       Vn        Rp/ pV'       d   \        \        V4      4      Wc&   VP                  RRWV4       V P                  VP
                  P                  VP                  4       ,          ^4       K  	  K  	  R# )
c                   ,   a  ] tR t^t o R tR tRtV tR# );HeaderTests.test_auto_headers.<locals>.HeaderCountingBufferc                    / V n         R # r4   countr1   s   &r   r   DHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.__init__   s	    
r   c                4   VP                  R 4      p\        V4      ^8  db   V^ ,          P                  R4      P                  4       pV P                  P                  V^ 4       V P                  V;;,          ^,          uu&   \        P                  W4       R# )   :r   N)splitlendecodelowerr   
setdefaultlistappend)r   itemkvlcKeys   &&  r   r   BHeaderTests.test_auto_headers.<locals>.HeaderCountingBuffer.append   sj    ZZ%r7Q;qELL1779EJJ))%3JJu%*%D'r   r~   Nr>   r?   r@   rA   r   r   rD   rE   rF   s   @r   HeaderCountingBufferr|      s      ( (r   r   rg   blahblahblahspamspamspamPOST/N)TF)Content-lengthHostzAccept-encoding)r   r   HTTPConnectionr   sock_bufferr   r   requestassertEqualr   r   )r   r   explicit_headerheaderconnbodyheaderss   &      r   test_auto_headersHeaderTests.test_auto_headers   s    
	(4 
	(  +OE,,];&~6	35%"&)#d)nGOVS$8  !3!3FLLN!CQG F  +r   c                    ! R  R\         4      pRpRp\        P                  ! W24       F  w  rE\        P                  ! R4      p\        R4      Vn        V! 4       Vn        VP                  VRV4       V P                  VP                  P                  RRP                  V4      4       K  	  RpV F~  p\        P                  ! R4      p\        R4      Vn        V! 4       Vn        VP                  VRR4       V P                  VP                  P                  RRP                  V4      4       K  	  V F~  p\        P                  ! R4      p\        R4      Vn        V! 4       Vn        VP                  VRR4       V P                  VP                  P                  RRP                  V4      4       K  	  \        P                  ! Ws4       F~  p\        P                  ! R4      p\        R4      Vn        V! 4       Vn        VP                  VRR	4       V P                  VP                  P                  R
RP                  V4      4       K  	  R# )c                   ,   a  ] tR t^t o R tR tRtV tR# )?HeaderTests.test_content_length_0.<locals>.ContentLengthCheckerc                >    \         P                  V 4       R V n        R # r4   )r   r   content_lengthr1   s   &r   r   HHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.__init__   s    d#&*#r   c                    VP                  R ^4      p\        V4      ^8  d9   V^ ,          P                  4       R8X  d   V^,          P                  4       V n        \
        P                  W4       R# )r   s   content-lengthN)r   r   r   stripr   r   r   )r   r   r   s   && r   r   FHeaderTests.test_content_length_0.<locals>.ContentLengthChecker.append   sM    ZZa(r7Q;2a5;;=4E#E*,Q%++-D'D'r   )r   Nr   rF   s   @r   ContentLengthCheckerr      s     +( (r   r   N rg   r      0z%Header Content-Length incorrect on {}z.Header Content-Length set for empty body on {}    1)Nr   )PUTr   PATCH)GETCONNECTDELETEHEADOPTIONSTRACE)r   	itertoolsproductr   r   r   r   r   r   r   r   formatchain)r   r   bodiesmethods_with_bodymethodr   r   methods_without_bodys   &       r   test_content_length_0!HeaderTests.test_content_length_0   s   	(4 	( 4%--.?HLF((7D"4(DI/1DLLLd+++T7>>vF I 
 +F((7D"4(DI/1DLLLd+++T@GGO + +F((7D"4(DI/1DLLLb)++T7>>vF +  oo&:NF((7D"4(DI/1DLLLc*++T7>>vF Or   c                   \         P                  ! R 4      p\        R4      Vn        VP	                  RR4       VP                  R^*4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  R	R
4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  RRR4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  RR4       V P                  RVP                  4       VP                  RR 4       V P                  R!VP                  4       VP                  R"R#4       V P                  R$VP                  4       VP                  R%R#4       V P                  R&VP                  4       VP                  R'R#4       V P                  R(VP                  4       VP                  R)R#4       V P                  R*VP                  4       R# )+rg   Nr   r   r   s   Content-length: 42Fooz bar s
   Foo:  bar Barz	baz	s
   Bar: 	baz	AuthorizationzBearer mytokens   Authorization: Bearer mytoken
IterHeaderIterAIterBs   IterHeader: IterA
	IterBLatinHeader   s   LatinHeader: 
Utf8Headers   Às   Utf8Header: Àz
C1-Controls	   nextlines   C1-Control: nextlinezEmbedded-Fold-Spacezis
 alloweds!   Embedded-Fold-Space: is
 allowedzEmbedded-Fold-Tabzis
	alloweds   Embedded-Fold-Tab: is
	allowedz	Key Spacer;   s   Key Space: valuez	KeySpace s   KeySpace : values   NonbreakSpaces   NonbreakSpace: values   NonbreakSpaces   NonbreakSpace: value)r   r   r   r   
putrequest	putheaderassertInr   r   r   s   & r   test_putheaderHeaderTests.test_putheader   s   $$]3t$	c"',+T\\:ug&mT\\2ui(ot||4(896E|Wg65t||D}g.*DLL9|[1-t||<|_514<<@,.>?<dllK*,=>;T\\J{G,)4<<8{G,)4<<8+W514<<@+W514<<@r   c                   R p\         P                  ! R4      p\        R4      pW2n        VP	                  RR4       V P                  VP                  V4       Rp\         P                  ! R4      p\        R4      pW2n        VP	                  RR4       V P                  VP                  V4       Rp\         P                  ! R4      p\        R4      pW2n        VP	                  RR4       V P                  VP                  V4       R	p\         P                  ! R
4      p\        R4      pW2n        VP	                  RR4       V P                  VP                  V4       R# )sC   GET /foo HTTP/1.1
Host: [2001::]:81
Accept-Encoding: identity

z[2001::]:81r   r   /foosE   GET /foo HTTP/1.1
Host: [2001:102A::]
Accept-Encoding: identity

z[2001:102A::]s@   GET /foo HTTP/1.1
Host: [fe80::]
Accept-Encoding: identity

z
[fe80::%2]sC   GET /foo HTTP/1.1
Host: [fe80::]:81
Accept-Encoding: identity

z[fe80::%2]:81N)r   r   r   r   r   assertStartsWithr   r   expectedr   r   s   &   r   test_ipv6host_header HeaderTests.test_ipv6host_header  s   8$$]3"~	UF#dii28$$_5"~	UF#dii28$$\2"~	UF#dii28$$_5"~	UF#dii2r   c                    R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  R4      R4       V P	                  VP                  R4      R4       R# )z4HTTP/1.1 200 OK
First: val
: nval
Second: val

FirstvalSecondN)r   r   HTTPResponsebeginr   	getheaderr   r   r   resps   &   r   !test_malformed_headers_coped_with-HeaderTests.test_malformed_headers_coped_with.  s\    O$""4(

0%8159r   c           	        R \        \        ^!^4      4      ,           R,           \        \        ^R4      4      ,           R,           p\        V4      p\        P                  ! V4      pVP                  4        V P                  VP                  R4      R4       V P                  VP                  R,          R4       V P                  VP                  R4      R4       V P                  VP                  R,          R4       RP                  \        \        \        ^!^4      4      4      pV P                  VP                  R4      V4       V P                  VP                  R,          V4       V P                  VP                  R	4      4       V P                  R	VP                  4       VP                  R
4      VP                  R
,          3 F9  pV P                  VR4       V P                  RV4       V P                  VR4       K;  	  R# )s0   HTTP/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!#$%&'*+-.^_`|~r;   r   VCHARzobs-textzobs-foldr   z folded with spacezfolded with tabN   )bytesranger   r   r   r   r   r   msgjoinmapchrassertIsNotNoner   r   assertEndsWith)r   r   r   r   vcharfoldeds   &     r   test_parse_all_octets!HeaderTests.test_parse_all_octets8  s   uT84569 "%h"789< 	 $""4(

(893?"23S9(9:GD"34g>CtX!6780%8'*E2T^^J78j$((+~~j1488J3GHF!!&&1MM.7(9: Ir   c           
        \         P                  ! R 4      p\        R4      Vn        VP	                  RR4       RpV F`  w  r4V P                  W434      ;_uu_ 4        V P                  \        R4      ;_uu_ 4        VP                  W44       RRR4       RRR4       Kb  	  R#   + '       g   i     L; i  + '       g   i     K  ; i)rg   r   r   r   zInvalid headerN))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   )	   ValidNames   Invalid
Value)r   s   InvalidValue)r   s   Invalid
Value)r   s   InvalidValue
)r   s   InvalidValue)r   s   InvalidValue
)	r   r   r   r   r   subTestassertRaisesRegex
ValueErrorr   )r   r   casesnamer;   s   &    r   test_invalid_headers HeaderTests.test_invalid_headersV  s    $$]3rN	s#
$ !KDtm,,++J8HIINN4/ J -, !II -,,s$   B6;B#B6#B3.B66Cc                   R p\        V4      p\        P                  ! V^R7      p\        P                  ! 4       ;_uu_ 4       pVP                  4        RRR4       XP                  4       P                  4       pV P                  V^ ,          R4       V P                  V^,          R4       V P                  V^,          R4       V P                  V^,          R4       R#   + '       g   i     L; i)s9   HTTP/1.1 200 OK
First: val
Second: val1
Second: val2
)
debuglevelNzreply: 'HTTP/1.1 200 OK\r\n'zheader: First: valzheader: Second: val1zheader: Second: val2)	r   r   r   r   captured_stdoutr   getvalue
splitlinesr   )r   r   r   r   outputliness   &     r   test_headers_debuglevel#HeaderTests.test_headers_debuglevelt  s      	 $""4A6$$&&&JJL '!,,.q#CDq#78q#9:q#9: '&s   C  C0	r5   N)r>   r?   r@   rA   r   r   r   r   r   r   r   r  rD   rE   rF   s   @r   ry   ry      s8     H:@D AD!3F:;<0<; ;r   ry   c                   &   a  ] tR tRt o R tRtV tR# )HttpMethodTestsi  c                   RpV Fc  pV P                  \        R4      ;_uu_ 4        \        P                  ! R4      p\	        R4      Vn        VP                  VRR7       RRR4       Ke  	  R#   + '       g   i     Kz  ; i)GETz'method can't contain control charactersrg   Nr   )r   url)	r
  zPOST
zPUT
z
POST
ValuezPOST
HOST:abczGET
rHost:abc
zPOSTRemainder:z
GETHOST:
z
PUT)r   r   r   r   r   r   r   )r   methodsr   r   s   &   r   test_invalid_method_names)HttpMethodTests.test_invalid_method_names  s{    

 F'' IK K,,];&t,	F4	K K K K Ks   :A..A?r5   N)r>   r?   r@   rA   r  rD   rE   rF   s   @r   r  r    s     5 5r   r  c                   R   a  ] tR tRt o RtR tR tR tR tRR lt	R t
R	 tR
tV tR# )TransferEncodingTest  s   It's just a flesh woundc                `   \         P                  ! R 4      p\        R4      Vn        VP	                  RR4       VP                  V P                  4       RR7       V P                  VP                  P                  4      w   r#V P                  V4      pV P                  W0P                  4       R# )rg   r   r   r   T)encode_chunkedN)r   r   r   r   r   
endheaders
_make_body_parse_requestr   _parse_chunkedr   expected_body)r   r   _r   s   &   r   test_endheaders_chunked,TransferEncodingTest.test_endheaders_chunked  s    $$]3sO	$)$?((8
1""4(112r   c                   \         P                  ! R 4      p\        R4      Vn        VP	                  RRV P                  4       RR/4       V P                  VP                  P                  4      w  r#pT P                  RVP                  4        Uu. uF  qUP                  4       NK  	  up4       V P                  VR,          R4       V P                  W@P                  4       \         P                  ! R 4      p\        R4      Vn        VP	                  RRV P                  P                  R4      RR/4       V P                  VP                  P                  4      w  r#pT P                  RVP                  4        Uu. uF  qUP                  4       NK  	  up4       V P                  VR,          R4       V P                  W@P                  4       \         P                  ! R 4      p\        R4      Vn        VP	                  RRRR/R	V P                  4       R
7       V P                  VP                  P                  4      w  r#pT P                  RV Uu. uF  qUP                  4       NK  	  up4       V P                  VR,          R4       V P                  V P                  V4      V P                  4       R# u upi u upi u upi )rg   r   r   r   Transfer-Encodingchunkedcontent-lengthlatin-1zgzip, chunkedT)r   r  r   N)r   r   r   r   r   r  r  r   assertNotInkeysr   r   r  r   r  r   r   r  r   r   ks   &     r   test_explicit_headers*TransferEncodingTest.test_explicit_headers  sD   $$]3sO	 	C*-@),L	N  ..tyy~~>D)w||~+N~!GGI~+NO!45yA112 $$]3sO	C++229= ),	.  ..tyy~~>D)w||~+N~!GGI~+NO!45yA112 $$]3sO	VS(/:" 	 	$  ..tyy~~>D)w+Gw!GGIw+GH!45G,,T2D4F4FG5 ,O ,O ,Hs   J;
?K 
K
c           	        R
 F  p\         P                  ! R4      p\        R4      Vn        VP	                  RRV P                  VR7      4       V P                  VP                  P                  4      w  r4pV P                  V4      pV P                  WPP                  4       V P                  VR,          R4       T P                  RV Uu. uF  qfP                  4       NK  	  up4       K  	  R	# u upi )Frg   r   r   r   )empty_linesr  r  r  N)FT)r   r   r   r   r   r  r  r   r  r   r  r!  r   )r   r(  r   r  r   r   r$  s   &      r   test_request!TransferEncodingTest.test_request  s    )K((7D"3DILLT___EG  $22499>>BA&&t,DT#5#56W%899E -7/K7a	7/KL * 0Ls   C1c                   \         P                  ! R 4      p\        R4      Vn        VP	                  RRR	4       V P                  VP                  P                  4      w  r#pV P                  VR,          R4       T P                  RV Uu. uF  qUP                  4       NK  	  up4       V P                  VR4       R# u upi )
rg   r   r   r   r  r  r  s   0

Nr5   )
r   r   r   r   r   r  r   r   r!  r   r#  s   &     r   test_empty_body$TransferEncodingTest.test_empty_body  s    $$]3sO	VS"%..tyy~~>D!45yA)w+Gw!GGIw+GH|, ,Hs   B>
c              #     "   V P                   P                  R 4      p\        V4       FH  w  r4V'       d   V^,          '       d   Rx  V\        V4      ^,
          8  d   VR ,           x  KD  Vx  KJ  	  R# 5i)    r   N)r  r   	enumerater   )r   r(  r  idxlines   &&   r   r  TransferEncodingTest._make_body  s[     ""((."5)ICsQww	SZ!^#Tk!
 *s   AA72A7c                   VP                  R 4      pV^ ,          p/ p^pV\        V4      8  d{   \        W%,          4      ^ 8  de   W%,          P                  R4      w  rgVP                  R4      P                  4       pVP                  R4      P                  4       WF&   V^,          pK  W4R P	                  W%^,           R 4      3# )   
r   r   N)r   r   r   r   r   )r   r   r  r   r   r[   keyr   s   &&      r   r  #TransferEncodingTest._parse_request  s    

7#(#e*nUX!2x~~d+HC**Y'--/C::i0668GLFAeEFm!<<<r   c                8   . p/ p^ pVP                  R4      p WTV^,            w  rg\        V^4      pV^ 8X  d   V^,          pMHV P                  V\        V4      4       VP	                  V4       V^,          pV\        V4      8  g   Kr   RP                  V4      # )r   r5  r   )r   intr   r   r   r   )r   r   r   trailersr[   r  sizechunks   &&      r   r  #TransferEncodingTest._parse_chunked  s    

7#!A#,KDtR=DqyQT3u:.KKFA 3u:~xx~r   r5   N)F)r>   r?   r@   rA   r  r  r%  r)  r,  r  r  r  rD   rE   rF   s   @r   r  r    s5     .M3$HLM -	= r   r  c                   ^  a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t R t!R  t"R! t#R" t$R# t%R$ t&R% t'R& t(R' t)R( t*R) t+R* t,R+ t-R, t.R- t/R. t0R/ t1R0 t2R1 t3R2 t4R3 t5R4 t6R5 t7R6 t8R7t9V t:R8# )9	BasicTesti  c           
     h    V P                  0 Rm\        \        \        R4      4      4      8*  4       R# )description  N>   r   r;   phraserA  )
assertTruesetdirr   r1   s   &r   &test_dir_with_added_behavior_on_status0BasicTest.test_dir_with_added_behavior_on_status  s#    Bc#jY\oJ^F__`r   c                n     ! R  R\         P                  4      p\         P                  ! V\        4       R# )c                     a  ] tR tRt o RtRR lt]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       tRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtRtR t R!t!R"t"R#t#R$t$R%t%R&t&R't'R(t(R)t)R*t*R+t+R,t,R-t-R.t.R/t/]/t0R0t1]1t2R1t3R2t4]4t5R3t6R4t7R5t8R6t9]9t:R7t;R8t<R9t=R:t>R;t?R<t@R=tAR>tBR?tCR@tDRAtERBtFRCtGRDtHREtIRFtJRGtKRHtLRItMR	tNV tOR
# )J;BasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatusi"  a  HTTP 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                T    \         P                  W4      pWn        W$n        W4n        V# r4   )r9  __new___value_rC  rA  )clsr;   rC  rA  objs   &&&& r   rM  CBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.__new__5  s$    kk#-##
"-
r   c                .    ^dT u;8*  ;'       d    ^8*  # u # )d   r5   r1   s   &r   is_informationalLBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_informational=      d))c))))r   c                .    ^T u;8*  ;'       d    R8*  # u #    i+  r5   r1   s   &r   
is_successFBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_successA  rV  r   c                .    R T u;8*  ;'       d    R8*  # u # ,  i  r5   r1   s   &r   is_redirectionJBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_redirectionE  rV  r   c                .    R T u;8*  ;'       d    R8*  # u #   i  r5   r1   s   &r   is_client_errorKBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_client_errorI  rV  r   c                .    R T u;8*  ;'       d    R8*  # u #   W  r5   r1   s   &r   is_server_errorKBasicTest.test_simple_httpstatus.<locals>.CheckedHTTPStatus.is_server_errorM  rV  r   r5   N)r   )rS  Continuez!Request received, please continue)e   zSwitching Protocolsz.Switching to new protocol; obey Upgrade header)f   
Processingz Server is processing the request)g   zEarly Hintsz(Headers sent to prepare for the response)rY  OKz#Request fulfilled, document follows)   CreatedzDocument created, URL follows)   Acceptedz/Request accepted, processing continues off-line)   zNon-Authoritative InformationzRequest fulfilled from cache)   z
No Contentz"Request fulfilled, nothing follows)   zReset Contentz"Clear input form for further input)   zPartial ContentzPartial content follows)   zMulti-Statusz/Response contains multiple statuses in the body)   zAlready Reportedz#Operation has already been reported)   zIM Usedz.Request completed using instance manipulations)r^  zMultiple Choicesz,Object has several resources -- see URI list)i-  zMoved 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)i0  zNot Modifiedz)Document has not changed since given time)i1  z	Use Proxyz@You must use proxy specified in Location to access this resource)i3  zTemporary Redirectr  )i4  zPermanent Redirectr}  )rc  zBad Requestz(Bad request syntax or unsupported method)  Unauthorizedz*No permission -- see authorization schemes)i  zPayment Requiredz"No payment -- see charging schemes)i  	Forbiddenz0Request forbidden -- authorization will not help)rB  	Not FoundzNothing matches the given URI)i  zMethod Not Allowedz-Specified method is invalid for this resource)i  zNot Acceptablez%URI not available in preferred format)i  zProxy Authentication Requiredz7You must authenticate with this proxy before proceeding)i  zRequest Timeoutz"Request timed out; try again later)i  ConflictzRequest conflict)i  Gonez5URI no longer exists and has been permanently removed)i  zLength Requiredz"Client must specify Content-Length)r  zPrecondition Failedz Precondition in headers is false)i  zContent Too LargezContent is too large)i  zURI Too LongzURI is too long)i  zUnsupported Media Typez!Entity body in unsupported format)i  zRange Not SatisfiablezCannot satisfy request range)i  zExpectation Failedz'Expect condition could not be satisfied)i  zI'm a Teapotz4Server refuses to brew coffee because it is a teapot)i  zMisdirected Requestz(Server is not able to produce a response)i  zUnprocessable Contentz8Server is not able to process the contained instructions)i  LockedzResource of a method is locked)i  zFailed Dependencyz&Dependent action of the request failed)i  z	Too Earlyz:Server refuses to process a request that might be replayed)i  zUpgrade Requiredz@Server refuses to perform the request using the current protocol)i  zPrecondition Requiredz8The origin server requires the request to be conditional)i  zToo Many RequestszOThe user has sent too many requests in a given amount of time ("rate limiting"))i  zRequest Header Fields Too LargezVThe server is unwilling to process the request because its header fields are too large)i  zUnavailable For Legal ReasonszOThe server is denying access to the resource as a consequence of a legal demand)rh  zInternal Server ErrorzServer got itself in trouble)i  zNot Implementedz&Server does not support this operation)i  zBad Gatewayz+Invalid responses from another server/proxy)i  zService Unavailablez8The server cannot process the request due to a high load)i  zGateway Timeoutz4The gateway server did not receive a timely response)i  zHTTP Version Not SupportedzCannot fulfill request)i  zVariant Also Negotiatesz*Server has an internal configuration error)i  zInsufficient Storagez.Server is not able to store the representation)i  zLoop Detectedz>Server encountered an infinite loop while processing a request)i  zNot Extendedz0Request does not meet the resource access policy)i  zNetwork Authentication Requiredz7The client needs to authenticate to gain network access)Pr>   r?   r@   rA   rc   rM  propertyrT  rZ  r_  rd  rj  CONTINUESWITCHING_PROTOCOLS
PROCESSINGEARLY_HINTSrq  CREATEDACCEPTEDNON_AUTHORITATIVE_INFORMATION
NO_CONTENTRESET_CONTENTPARTIAL_CONTENTMULTI_STATUSALREADY_REPORTEDIM_USEDMULTIPLE_CHOICESMOVED_PERMANENTLYFOUND	SEE_OTHERNOT_MODIFIED	USE_PROXYTEMPORARY_REDIRECTPERMANENT_REDIRECTBAD_REQUESTUNAUTHORIZEDPAYMENT_REQUIRED	FORBIDDEN	NOT_FOUNDMETHOD_NOT_ALLOWEDNOT_ACCEPTABLEPROXY_AUTHENTICATION_REQUIREDREQUEST_TIMEOUTCONFLICTGONELENGTH_REQUIREDPRECONDITION_FAILEDCONTENT_TOO_LARGEREQUEST_ENTITY_TOO_LARGEURI_TOO_LONGREQUEST_URI_TOO_LONGUNSUPPORTED_MEDIA_TYPERANGE_NOT_SATISFIABLEREQUESTED_RANGE_NOT_SATISFIABLEEXPECTATION_FAILEDIM_A_TEAPOTMISDIRECTED_REQUESTUNPROCESSABLE_CONTENTUNPROCESSABLE_ENTITYLOCKEDFAILED_DEPENDENCY	TOO_EARLYUPGRADE_REQUIREDPRECONDITION_REQUIREDTOO_MANY_REQUESTSREQUEST_HEADER_FIELDS_TOO_LARGEUNAVAILABLE_FOR_LEGAL_REASONSINTERNAL_SERVER_ERRORNOT_IMPLEMENTEDBAD_GATEWAYSERVICE_UNAVAILABLEGATEWAY_TIMEOUTHTTP_VERSION_NOT_SUPPORTEDVARIANT_ALSO_NEGOTIATESINSUFFICIENT_STORAGELOOP_DETECTEDNOT_EXTENDEDNETWORK_AUTHENTICATION_REQUIREDrD   rE   rF   s   @r   CheckedHTTPStatusrK  "  s^    $ * * * * * * * * * * LH#FNJ<K BBEGCH-Q)PJVMOOCL 7VG @!<LESI=LTI"<"<<K>L 6DI1I"A9N-K)6O:HID6O#4!('8$CL#/ &5"%0! /D+";HK#<%L!#8 DF!:NI T%L!!</(+-?)
%0!:O?K#LHO**&'>#$B RMDL/K+r   r  N)enumIntEnum_test_simple_enumr   )r   r  s   & r   test_simple_httpstatus BasicTest.test_simple_httpstatus!  s*    n	K n	K^ 	0*=r   c                    \         P                  P                  4        F'  pV P                  V^d4       V P	                  VR4       K)  	  R# )z1Checks that the statuses are in the 100-599 rangeri  N)r   __members__valuesassertGreaterEqualassertLessEqual)r   members   & r   test_httpstatus_rangeBasicTest.test_httpstatus_range  s=     !,,335F##FC0  - 6r   c                    Rp\         P                  P                  4        FQ  pV FH  w  w  r4p\        W%4      pY2u;8:  d   V8:  d   M MV P	                  V4       K7  V P                  V4       KJ  	  KS  	  R# )z:Checks that the statuses belong to the standard categoriesN)))rS     rT  )rX  rZ  )r]  r_  )rb  rd  )rg  rj  )r   r  r  getattrrD  assertFalse)r   
categoriesr  r   uppercategorycategory_indicators   &      r   test_httpstatus_category"BasicTest.test_httpstatus_category  sg    

 !,,335F,6(%,V%>"+e+OO$67$$%78 -7 6r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  ^ 4      R4       V P                  VP                  4       4       V P                  VP                  4       V P	                  VP                  4       R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       Rp\        V4      p\        P                  ! V4      pV P                  \        P                  VP                  4       R# )HTTP/1.1 200 Ok

Textr      TextzHTTP/1.1 400.100 Not Ok

TextN)r   r   r   r   r   rY   r  isclosedclosedrD  r+   assertRaisesBadStatusLiner   s   &   r   test_status_linesBasicTest.test_status_lines  s     -$""4(

1s+)%g.(%

$4$""4(&..

;r   c                h    \         P                  ! R 4      pV P                  \        V4      R4       R# )r   zBadStatusLine("''")N)r   r  r   repr)r   excs   & r   test_bad_status_reprBasicTest.test_bad_status_repr  s'    ""2&c$=>r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  ^4      R4       V P                  VP                  4       4       V P	                  VP                  ^4      R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# *HTTP/1.1 200 Ok
Content-Length: 4

Text   Te   xtNr   r   r   r   r   rY   r  r  rD  r  r+   r   s   &   r   test_partial_readsBasicTest.test_partial_reads  s     B$""4(

1u-)1u-(%

$r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  4       R4       V P                  VP                  4       4       V P	                  VP                  4       R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )z4HTTP/1.1 200 Ok
Content-Length: 13

Text
Anothers   Text
s   AnotherN)r   r   r   r   r   r^   r  r  rY   rD  r  r+   r   s   &   r   test_mixed_readsBasicTest.test_mixed_reads  s     N$""4(

+6)j1(%

$r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        \	        ^4      pVP                  V4      pV P                  V^4       V P                  \        V4      R4       V P                  VP                  4       4       VP                  V4      pV P                  V^4       V P                  \        V4      R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# r  r   r   r   r   	bytearrayreadintor   r   r  r  rD  r  r+   r   r   r   r   br[   s   &     r   test_partial_readintos BasicTest.test_partial_readintos#  s     B$""4(

aLMM!Aq5))MM!Aq5)(%

$r   c                x   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  ^
4      R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )r  r  Nr   r   r   r   r   rY   rD  r  r  r  r+   r   s   &   r   test_partial_reads_past_end%BasicTest.test_partial_reads_past_end7  s    A$""4(

20(%

$r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        \	        ^
4      pVP                  V4      pV P                  V^4       V P                  \        V4      R,          R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )r  :N   Nr  N)r   r   r   r   r  r  r   r   rD  r  r  r  r+   r  s   &     r   test_partial_readintos_past_end)BasicTest.test_partial_readintos_past_endC  s    A$""4(

bMMM!Aq"w/(%

$r   c                :   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  ^4      R4       V P                  VP                  4       4       V P	                  VP                  ^4      R4       V P	                  VP                  ^4      R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )r  r  r  r   Nr  r   s   &   r   $test_partial_reads_no_content_length.BasicTest.test_partial_reads_no_content_lengthR  s     -$""4(

1u-)1u-1s+(%

$r   c                <   R p\        V4      p\        P                  ! V4      pVP                  4        \	        ^4      pVP                  V4      pV P                  V^4       V P                  \        V4      R4       V P                  VP                  4       4       VP                  V4      pV P                  V^4       V P                  \        V4      R4       VP                  V4      pV P                  V^ 4       V P                  VP                  4       4       R# )r  r  r  N)r   r   r   r   r  r  r   r   r  r  rD  r  s   &     r   (test_partial_readintos_no_content_length2BasicTest.test_partial_readintos_no_content_lengthb  s     -$""4(

aLMM!Aq5))MM!Aq5)MM!A(r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  ^4      R4       V P                  VP                  4       4       V P	                  VP                  ^4      R4       V P	                  VP                  ^4      R4       V P                  VP                  4       4       R# )+HTTP/1.1 200 Ok
Content-Length: 10

Textr  r  r   N)	r   r   r   r   r   rY   r  r  rD  r   s   &   r   "test_partial_reads_incomplete_body,BasicTest.test_partial_reads_incomplete_bodyu  s     C$""4(

1u-)1u-1s+(r   c                   R p\        V4      p\        P                  ! V4      pVP                  4        \	        ^4      pVP                  V4      pV P                  V^4       V P                  \        V4      R4       V P                  VP                  4       4       VP                  V4      pV P                  V^4       V P                  \        V4      R4       VP                  V4      pV P                  V^ 4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )r  r  r  Nr  r  s   &     r   &test_partial_readintos_incomplete_body0BasicTest.test_partial_readintos_incomplete_body  s	    C$""4(

aLMM!Aq5))MM!Aq5)MM!A(%

$r   c                &   R F2  pV P                  \        P                  \        P                  V4       K4  	  R FR  w  rp\        P                  ! V4      pV P	                  W$P
                  4       V P	                  W4P                  4       KT  	  R# )www.python.org:abcNr  zuser:password@www.python.org)z[fe80::207:e9ff:fe9b]:8000fe80::207:e9ff:fe9bi@  )zwww.python.org:80www.python.orgP   )www.python.org:r  r  )r  r  r  )[fe80::207:e9ff:fe9b]r  r  )[fe80::207:e9ff:fe9b]:r  r  )r  r   
InvalidURLr   r   r   r   r   hphpcs   &    r   test_host_portBasicTest.test_host_port  sv     IBf//1F1FK IPHB1 %%b)AQ'Q'Pr   c                    R pRp\        V4      p\        P                  ! V4      pVP                  4        VP	                  R4      pV P                  WR4       R# )zHTTP/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-CookieN)r   r   r   r   r   r   )r   r   hdrsr&   cookiess   &     r   test_response_headersBasicTest.test_response_headers  sR    O t"		++l+&r   c                    \        R \        4      p\        P                  ! VRR7      pVP	                  4        VP                  4       '       d   V P                  R4       R# R# )*HTTP/1.1 200 OK
Content-Length: 14432

r   r   )Did not expect response from HEAD requestN)r   rV   r   r   r   rY   failr   r   r   s   &  r   test_read_headBasicTest.test_read_head  sR      	
 ""47

99;;IIAB r   c                   \        R \        4      p\        P                  ! VRR7      pVP	                  4        \        ^4      pVP                  V4      ^ 8w  d   V P                  R4       V P                  \        V4      R4       R# )r0  r   r1  r2  N        )
r   rV   r   r   r   r  r  r3  r   r   )r   r   r   r  s   &   r   test_readinto_headBasicTest.test_readinto_head  sp      	
 ""47

aL==q IIABq9-r   c                *   R P                  R \        \        P                  ^,           4       4       4      R ,           pRV,           p\	        V4      p\        P
                  ! V4      pV P                  \        P                  RVP                  4       R# )r   c              3   4   "   T F  pR V,          x  K  	  R# 5i)zHeader%d: fooNr5   ).0is   & r   	<genexpr>2BasicTest.test_too_many_headers.<locals>.<genexpr>  s       F'D! .11'Ds   zHTTP/1.1 200 OK
zgot more than \d+ headersN)	r   r   r   _MAXHEADERSr   r   r   HTTPExceptionr   )r   r   r   r+  r&   s   &    r   test_too_many_headersBasicTest.test_too_many_headers  s}    ++ F',V-?-?!-C'DF FHNO%/t"v33;QWW	Fr   c                    R p\        \        R4      ;_uu_ 4       p\        P                  ! R4      p\	        V4      pWCn        VP                  RRV4       V P                  VP                  V4       RRR4       R#   + '       g   i     R# ; i)s_   GET /foo HTTP/1.1
Host: example.com
Accept-Encoding: identity
Transfer-Encoding: chunked

r'   rg   r   r   N)	open__file__r   r   r   r   r   r   r   r   r   r   r   r   s   &    r   test_send_fileBasicTest.test_send_file  sl    
 (D!!T((7Dd#DILL-!!$))X6 "!!!s   AA<<B	c                   R p\         P                  ! R4      p\        R4      pW2n        VP	                  V4       V P                  WP                  4       RVn        VP	                  \        P                  ! RV4      4       V P                  WP                  4       RVn        VP	                  \        P                  ! V4      4       V P                  WP                  4       R# )s"   this is a test this is only a testrg   Nr   r  )
r   r   r   r   sendr   r   arrayrB   rC   r   s   &   r   	test_sendBasicTest.test_send  s    8$$]3$			(99-			%++c8,-99-			"**X&'99-r   c                   a R  o ! V3R lR\         P                  4      pRp\        P                  ! R4      p\	        R4      pWCn        VP                  V! 4       4       V P                  VP                  V4       R# )c               3   &   "   R x  Rx  Rx  R# 5i)r   Ndata_twor5   r5   r   r   r   /BasicTest.test_send_updating_file.<locals>.data  s     LJ   c                   @   <a  ] tR tRt o Rt Z! 4       tRR ltRtV tR# )7BasicTest.test_send_updating_file.<locals>.UpdatingFilei  r&   c                ,    \        V P                  4      # r4   )nextd)r   	blocksizes   &&r   rY   <BasicTest.test_send_updating_file.<locals>.UpdatingFile.read  s    DFF|#r   r5   Nra   )	r>   r?   r@   rA   r,   rY  rY   rD   rE   )rG   r   s   @r   UpdatingFilerV    s     DA$ $r   r\  s   datarg   r   N)	rB   
TextIOBaser   r   r   r   rL  r   r   )r   r\  r   r   r   r   s   &    @r   test_send_updating_file!BasicTest.test_send_updating_file  s_    	
	$2== 	$ $$]3"~			,.!H-r   c                    R pR p\         P                  ! R4      p\        R4      pWCn        VP	                  RRV! 4       RR/4       V P                  VP                  V4       R# )	sb   GET /foo HTTP/1.1
Host: example.com
Accept-Encoding: identity
Content-Length: 11

onetwothreec               3   &   "   R x  Rx  Rx  R# 5i)s   ones   twos   threeNr5   r5   r   r   r   &BasicTest.test_send_iter.<locals>.body  s     LLNrT  rg   r   r   r   r   11N)r   r   r   r   r   r   r   rH  s   &    r   test_send_iterBasicTest.test_send_iter  s\    &	
 $$]3"~	UFDF-=t,DEH-r   c                p   ^p\         P                  ! RVR7      p\        R4      pW2n        RV,          R,           pVP	                  RR\
        P                  ! V4      RR	/4       V P                  VP                  ^4       VP                  P                  R
^4      ^,          pV P                  WT4       R# )z8Check that request() respects the configured block size.rg   rZ  N   a   br   r   r   9   

)r   r   r   r   r   rB   rC   r   r   r   r   )r   rZ  r   r   r   r   s   &     r   test_blocksize_request BasicTest.test_blocksize_request   s    	$$]iH$	)#d*UCH!58H#7NO++Q/yy{A.q1(r   c                6   ^p\         P                  ! RVR7      p\        R4      pW2n        RV,          R,           pVP	                  \
        P                  ! V4      4       V P                  VP                  ^4       V P                  VP                  V4       R# )z5Check that send() respects the configured block size.rg   rg  Nrh  ri  )
r   r   r   r   rL  rB   rC   r   r   r   )r   rZ  r   r   r   s   &    r   test_blocksize_sendBasicTest.test_blocksize_send,  sv    	$$]iH$	)#d*		"**X&'++Q/H-r   c                    \         P                  ! R 4      p\        R4      Vn        V P	                  \
        4      ;_uu_ 4        VP                  RRV4       RRR4       R#   + '       g   i     R# ; i)rg   r   r   testN)r   r   r   r   r  	TypeErrorr   r   s   & r   test_send_type_errorBasicTest.test_send_type_error7  sM    $$]3rN	y))LL. *)))s   A""A3	c                    \         p\        \        \        ,           \        ,           4      p\
        P                  ! VR R7      pVP                  4        V P                  VP                  4       V4       VP                  4        R
 F  pV P                  RVR7      ;_uu_ 4        \        \        \        ,           \        ,           4      p\
        P                  ! VR R7      pVP                  4        V P                  VP                  4       V P                  VP                  V4      V4       VP                  4        RRR4       K  	  V P                  R4      ;_uu_ 4        \        \        \        ,           \        ,           4      p\
        P                  ! VR R7      pVP                  4        V P                  VP                  4       V P                  VP                  R	4      R4       VP                  4        RRR4       \        ^^4       F  p\        \        \        ,           \        ,           4      p\
        P                  ! VR R7      pVP                  4        V P                  VP                  V4      VP                  V4      ,           VP                  4       ,           V4       VP                  4        K  	  R Fs  p\        \        V,           4      p\
        P                  ! VR R7      pVP                  4         VP                  4        V P!                  R4       VP                  4        Ku  	  R#   + '       g   i     EK  ; i  + '       g   i     EL]; i  \
        P"                   do   pT P                  TP$                  T4       R\'        T4      ,          pT P                  \)        T4      T4       T P                  \+        T4      T4        Rp?LRp?ii ; i  TP                  4        i ; i)r   r1  Nz	full read)r[   z	read1(-1)s
   hello worlIncompleteRead expectedIncompleteRead(%d bytes read)rb   )irb   Nr   zfoo
)chunked_expectedr   chunked_start
last_chunkchunked_endr   r   r   r   rY   r+   r   rD  r  read1r   r3  IncompleteReadpartialr   r  r   )r   r   r   r   r[   xr>  expected_messages   &       r   test_chunkedBasicTest.test_chunked>  s   #-*4{BC""46

h/

 "AkQ//!-*"<{"JK**4>

-  1x8

 0/ " \\+&&mj8;FGD&&tE:DJJLOODLL)TZZ^];JJL ' q"Amj8;FGD&&tE:DJJLTYYq\DIIaL8499;FQJJL  !Ama/0D&&tE:DJJL
		 		34

 !3 0// '&&, (( ;  H5#BS]#R   a*:;  Q)9::	; 

sK   $BL<#BMM%O+<MM"	%O(:A$O#O+#O((O++O=c                j   \         p\        V4      p\        ^4      p\        \        \
        ,           \        ,           4      p\        P                  ! VRR7      pVP                  4        VP                  V4      pV P                  VRV V4       V P                  Wb4       VP                  4        \        ^^4       F  p\        \        \
        ,           \        ,           4      p\        P                  ! VRR7      pVP                  4        \        V4      pVP                  V^ V 4      pWP                  WxWh,            4      ,          pWP                  WxR 4      ,          pV P                  VRV V4       V P                  W4       VP                  4        K  	  R Ft  p	\        \        V	,           4      p\        P                  ! VRR7      pVP                  4         VP                  V4      pV P                  R4       VP                  4        Kv  	  R#   \        P                    do   pT P                  TP"                  T4       R\        T4      ,          p
T P                  \%        T4      T
4       T P                  \'        T4      T
4        Rp?LRp?ii ; i  TP                  4        i ; i)   r   r1  Nrw  rx  ry  )rz  r   r  r   r{  r|  r}  r   r   r   r  r   r+   r   
memoryviewr3  r  r  r  r   )r   r   	nexpectedr  r   r   r[   mr>  r  r  s   &          r   test_readinto_chunkedBasicTest.test_readinto_chunkedq  s   #M	cN-*4{BC""46

MM!:I1&

 q"Amj8;FGD&&tE:DJJL1Aa!f%Aq15z**Aqu%%AQz	]H5Q*JJL  !Ama/0D&&tE:DJJL
MM!$ 		34

 ! (( ;  H5#BS]#R   a*:;  Q)9::	; 

s1   "H3J J/A$JJ JJ  J2c                   R p\        V\        ,           \        ,           4      p\        P                  ! VRR7      pVP                  4        V P                  VP                  4       R4       V P                  VP                  ^4       V P                  VP                  R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )EHTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello world
1
d
r   r1  r   rq  N)r   r|  r}  r   r   r   r   rY   statusreasonrD  r  r  r  r+   )r   r{  r   r   s   &   r   test_chunked_headBasicTest.test_chunked_head  s     	 -*4{BC""47

c*c*d+(%

$r   c                h   R p\        V\        ,           \        ,           4      p\        P                  ! VRR7      pVP                  4        \        ^4      pVP                  V4      pV P                  V^ 4       V P                  \        V4      R4       V P                  VP                  ^4       V P                  VP                  R4       V P                  VP                  4       4       V P                  VP                  4       VP!                  4        V P                  VP                  4       R# )r  r   r1  rq  Nr8  )r   r|  r}  r   r   r   r  r  r   r   r  r  rD  r  r  r  r+   )r   r{  r   r   r  r[   s   &     r   test_readinto_chunked_head$BasicTest.test_readinto_chunked_head  s     	 -*4{BC""47

aLMM!Aq9-c*d+(%

$r   c                    \        R 4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  4       R4       V P                  VP                  4       4       R# )z.HTTP/1.1 200 OK
Content-Length: -1

Hello
r   r1     Hello
N)r   r   r   r   r   rY   rD  r  r4  s   &  r   test_negative_content_length&BasicTest.test_negative_content_length  sS    DF""46

l3(r   c                   \        R 4      p\        P                  ! VRR7      pVP                  4         VP	                  4        V P                  R4       R#   \        P                   d}   pT P                  TP                  R4       T P                  \        T4      R4       T P                  \        T4      R4       T P                  TP                  4       4        Rp?R# Rp?ii ; i)z.HTTP/1.1 200 OK
Content-Length: 10

Hello
r   r1  rw  r  z-IncompleteRead(7 bytes read, 3 more expected)N)r   r   r   r   rY   r3  r  r   r  r  r   rD  r  )r   r   r   r>  s   &   r   test_incomplete_readBasicTest.test_incomplete_read  s    RS""46


	1IIK II/0 $$ 	-QYY5T!WLNSVLNOODMMO,,	-s   A C)-A1C$$C)c                (  a \        R R4      p\        P                  ! R4      oVSn        V P	                  \
        V3R l4       SP                  4       pV P                  RVP                  4       V P                  RVP                  R4      4       R# )zgHTTP/1.0 401 Authorization Required
Content-type: text/html
WWW-Authenticate: Basic realm="example"
s   Content-Lengthrg   c                  *   < S P                  R RR4      # )r   /urlr   )r   )r   s   r   <lambda>&BasicTest.test_epipe.<locals>.<lambda>  s    $,,uff"Er   r  zBasic realm="example"zwww-authenticateN)
rI   r   r   r   r  rO   getresponser   r  r   )r   r   r   r   s   &  @r   
test_epipeBasicTest.test_epipe  s    < 	
 $$]3	'E	G!dkk*2(:;	=r   c                    R RR,          ,           R,           p\         P                  ! \        V4      4      pV P                  \         P                  \         P
                  3VP                  4       R# )HTTP/1.1 200 Okr$     r   N)r   r   r   r  LineTooLongr  r   r   r   r   s   &  r   test_overflowing_status_line&BasicTest.test_overflowing_status_line  sO     3;.7"":d#346--v/C/CDdjjQr   c                    R RR,          ,           R,           p\         P                  ! \        V4      4      pV P                  \         P                  VP
                  4       R# )zHTTP/1.1 200 OK
X-Foo: barr&   r  

N)r   r   r   r  r  r   r  s   &  r   test_overflowing_header_line&BasicTest.test_overflowing_header_line  sQ    ;')34 	 "":d#34&,,djj9r   c                   R R,          p\         P                  ! \        V4      4      pV P                  \         P                  4      ;_uu_ 4       pVP                  4        RRR4       V P                  R\        XP                  4      4       V P                  R\        VP                  4      4       R#   + '       g   i     L\; i)zHTTP/1.1 100 OK
r
i   Nzgot more than r   )	r   r   r   r  rB  r   r   r   	exception)r   r   r   cms   &   r   'test_overflowing_header_limit_after_1001BasicTest.test_overflowing_header_limit_after_100  s     	 "":d#34v3344JJL 5 	&BLL(9:iR\\!23 54s   B55C	c                    R RR,          ,           R,           p\         P                  ! \        V4      4      pVP                  4        V P	                  \         P
                  VP                  4       R# )z/HTTP/1.1 200 OK
Transfer-Encoding: chunked

r   r  za
hello world
0

N)r   r   r   r   r  r  rY   r  s   &  r   test_overflowing_chunked_line'BasicTest.test_overflowing_chunked_line
  s\    1Ek 	 "":d#34

&,,dii8r   c                v   R p\        V4      p\        P                  ! V4      pVP                  4        V P	                  VP                  4       R4       V P                  VP                  4       4       V P                  VP                  4       VP                  4        V P                  VP                  4       R# )r  r   Nr  r   s   &   r   test_early_eofBasicTest.test_early_eof  s}     $""4(

c*(%

$r   c                  a \         P                  ! R 4      pRo ! V3R lR\         P                  4      pW!n        \	        R4      Vn        VP                  RR4       V P                  \         P                  VP                  4       V P                  SP                  4       V P                  VP
                  P                  4       R# )rg   Nc                   .   <a  ] tR tRt o V3R ltRtV tR# )+BasicTest.test_error_leak.<locals>.Responsei'  c                T   < V o\         P                  P                  ! V .VO5/ VB  R # r4   )r   r   r   )r   rt   ru   responses   &*,r   r   4BasicTest.test_error_leak.<locals>.Response.__init__(  s&    ##,,T>C>2>r   r5   N)r>   r?   r@   rA   r   rD   rE   )rG   r  s   @r   Responser  '  s     ? ?r   r  zInvalid status liner   r   )r   r   r   response_classr   r   r   r  r  r  rD  r  r   )r   r   r  r  s   &  @r   test_error_leakBasicTest.test_error_leak#  s    $$]3	?v** 	?
 '45	UC &..0@0@A(		--.r   c                ,   Rp\         R,           p\        \        V,           \        ,           \        ,           4      p\
        P                  ! VRR7      pVP                  4        V P                  VP                  4       V4       VP                  4        R# )z3;foo=bar
s   abcr   r1  Nz3;foo=bar
abc
)rz  r   r{  last_chunk_extendedr}  r   r   r   r   rY   r+   )r   extrar   r   r   s   &    r   test_chunked_extension BasicTest.test_chunked_extension3  se    +#f,-%/2EEST""46

h/

r   c                    \         p\        \        \        ,           4      p\        P
                  ! VRR7      pVP                  4        V P                  VP                  4       V4       VP                  4        R# )z9some servers may serve up a short chunked encoding streamr   r1  N)
rz  r   r{  r|  r   r   r   r   rY   r+   r   r   r   r   s   &   r   test_chunked_missing_end"BasicTest.test_chunked_missing_end=  sP    #-*45""46

h/

r   c                v   \         p\        \        \        ,           \        ,           \
        ,           4      p\        P                  ! VRR7      pVP                  4        V P                  VP                  4       V4       V P                  VP                  P                  4       R4       VP                  4        R# )z&See that trailers are read and ignoredr   r1  r   N)rz  r   r{  r|  r:  r}  r   r   r   r   rY   r)   r+   r  s   &   r   test_chunked_trailersBasicTest.test_chunked_trailersF  su    #-*4x?+MN""46

h/)3/

r   c                   \         pRp\        \        \        ,           \        ,           \
        ,           V,           4      p\        P                  ! VRR7      pVP                  4        V P                  VP                  4       V4       V P                  VP                  P                  4       VP                  R4      4       VP                  4        R# )zDCheck that we don't read past the end of the chunked-encoding stream	extradatar   r1  r   N)rz  r   r{  r|  r:  r}  r   r   r   r   rY   r)   r   r+   )r   r   r  r   r   s   &    r   test_chunked_syncBasicTest.test_chunked_syncQ  s    #	-*4x?+MPYYZ""46

h/)9+;+;G+DE

r   c                D   RpRp\        RV,           V,           4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  4       V4       V P	                  VP                  P                  4       V4       VP                  4        R# )zBCheck that we don't read past the end of the Content-Length stream	   extradata
   Hello123
'   HTTP/1.1 200 OK
Content-Length: 10

r   r1  N)r   r   r   r   r   rY   r)   r+   r   r  r   r   r   s   &    r   test_content_length_sync"BasicTest.test_content_length_sync]  sw     	"JXUXaab""46

h/)95

r   c                H   R pRp\        RV,           V,           4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  R4      V.4       V P	                  VP                  P                  4       V4       VP                  4        R# r  r  r  r   r1  i  N)	r   r   r   r   r   	readlinesr)   rY   r+   r  s   &    r   test_readlines_content_length'BasicTest.test_readlines_content_lengthi  s|     	"JXUXaab""46

-z:)95

r   c                F   R pRp\        RV,           V,           4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  R4      V4       V P	                  VP                  P                  4       V4       VP                  4        R# r  )	r   r   r   r   r   r~  r)   rY   r+   r  s   &    r   test_read1_content_length#BasicTest.test_read1_content_lengtht  sz     	"JXUXaab""46

D)84)95

r   c                   R pRp\        RV,           V,           4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  ^
4      V4       V P	                  VP                  ^
4      R4       V P	                  VP                  P                  4       V4       VP                  4        R# )r  r  r  r   r1  r   N)	r   r   r   r   r   r^   r)   rY   r+   r  s   &    r   "test_readline_bound_content_length,BasicTest.test_readline_bound_content_length  s     	"JXUXaab""46

r*H5r*C0)95

r   c                   R pRp\        RV^,          ,           V,           4      p\        P                  ! VRR7      pVP                  4        V P	                  VP                  ^4      V^,          4       V P	                  VP                  4       V4       V P	                  VP                  P                  4       V4       VP                  4        R# )r  r  s'   HTTP/1.1 200 OK
Content-Length: 30

r   r1  N)	r   r   r   r   r   r~  rY   r)   r+   r  s   &    r   test_read1_bound_content_length)BasicTest.test_read1_bound_content_length  s     	"JXVWZWZccd""46

B!4h/)95

r   c                  aa \         P                  ! \        ^ 34      oV P                  SP                  4       RoVV3R lp\
        P                  ! VR7      pVP                  4        V P                  VP                  \        ^4      4       \        P                  ! SP                  4       !  pVP                  RR4       VP                  4       p V P                  VP                   \        P"                  4       \         P                   ! VP%                  4       R7      p VP'                  R4       VP)                  4         VP	                  4        VP	                  4        VP                  4        V P                  SR4       R#   TP)                  4        i ; i  TP	                  4        TP	                  4        i ; i)r   Nc            	      |  < SP                  4       w  rT ;_uu_ 4        V P                  R 4      ;_uu_ 4       p VP                  4       pVP                  R4      '       d   K*   T P	                  R4       TP                  4       oRRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r'   r5  s'   HTTP/1.1 200 Connection established

N)acceptr.   r^   rstripr#   rY   )r   addressreaderr2  resultservs       r   
run_server2BasicTest.test_response_fileno.<locals>.run_server  su    "kkmOTt}}T**f!??,D;;w//KL +**s(   B*&B	#"B	B*B'"B**B;	)targetr   z
dummy:1234)filenos   proxied data
)socketcreate_serverHOST
addCleanupr+   	threadingThreadstartr   floatr   r   getsocknamer   r  r   r  rq  r  r#   detach)r   r  threadr   r  r+  r  r  s   &     @@r   test_response_filenoBasicTest.test_response_fileno  s2   ##T1I.

#
	' !!4U1X.$$d&6&6&89Y-##%		X__fii8X__%67A		+,
NNJJL!23 
NNJJLs%   AF $F
 5F 
FF "Gc                     ! R R\         P                  4      pV! R4      p\        R4      Vn        VP	                  RR4       R# )z^
It should be possible to override the default validation
behavior in putrequest (bpo-38216).
c                   &   a  ] tR tRt o R tRtV tR# )RBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnectioni  c                    R # r4   r5   r   r  s   &&r   _validate_pathaBasicTest.test_putrequest_override_domain_validation.<locals>.UnsafeHTTPConnection._validate_path      r   r5   N)r>   r?   r@   rA   r  rD   rE   rF   s   @r   UnsafeHTTPConnectionr          r   r
  rg   r   r   z/ Nr   r   r   r   r   r   r
  r   s   &  r   *test_putrequest_override_domain_validation4BasicTest.test_putrequest_override_domain_validation  s9    
	6#8#8 	 $M2rN	w'r   c                     ! R  R\         P                  4      pV! R4      p\        R4      Vn        VP	                  RR^R7       R# )c                   &   a  ] tR tRt o R tRtV tR# )PBasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnectioni  c                    R # r4   r5   r  s   &&r   _validate_host_BasicTest.test_putrequest_override_host_validation.<locals>.UnsafeHTTPConnection._validate_host  r	  r   r5   N)r>   r?   r@   rA   r  rD   rE   rF   s   @r   r
  r    r  r   r
  zexample.com
r   r   r   )	skip_hostNr  r  s   &  r   (test_putrequest_override_host_validation2BasicTest.test_putrequest_override_host_validation  s@    	6#8#8 	 $$56rN	 	sa0r   c                     ! R R\         P                  4      pV! R4      p\        R4      Vn        VP	                  RR4       R# )z{
It should be possible to override the default encoding
to transmit bytes in another encoding even if invalid
(bpo-36274).
c                   &   a  ] tR tRt o R tRtV tR# )IBasicTest.test_putrequest_override_encoding.<locals>.UnsafeHTTPConnectioni  c                $    VP                  R 4      # )utf-8)r   )r   str_urls   &&r   _encode_requestYBasicTest.test_putrequest_override_encoding.<locals>.UnsafeHTTPConnection._encode_request  s    ~~g..r   r5   N)r>   r?   r@   rA   r  rD   rE   rF   s   @r   r
  r    s     / /r   r
  rg   r   r   u   /☃Nr  r  s   &  r   !test_putrequest_override_encoding+BasicTest.test_putrequest_override_encoding  s9    	/6#8#8 	/ $M2rN	v&r   r5   N);r>   r?   r@   rA   rG  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r'  r-  r5  r9  rC  rI  rN  r^  rd  rl  ro  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r!  rD   rE   rF   s   @r   r?  r?    s    ap>d.9$<*?%%%(
%%% )&)%,("'$C.F7..*. 
)	./1f)V%(%.)1 ="R
:49
%/ 	

		

#4J(	1' 'r   r?  c                      a  ] tR tRt o RtRt]]P                  R4      R P                  R4      tRt	R t
R	 tR
 tR tRR ltR tR tR tR tR tRtV tR# )ExtendedReadTesti  z"
Test peek(), read1(), readline()
zOHTTP/1.1 200 OK

hello world!
and now 
for something completely different
foohelloNr   HTTP/1.1 200 OK
Transfer-Encoding: chunked

a
hello worl
3
d!

9
and now 

23
for something completely different

3
foo
0

c                    \        V P                  4      p\        P                  ! VR R7      pVP	                  4        \
        P                  ! VP                  4      Vn        W n        R# )r   r1  N)	r   r  r   r   r   rB   BufferedReaderfpr   r4  s   &  r   setUpExtendedReadTest.setUp  sF    $**%""46

##DGG,	r   c                  a V P                   pVP                  P                  oRV3R llpW!P                  n        . p VP                  ^4      pV'       d   V P                  \	        V4      ^ 4       VP                  4       pV P                  \	        V4      \	        V4      4       V P                  WT4       VP                  \	        V4      4      pV P                  We4       M!VP                  4       pV P                  V4       VP                  V4       V'       d   K   T P                  RP                  T4      T P                  4       R# )r!   c                 >   < S! V 4      pV ^ 8  d   VRV  # VR,          # )r   N:N
   Nr5   )r[   r%  oldpeeks   & r   mypeek*ExtendedReadTest.test_peek.<locals>.mypeek  s'    
AAv!uS6Mr   r   Nra   )r   r)  peekassertGreaterr   r  r   rY   r   r  r   r   lines_expected)r   r   r0  allr%  p2rX  r/  s   &      @r   	test_peekExtendedReadTest.test_peek
  s    yy'',,	
 		!A""3q61-YY[''BQ8%%b,yyR)  *yy{  &JJt4#(;(;<r   c                ~    V P                   pV P                  V P                   P                  V P                  4       R # r4   )r   _verify_readliner^   r4  )r   r   s   & r   test_readlineExtendedReadTest.test_readline)  s+    yydii00$2E2EFr   c                j    V P                  V P                  P                  V P                  RR7       R# )r!   )limitNrb   )r:  r   r^   r4  r1   s   &r   test_readline_without_limit,ExtendedReadTest.test_readline_without_limit-  s'    dii00$2E2ERPr   c                J   . p V! V4      pV'       d*   VR8w  d#   \        V4      ^8  d   V P                  VR4       VP                  V4       V'       d   KU   T P                  RP	                  T4      T4       T P                  T P                  P                  4       4       R# )T   foo   
r   N)r   r   r   r   r   rD  r   r  )r   r^   r   r>  r5  r2  s   &&&&  r   r:  !ExtendedReadTest._verify_readline0  s|    E?Dt9q=''e4JJt4#1		**,-r   c                   a a S P                   oVV 3R  lp\        V4      pS P                  VP                  S P                  4       R# )c                  `   < SP                  ^4      p SP                  \        V 4      ^4       V # )r  )r~  r  r   )resr   r   s    r   r&   &ExtendedReadTest.test_read1.<locals>.r@  s)    **Q-C  S1-Jr   N)r   	Readlinerr:  r^   r4  )r   r&   	readlinerr   s   f  @r   
test_read1ExtendedReadTest.test_read1>  s8    yy	 aL	i00$2E2EFr   c                   V P                   p. p VP                  4       pV'       g   MVP                  V4       K-  V P                  RP	                  V4      V P
                  4       V P                  VP                  4       4       R# Tr   N)r   r~  r   r   r   r4  rD  r  r   r   r5  r   s   &   r   test_read1_unbounded%ExtendedReadTest.test_read1_unboundedG  s`    yy::<DJJt#(;(;<(r   c                H   V P                   p. p VP                  ^
4      pV'       g   M.V P                  \        V4      ^
4       VP	                  V4       KI  V P                  RP                  V4      V P                  4       V P                  VP                  4       4       R# rN  )
r   r~  r  r   r   r   r   r4  rD  r  rO  s   &   r   test_read1_bounded#ExtendedReadTest.test_read1_boundedR  sv    yy::b>D  TB/JJt#(;(;<(r   c                    V P                  V P                  P                  ^ 4      R4       V P                  V P                  P	                  4       4       R# )r   r   N)r   r   r~  r  r  r1   s   &r   test_read1_0ExtendedReadTest.test_read1_0^  s:    +S1++-.r   c                r    V P                   P                  ^ 4      pV P                  ^ \        V4      4       R# )r   N)r   r2  r  r   )r   r%  s   & r   test_peek_0ExtendedReadTest.test_peek_0b  s(    IINN1QA'r   r   )   )r>   r?   r@   rA   rc   r  findr   r4  lines_chunkedr*  r7  r;  r?  r:  rK  rP  rS  rV  rY  rD   rE   rF   s   @r   r$  r$    s{     	 
 5::g./077@N	 "=>GQ.G	)
)/( (r   r$  c                       ] tR tRt]P
                  P                  R^4      w  tt]R]	! ]4       R2,           ],           tRt
R# )"ExtendedReadTestContentLengthKnownig  r  z
Content-Length: r5   N)r>   r?   r@   rA   r$  r  r   _header_bodyr   rD   r5   r   r   r`  r`  g  s;    %++11*a@NGU,SZLAAEIEr   r`  c                       ] tR tRtRtRtRtR# )ExtendedReadTestChunkedil  z2
Test peek(), read1(), readline() in chunked mode
r&  r5   N)r>   r?   r@   rA   rc   r  rD   r5   r   r   rd  rd  l  s    	 
r   rd  c                   0   a  ] tR tRt o RtR tR tRtV tR# )rI  i  zL
a simple readline class that uses an arbitrary read function and buffering
c                     Wn         R V n        R# )r   Nreadfunc	remainder)r   rh  s   &&r   r   Readliner.__init__  s     r   c                   . p^ pV P                   p  VP                  R4      pVR8w  d   MTV\        V4      ,           V8  d   W,
          ^,
          pVP                  V4       V P	                  4       pV'       d   Kk  ^ p V^,          pVP                  VRV 4       WER V n         RP                  V4      #    RP                  T4      T n         h ; i)r   rC  Nr   rb   )ri  r]  r   r   rh  r   )r   r>  r   datalenrY   r1  s   &&    r   r^   Readliner.readline  s    ~~	ii&"9SY&%//A-CD!}}tC1HCKKTc
#!$ZDN88D>!	 XXd^DNs   A&B7 =9B7 7Crg  N)	r>   r?   r@   rA   rc   r   r^   rD   rE   rF   s   @r   rI  rI    s      r   rI  c                   2   a  ] tR tRt o R tR tR tRtV tR# )OfflineTesti  c                (   R 0pRR0p\        \        4       FW  pVP                  R4      '       g   W29   d   K"  \        \        V4      p\        VRR4      R8X  g   KF  VP	                  V4       KY  	  V P                  \        P                  V4       R# )	responsesHTTPMessageparse_headersr  r?   Nzhttp.client)rF  r   
startswithr  addassertCountEqual__all__)r   r   denylistr   module_objects   &    r   test_allOfflineTest.test_all  sy    = "?3KDs##t'7#FD1M}lD9]JT"   	fnnh7r   c                p    V P                  \        P                  \        P                  ,          R 4       R# )r  N)r   r   rq  r  r1   s   &r   test_responsesOfflineTest.test_responses  s#    ))&*:*:;[Ir   c                   . R NRNRNRNRNRNRNRNRNR	NR
NRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0NR1NR2NR3NR4NR5NR6NR7NR8NR9NR:NR;NR<NR=NpV F<  pV P                  VR>7      ;_uu_ 4        V P                  \        V4       R?R?R?4       K>  	  R?#   + '       g   i     KS  ; i)@r  r  r  rq  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  )constantN)r   assertHasAttrr   )r   r   consts   &  r   test_client_constants!OfflineTest.test_client_constants  s   ?
?
!?
 ?
 	?

 ?
 ?
 ,?
 ?
 ?
 ?
 ?
 ?
 ?
  ?
 ?
  !?
" #?
$ %?
& !'?
( )?
* +?
, -?
. /?
0 1?
2 !3?
4 5?
6 ,7?
8 9?
: ;?
< =?
> ??
@ "A?
B  C?
D 'E?
F G?
H #I?
J %K?
L $M?
N .O?
P !Q?
R S?
T "U?
V $W?
X #Y?
Z [?
\  ]?
^ _?
` $a?
b  c?
d .e?
f ,g?
h $i?
j k?
l m?
n "o?
p q?
r )s?
t #u?
v w?
x .y?
z {?
| }?
@ Eu--""651 .- ---s   CCr5   N)	r>   r?   r@   rA   rz  r}  r  rD   rE   rF   s   @r   ro  ro    s     8JD2 D2r   ro  c                   |   a  ] tR tRt o R tR tR t]P                  ! ]	! ]
R4      '       * R4      R 4       tRtV tR	# )
SourceAddressTesti  c                6   \         P                   ! \         P                  \         P                  4      V n        \        P
                  ! V P                  4      V n        \        P                  ! 4       V n        V P                  P                  4        R V n
        R # r4   )r  AF_INETSOCK_STREAMr  r   	bind_portr   find_unused_portsource_portlistenr   r1   s   &r   r*  SourceAddressTest.setUp  s\    MM&..&2D2DE	!++DII6	(99;			r   c                    V P                   '       d"   V P                   P                  4        R V n         V P                  P                  4        R V n        R # r4   )r   r+   r  r1   s   &r   tearDownSourceAddressTest.tearDown  s5    999IIOODI			r   c                4   \         P                  ! \        V P                  R V P                  3R7      V n        V P
                  P                  4        V P                  V P
                  P                  P                  4       ^,          V P                  4       R# r   )source_addressN)
r   r   r  r   r  r   rq   r   r   r  r1   s   &r   testHTTPConnectionSourceAddress1SourceAddressTest.testHTTPConnectionSourceAddress  sf    ))$		 "D$4$457			335a8$:J:JKr   HTTPSConnectionz'http.client.HTTPSConnection not definedc                v    \         P                  ! \        V P                  R V P                  3R7      V n        R# r  )r   r  r  r   r  r   r1   s   &r    testHTTPSConnectionSourceAddress2SourceAddressTest.testHTTPSConnectionSourceAddress  s,     **4 "D$4$457	r   )r   r   r  r  N)r>   r?   r@   rA   r*  r  r  unittestskipIfhasattrr   r  rD   rE   rF   s   @r   r  r    sD     L __):;;>@7@7r   r  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )TimeoutTesti  Nc                    \         P                   ! \         P                  \         P                  4      V n        \        P
                  ! V P                  4      \        n        V P                  P                  4        R # r4   )	r  r  r  r  r   r  r  PORTr  r1   s   &r   r*  TimeoutTest.setUp  sE    MM&..&2D2DE	(22499=		r   c                H    V P                   P                  4        R V n         R # r4   )r  r+   r1   s   &r   r  TimeoutTest.tearDown$  s    			r   c                p   V P                  \        P                  ! 4       4       \        P                  ! ^4        \        P
                  ! \        \        P                  4      pVP                  4        \        P                  ! R4       V P                  VP                  P                  4       ^4       VP                  4        V P                  \        P                  ! 4       4       \        P                  ! ^4        \        P
                  ! \        \        P                  RR7      pVP                  4        \        P                  ! R4       V P                  VP                  P                  4       R4       VP                  4        \        P
                  ! \        \        P                  ^R7      pVP                  4        V P                  VP                  P                  4       ^4       VP                  4        R#   \        P                  ! R4       i ; i  \        P                  ! R4       i ; i)   Ntimeout)assertIsNoner  getdefaulttimeoutsetdefaulttimeoutr   r   r  r  r  rq   r   r   
gettimeoutr+   )r   httpConns   & r   testTimeoutAttribute TimeoutTest.testTimeoutAttribute(  s   
 	&2245  $	+,,T;3C3CDH$$T*113R8 	&2245  $	+,,T;3C3C6:<H$$T*113T: (({/?/?L113R8) $$T* $$T*s   9H  ;H HH5)r  )
r>   r?   r@   rA   r  r*  r  r  rD   rE   rF   s   @r   r  r    s     D
 r   r  c                   2   a  ] tR tRt o R tR tR tRtV tR# )PersistenceTestiJ  c           
        RpV EF>  w  r#pV P                  W#R7      ;_uu_ 4        RP                  W#4      p\        V4      pV P                  VP                  4       VP                  RR4       VP                  4       ;_uu_ 4       pV P                  VP                  RJ V'       * 4       VP                  4        RRR4       V P                  VP                  RJ V'       * 4       V P                  VP                  ^4       VP                  RR4       T P                  VP                  V'       d   ^M^4       RRR4       EKA  	  R#   + '       g   i     L; i  + '       g   i     EKj  ; i)1.0)versionr   z4HTTP/{} 200 OK
{}Content-Length: 12

Dummy body
r   z/open-connectionNz/subsequent-request))r  r   F)r  zConnection: keep-alive
T)1.1r   T)r  zConnection: close
F)r  zConnection: keep-ALIVE
T)r  zConnection: cloSE
F)
r   r   re   r  r   r   r  r   rY   rh   )r   testsr  r   reuser   r   r  s   &       r   test_reuse_reconnect$PersistenceTest.test_reuse_reconnectL  s!   
 ',"GUg==%
 &)  04!!$)),U$67%%''8$$TYY$%6E	BMMO (   d!2I>  !1!115U$9:  !1!111E# >= ', (' >==s+   A"E4E
<A6E3E
EEE/c                   R  p\         P                  \        P                  3V\        33pV F  w  r4V P                  VR7      ;_uu_ 4        \        RV4      pVP                  RR4       V P                  WEP                  4       V P                  VP                  4       VP                  RR4       V P                  VP                  ^4       RRR4       K  	  R#   + '       g   i     K  ; i)c                v   a \         P                  ! V 4      oV3R lpVSn        \         P                  ! S4      # )z3Return BufferedReader that raises ECONNRESET at EOFc                 j   < \         P                  P                  SV 4      pV^ 8X  d   \        4       hV# )r   )rB   rC   r  ConnectionResetError)bufferr;  streams   & r   r  NPersistenceTest.test_disconnected.<locals>.make_reset_reader.<locals>.readintoo  s.    zz**66:19.00r   )rB   rC   r  r(  )r   r  r  s   & @r   make_reset_reader<PersistenceTest.test_disconnected.<locals>.make_reset_readerl  s0    ZZ%F
 'FO$$V,,r   )r  r   r   z/eof-response
/reconnectN)rB   rC   r   RemoteDisconnectedr  r   re   r   r  r  r  r   r   rh   )r   r  r  stream_factoryr  r   s   &     r   test_disconnected!PersistenceTest.test_disconnectedj  s    		- ZZ223 45
 */%N	22/^DUO4!!)-=-=>!!$)),UL1  !1!115 32 */222s   BCC/c                .   \        R 4      pVP                  RRRR/R7       V P                  \        P                  VP
                  4       V P                  VP                  4       VP                  RR4       V P                  VP                  ^4       R# )s   HTTP/1.1 100 Continue

r   r   Expectz100-continuer   r  N)
re   r   r  r   r  r  r  r   r   rh   r   s   & r   test_100_closePersistenceTest.test_100_close  s|    '

 	UC(N)CD&33T5E5EF$))$UL)))1-r   r5   N)	r>   r?   r@   rA   r  r  r  rD   rE   rF   s   @r   r  r  J  s     F<66
. 
.r   r  c                      a  ] tR tRt o R tR tR tR tR t]	P                  R 4       tR t]	P                  ! R	4      R
 4       tR tR tR t]P&                  ! ]! ]R4      '       * R4      R 4       tR tRtV tR# )	HTTPSTesti  c                X    \        \        R 4      '       g   V P                  R4       R# R# )r  zssl support requiredN)r  r   skipTestr1   s   &r   r*  HTTPSTest.setUp  s"    v011MM01 2r   c                     ^ RI Hp V! WR7      # )r   )make_https_server)certfile)test.ssl_serversr  )r   r  r  s   && r   make_serverHTTPSTest.make_server  s    6 99r   c                    \         P                  ! \        \        P                  ^R7      pV P                  VP                  ^4       R# )r  r  N)r   r  r  r  r  r   r  )r   r$  s   & r   test_attributesHTTPSTest.test_attributes  s0    ""4)9)92FB'r   c           	        ^ RI p\        P                  ! R4       \        P                  ! R4      ;_uu_ 4        \
        P                  ! RR4      pV P                  VP                  4      ;_uu_ 4       pVP                  RR4       RRR4       V P                  XP                  P                  R4       RRR4       R#   + '       g   i     L@; i  + '       g   i     R# ; i)r   Nnetworkself-signed.pythontest.net  r   r   CERTIFICATE_VERIFY_FAILED)sslr   requiresr   transient_internetr   r  r  SSLErrorr   r   r  r  )r   r  r$  exc_infos   &   r   test_networkedHTTPSTest.test_networked  s    #--.JKK&&'CSIA""3<<00H		%% 1X//668ST	 LK00 LKKs#   ;C4B?	.C?C
CC#	c                   ^ RI p\        P                  ! R4       \        P                  ! R4      ;_uu_ 4        VP                  4       p\        P                  ! RRVR7      pVP                  RR4       VP                  4       pVP                  4        V P                  RVP                  R	4      4       VP                  4        RRR4       R#   + '       g   i     R# ; i)
r   Nr  r  r  contextr   r   nginxserver)r  r   r  r   r  _create_unverified_contextr   r  r   r  r+   r   r   )r   r  r  r$  r   s   &    r   test_networked_noverification'HTTPSTest.test_networked_noverification  s    #--.JKK446G&&'CS/68AIIeS!==?DGGIMM'4>>(#;<JJL LKKKs   BCC!	c                   \         P                  ! R 4       \        P                  ! R4      ;_uu_ 4        \        P
                  ! RR4      pVP                  RR4       VP                  4       pVP                  R4      pVP                  4        VP                  4        V P                  RV4       RRR4       R#   + '       g   i     R# ; i)r  r  r  r   r   zcontent-typez	text/htmlN)r   r  r   r  r   r  r   r  r   r+   r   )r   r$  r   content_types   &   r   &test_networked_trusted_by_default_cert0HTTPSTest.test_networked_trusted_by_default_cert  s     	#--.>??&&'7=AIIeS!==?D>>.9LJJLGGIMM+|4 @???s   A=B<<C	c           
     T   ^ RI p\        P                  ! R4       Rp\        P                  ! V4      ;_uu_ 4        VP                  VP                  4      pV P                  VP                  VP                  4       V P                  VP                  R4       VP                  \        4        \        P                  ! VRVR7      pVP                  RR4       VP!                  4       pTP/                  R4      pTP1                  4        TP1                  4        T P3                  RT4       RRR4       R#   TP"                   dL   p\%        T4      p\&        P(                  ! R	T4      '       d   \*        P,                  ! R
T RT R24      hh Rp?ii ; i  + '       g   i     R# ; i)r   Nr  r  Tr  r  r   r   z(?i)key.too.weakzGot z trying to connect to z). See https://bugs.python.org/issue36816.r  r  )r  r   r  r   r  
SSLContextPROTOCOL_TLS_CLIENTr   verify_modeCERT_REQUIREDcheck_hostnameload_verify_locations CERT_selfsigned_pythontestdotnetr   r  r   r  r  r   researchr  SkipTestr   r+   r   )	r   r  selfsigned_pythontestdotnetr  r$  r   ssl_errssl_err_strserver_strings	   &        r   test_networked_good_cert"HTTPSTest.test_networked_good_cert  sg   #&B#--.IJJnnS%<%<=GW00#2C2CDW33T:))*JK**+F3:<		%%}} !NN84MJJLGGIMM'=15 KJ << !'l 990+>>"++{m ,9: ;BBC C  KJJs2   A3F/;D7*AF7FAFFFF'	walltimec           	     0   ^ RI p\        P                  ! R4       \        P                  ! R4      ;_uu_ 4        VP                  VP                  4      pVP                  \        4       \        P                  ! RRVR7      pV P                  VP                  4      ;_uu_ 4       pVP                  RR4       RRR4       V P                  XP                  P                   R4       RRR4       R#   + '       g   i     L@; i  + '       g   i     R# ; i)	r   Nr  r  r  r  r   r   r  )r  r   r  r   r  r  r  r  CERT_localhostr   r  r  r  r   r   r  r  )r   r  r  r$  r  s   &    r   test_networked_bad_cert!HTTPSTest.test_networked_bad_cert  s     	#--.JKKnnS%<%<=G)).9&&'CSRYZA""3<<00H		%% 1X//668ST LK 10	 LKKs$   A-D&C1	9.D1D<DD	c                h   ^ RI pV P                  \        4      p\        P                  ! RVP
                  4      pV P                  VP                  4      ;_uu_ 4       pVP                  RR4       RRR4       V P                  XP                  P                  R4       R#   + '       g   i     L8; i)r   N	localhostr   r   r  )r  r  r  r   r  r   r  r  r   r   r  r  )r   r  r  r$  r  s   &    r   test_local_unknown_cert!HTTPSTest.test_local_unknown_cert  s{    !!.1"";<s||,,IIeS! -++224OP -,s   B!!B1	c                   ^ RI pV P                  \        4      pVP                  VP                  4      pVP                  \        4       \        P                  ! RVP                  VR7      pV P                  VP                  4       VP                  RR4       VP                  4       pV P                  VP                  4       V P                  VP                  R4       R# )r   Nr
  r  r   /nonexistentrB  )r  r  r  r  r  r  r   r  r   r  r+   r   r  r   r  r   r  r  r  r$  r   s   &     r   test_local_good_hostname"HTTPSTest.test_local_good_hostname  s    !!.1..!8!89%%n5"";WM 			%(}}

#c*r   c                   ^ RI pV P                  \        4      pVP                  VP                  4      pVP                  \        4       \        P                  ! RVP                  VR7      pV P                  VP                  4      ;_uu_ 4        VP                  RR4       RRR4       RVn        \        P                  ! RVP                  VR7      pV P                  VP                  4      ;_uu_ 4        VP                  RR4       RRR4       RVn        \        P                  ! RVP                  VR7      pVP                  RR4       VP                  4       pVP                  4        VP                  4        V P                  VP                   R	4       R#   + '       g   i     EL; i  + '       g   i     L; i)
r   Nr
  r  r   r   TFr  rB  )r  r  CERT_fakehostnamer  r  r  r   r  r   r  CertificateErrorr   r  r  r+   r   r  r  s   &     r   test_local_bad_hostname!HTTPSTest.test_local_bad_hostname
  s=   !!"34..!8!89%%&78"";WMs3344IIeS! 5 "&"";WMs3344IIeS! 5 "'"";WM			%(}}

		c*! 544 54s   F8F1F.	1G	r  z)http.client.HTTPSConnection not availablec                &   R F2  pV P                  \        P                  \        P                  V4       K4  	  R FR  w  rp\        P                  ! V4      pV P	                  W$P
                  4       V P	                  W4P                  4       KT  	  R# )r  Nr  )r  )zwww.python.org:443r  r  )r  r  r  )r  r  r  )r  r  r  )r   r  r  )r  r   r!  r  r   r   r   r"  s   &    r   r'  HTTPSTest.test_host_port#  st    
 IBf//1G1GL I#HB1 &&r*AQ'Q'#r   c                   ^ RI pVP                  '       d   VP                  '       g   V P                  R4       \        P
                  ! RR4      pV P                  VP                  P                  4       VP                  VP                  4      pV P                  VP                  4       \        P
                  ! RRVR7      pV P                  VP                  V4       V P                  VP                  P                  4       VP                  VP                  \        R7      pRVn        \        P
                  ! RRVR7      pV P                  VP                  P                  4       R# )r   NzTLS 1.3 PHA support requiredr
  r  r  )	cert_fileT)r  HAS_TLSv1_3HAS_PHAr  r   r  rD  _contextpost_handshake_authr  r  r  assertIsr  )r   r  r$  r  s   &   r   test_tls13_phaHTTPSTest.test_tls13_pha7  s    ckkkMM89"";4

667..!8!89445"";WEajj'*778..!8!8N.S&*#"";WE

667r   r5   N)r>   r?   r@   rA   r*  r  r  r  r  r   system_must_validate_certr  r  requires_resourcer  r  r  r  r  r  r  r   r'  r   rD   rE   rF   s   @r   r  r    s     2:(
U &&
5 '
52B z*
U +
UQ++2 __):;;@B(B($8 8r   r  c                   Z   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )RequestBodyTestiK  z3Test cases where a request includes a message body.c                    \         P                  ! R 4      V n        \        R4      ;V P                  n        V n        V P                  V P                  n        R# )rg   r   N)r   r   r   r   r   r1   s   &r   r*  RequestBodyTest.setUpN  s9    ))-8	%/^3				r   c                    \         P                  ! V P                  P                  4      pVP	                  4        \
        P                  ! V4      pW!3# r4   )rB   rC   r   r   r^   r   rs  r   fmessages   &  r   get_headers_and_fp"RequestBodyTest.get_headers_and_fpS  s9    JJtyy~~&	

&&q)zr   c                8   R R.R3R3pV F  w  r#V P                  V4      ;_uu_ 4        \        P                  ! R4      V n        \	        R4      ;V P                  n        V n        V P                  P                  RRV4       V P                  4       w  rEV P                  RV4       V P                  RV4       V P                  VP                  R	4      R
4       V P                  W5P                  4       4       RRR4       K  	  R#   + '       g   i     EK  ; i)rB     bar   3
foo
3
bar
0

rg   r   r   r  zContent-Typer   r  r  N))rB  r/  r0  )r   r   r   r   r   r   r   r,  r!  r   getrY   )r   r   r   r   r   r*  s   &     r   test_list_bodyRequestBodyTest.test_list_bodyY  s    
 fCDD
 $NDd##"11-@	-7^;				!!%6002  5  !137  )<!=yI  6684 $# $###s   CDDc                    V P                   P                  R RRRR/4       V P                  4       w  rV P                  RVP	                  R4      4       V P                  ^\        VP                  4       4      4       R# )r   r  r   r   42r  N)r   r   r,  r   r1  r   rY   r   r+  r*  s   &  r   test_manual_content_length*RequestBodyTest.test_manual_content_lengthm  sh     			%+T2	4,,.
w{{+;<=CM*r   c                d   V P                   P                  R RR4       V P                  4       w  rV P                  RVP	                  4       4       V P                  VP                  4       4       V P                  RVP                  R4      4       V P                  RVP                  4       4       R# )r   r  r   
text/plain4r  s   bodyN	r   r   r,  r   get_content_typer  get_charsetr1  rY   r6  s   &  r   test_ascii_bodyRequestBodyTest.test_ascii_bodyv  s    		%0,,.
w'?'?'AB'--/0gkk*:;<!&&(+r   c                d   V P                   P                  R RR4       V P                  4       w  rV P                  RVP	                  4       4       V P                  VP                  4       4       V P                  RVP                  R4      4       V P                  RVP                  4       4       R# )r   r  u   bodyÁr:  5r     bodyNr<  r6  s   &  r   test_latin1_body RequestBodyTest.test_latin1_body~  s    		%4,,.
w'?'?'AB'--/0gkk*:;<affh/r   c                d   V P                   P                  R RR4       V P                  4       w  rV P                  RVP	                  4       4       V P                  VP                  4       4       V P                  RVP                  R4      4       V P                  RVP                  4       4       R# )r   r  rC  r:  rB  r  Nr<  r6  s   &  r   test_bytes_bodyRequestBodyTest.test_bytes_body  s    		%5,,.
w'?'?'AB'--/0gkk*:;<affh/r   c                $   V P                  \        P                  \        P                  4       \	        \        P                  R RR7      ;_uu_ 4       pVP                  R4       RRR4       \	        \        P                  RR7      ;_uu_ 4       pV P                  P                  RRV4       V P                  4       w  r!V P                  RVP                  4       4       V P                  VP                  4       4       V P                  VP                  R4      4       V P                  R	VP                  R
4      4       V P                  RVP                  4       4       RRR4       R#   + '       g   i     EL; i  + '       g   i     R# ; i)wr  )encodingr   Nr   r  r:  r  r  ztransfer-encodings   4
body
0

)r  r   unlinkTESTFNrF  writer   r   r,  r   r=  r  r>  r1  rY   r)  s   &  r   test_text_file_body#RequestBodyTest.test_text_file_body  s   	(()*:*:;)""C'::aGGFO ;)""W55IIeVQ/002JG\7+C+C+EFg1134 gkk*:;<Y4G(HI6A 65 ;::555s   E*CE>*E;	>F	c                    V P                  \        P                  \        P                  4       \	        \        P                  R 4      ;_uu_ 4       pVP                  R4       RRR4       \	        \        P                  R4      ;_uu_ 4       pV P                  P                  RRV4       V P                  4       w  r!V P                  RVP                  4       4       V P                  VP                  4       4       V P                  RVP                  R4      4       V P                  R	V4       V P                  R
VP                  4       4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)wbrC  Nr'   r   r  r:  r  r  r   s   5
body
0

)r  r   rL  rM  rF  rN  r   r   r,  r   r=  r  r>  r1  r!  rY   r)  s   &  r   test_binary_file_body%RequestBodyTest.test_binary_file_body  s
   	(()*:*:;)""D))QGGK  *)""D))QIIeVQ/002JG\7+C+C+EFg1134Y4G(HI-w7:AFFHE *) *))))s   ECE,E)	,E=	)r   r   N)r>   r?   r@   rA   rc   r*  r,  r2  r7  r?  rD  rG  rO  rS  rD   rE   rF   s   @r   r%  r%  K  s=     =#
5(+,00BF Fr   r%  c                   D   a  ] tR tRt o R tR tR tR tR tR t	Rt
V tR	# )
HTTPResponseTesti  c                    R p\        V4      p\        P                  ! V4      V n        V P                  P	                  4        R# )zXHTTP/1.1 200 Ok
My-Header: first-value
My-Header:                 second-value

TextN)r   r   r   r   r   )r   r   r   s   &  r   r*  HTTPResponseTest.setUp  s3    *$''-			r   c                    V P                   P                  R 4      pV P                  VR4       V P                   P                  R R4      pV P                  VR4       R# )z	My-Headerzfirst-value, second-valuezsome defaultNr   r   r   r   r   s   & r   test_getting_header$HTTPResponseTest.test_getting_header  sN    $$[1!<=$$[.A!<=r   c                b    V P                   P                  R R4      pV P                  VR4       R# )No-Such-Headerzdefault-valueNrZ  r[  s   & r   3test_getting_nonexistent_header_with_string_defaultDHTTPResponseTest.test_getting_nonexistent_header_with_string_default  s)    $$%5G1r   c                    V P                   P                  R RR.4      pV P                  VR4       V P                   P                  R R4      pV P                  VR4       R# )r_  defaultr  zdefault, valuesN)rc  r  rZ  r[  s   & r   5test_getting_nonexistent_header_with_iterable_defaultFHTTPResponseTest.test_getting_nonexistent_header_with_iterable_default  sX    $$%5	87LM!23$$%57LM!23r   c                `    V P                   P                  R 4      pV P                  VR4       R# )r_  NrZ  r[  s   & r   /test_getting_nonexistent_header_without_default@HTTPResponseTest.test_getting_nonexistent_header_without_default  s'    $$%56&r   c                d    V P                   P                  R ^*R7      pV P                  V^*4       R# )r_  )rc  NrZ  r[  s   & r   test_getting_header_defaultint/HTTPResponseTest.test_getting_header_defaultint  s,    $$%5b$A$r   r[  N)r>   r?   r@   rA   r*  r\  r`  rd  rg  rj  rD   rE   rF   s   @r   rV  rV    s(     >24'% %r   rV  c                      a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )TunnelTestsi  c                    R pRV n         \        P                  V n        \        P                  ! V P                   4      V n        V P                  V4      V P
                  n        R# )z:HTTP/1.1 200 OK

HTTP/1.1 200 OK
Content-Length: 42

z	proxy.comN)r   r   	HTTP_PORTr   r   r   rl   )r   response_texts   & r   r*  TunnelTests.setUp  sO    ) 	
  	$$	))$))4	'+'>'>}'M		$r   c                :    V P                   P                  4        R # r4   )r   r+   r1   s   &r   r  TunnelTests.tearDown  s    		r   c                   a RV3R llpV# )Nc                 <   < \        SV ^ ,          V ^,          R7      # )r   r   r   r   )r  r  r  rp  s   &&&r   rk   9TunnelTests._create_connection.<locals>.create_connection  s    m'!*71:NNr   NNr5   )r   rp  rk   s   &f r   rl   TunnelTests._create_connection  s    	O  r   c                   R pRpRR/pVP                  4       pRW3,          VR&   V P                  P                  WVR7       V P                  P                  RRR	4       V P	                  V P                  P
                  P                  V P                  4       V P	                  V P                  P
                  P                  V P                  4       V P	                  V P                  P                  V4       V P	                  V P                  P                  V4       V P	                  V P                  P                  V4       R
# )destination.com"  
User-Agent!Mozilla/5.0 (compatible, MSIE 11)%s:%dr   r   r   r   r   r   N)copyr   
set_tunnelr   r   r   r   r   _tunnel_host_tunnel_port_tunnel_headers)r   tunnel_hosttunnel_porttunnel_headerstunnel_headers_afters   &    r   2test_set_tunnel_host_port_headers_add_host_missing>TunnelTests.test_set_tunnel_host_port_headers_add_host_missing  s    '&(KL-224'.+1K'KV$		[%3 	 	5		&#r*,,dii8,,dii8//=//=224HIr   c                j   R pRpRRRRW3,          /pV P                   P                  WVR7       V P                   P                  RRR	4       V P                  V P                   P                  P
                  V P
                  4       V P                  V P                   P                  P                  V P                  4       V P                  V P                   P                  V4       V P                  V P                   P                  V4       V P                  V P                   P                  V4       R
# )r|  r}  r~  r  r   r  r  r   r   r   N
r   r  r   r   r   r   r   r  r  r  r   r  r  r  s   &   r   4test_set_tunnel_host_port_headers_set_host_identical@TunnelTests.test_set_tunnel_host_port_headers_set_host_identical  s    '&(K '[,F"FH		[%3 	 	5		&#r*,,dii8,,dii8//=//=22NCr   c                h   R pRpRRRRR,          /pV P                   P                  WVR7       V P                   P                  RRR	4       V P                  V P                   P                  P
                  V P
                  4       V P                  V P                   P                  P                  V P                  4       V P                  V P                   P                  V4       V P                  V P                   P                  V4       V P                  V P                   P                  V4       R
# )r|  r}  r~  r  r   r  r  r   r   r   N)rg   ih  r  r  s   &   r   4test_set_tunnel_host_port_headers_set_host_different@TunnelTests.test_set_tunnel_host_port_headers_set_host_different  s    '&(K ',A"AC		[%3 	 	5		&#r*,,dii8,,dii8//=//=22NCr   c                    V P                   P                  4        V P                  \        V P                   P                  R 4       R# )r|  N)r   rq   r  RuntimeErrorr  r1   s   &r   &test_disallow_set_tunnel_after_connect2TunnelTests.test_disallow_set_tunnel_after_connect	  s1    		,		(<(<+	-r   c                   R RR\         P                  /pV P                  P                  VR ,          P	                  R4      4       V P                  P                  RRR4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  V P                  4       V P                  RV,          V P                  P                  P                  4       V P                  RV,          V P                  P                  P                  4       R	# 
   host   destination.com   portr   r   r   r   ?   CONNECT %(host)s:%(port)d HTTP/1.1
Host: %(host)s:%(port)d

!   HEAD / HTTP/1.1
Host: %(host)s
Nr   ro  r   r  r   r   r   r   r   r   r   r   r   rY  s   & r   test_connect_with_tunnel$TunnelTests.test_connect_with_tunnel	      'V%%
 			QwZ..w78		&#r*,,dii8,,dii8 9;<=iinn))	+ 	>Biinn))	+r   c                   R RR\         P                  /pV P                  P                  VR ,          P	                  R4      VR,          R7       V P                  P                  RRR4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  V P                  4       V P                  RV,          V P                  P                  P                  4       V P                  R	V,          V P                  P                  P                  4       R
# )r  r  r  r   r   r   r   r   r  r  Nr  r  s   & r   *test_connect_with_tunnel_with_default_port6TunnelTests.test_connect_with_tunnel_with_default_port"	  s    'V%%
 			QwZ..w7ajI		&#r*,,dii8,,dii8 9;<=iinn))	+ 	>Biinn))	+r   c                   R RRR/pV P                   P                  VR ,          P                  R4      VR,          R7       V P                   P                  RRR4       V P	                  V P                   P
                  P                  V P                  4       V P	                  V P                   P
                  P                  V P                  4       V P                  R	V,          V P                   P
                  P                  4       V P                  R
V,          V P                   P
                  P                  4       R# )r  r  r  r}  r   r  r   r   r   r  s*   HEAD / HTTP/1.1
Host: %(host)s:%(port)d
N)
r   r  r   r   r   r   r   r   r   r   r  s   & r   .test_connect_with_tunnel_with_nonstandard_port:TunnelTests.test_connect_with_tunnel_with_nonstandard_port1	  s    'T
 			QwZ..w7ajI		&#r*,,dii8,,dii8 9;<=iinn))	+ 	G!Kiinn))	+r   c                   R RRRR\         P                  /pV P                  P                  VR ,          P	                  R4      RVR,          P	                  R4      /R7       V P                  P                  RR	R
4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  V P                  4       V P                  RV,          V P                  P                  P                  4       V P                  RV,          V P                  P                  P                  4       R# )r  r  s   tunnel_host_headers   example.com:9876r  r   r  r  r   r   r   sD   CONNECT %(host)s:%(port)d HTTP/1.1
HOST: %(tunnel_host_header)s

r  Nr  r  s   & r   3test_connect_with_tunnel_with_different_host_header?TunnelTests.test_connect_with_tunnel_with_different_host_headerC	  s   '!#6V%%

 			gJg&Q45<<WEF 	 	H 			&#r*,,dii8,,dii8 >@ABiinn))	+ 	>Biinn))	+r   c                   R RR\         P                  /pV P                  P                  VR ,          P	                  R4      4       V P                  P                  RRR4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  V P                  4       V P                  RV,          V P                  P                  P                  4       V P                  RV,          V P                  P                  P                  4       R	# r  r  r  s   & r   'test_connect_with_tunnel_different_host3TunnelTests.test_connect_with_tunnel_different_hostU	  r  r   c                ,   R pRVP                  R4      \        P                  3,          pRW"3,          pV P                  P	                  V4       V P                  P                  RRR4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  \        P                  4       V P                  W0P                  P                  P                  4       R# )u	   δπθ.grs   %s:%didnas!   CONNECT %s HTTP/1.1
Host: %s

r   r   r   N)r   r   ro  r   r  r   r   r   r   r   r   r   )r   dest	dest_portr   s   &   r   test_connect_with_tunnel_idna)TunnelTests.test_connect_with_tunnel_idnad	  s    &F 3V5E5EFF	=A" "		T"		&#r*,,dii8,,f.>.>?h		 3 34r   c                b   \         P                  P                  V P                  R4      ;_uu_ 4       pV P                  P	                  R4       V P                  P                  4        V P                  P                  RR4       RRR4       XP                  4        V P                  \        VP                  4      ^RVP                   2R7       VP                  ^ ,          ^,          ^ ,          pV P                  RV4       V P                  VR	R
V: 2R7       R#   + '       g   i     L; i)z8Regresstion test for https://bugs.python.org/issue43332.rL  r|  r   r   Nz!unexpected number of send calls: )r   s   CONNECT destination.comrk  zunexpected proxy data sent )r   patchobjectr   r  rq   r   assert_calledr3  r   
mock_callsr   r   )r   	mock_sendproxy_setup_data_sents   &  r   0test_tunnel_connect_single_send_connection_setup<TunnelTests.test_tunnel_connect_single_send_connection_setupo	  s    ZZtyy&11YII  !23IIIIeS) 2 	!I(()17	8L8L7MN 	 	P !* 4 4Q 7 :1 =02GH1;12G1JK 	 	M 21s   ADD.	c                   R RR\         P                  /pV P                  P                  VR ,          P	                  R4      4       V P                  P                  RRR4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  V P                  4       V P                  RV,          V P                  P                  P                  4       V P                  RV,          V P                  P                  P                  4       R	# )
r  r  r  r   r   r   r   r  s    PUT / HTTP/1.1
Host: %(host)s
Nr  r  s   & r   test_connect_put_request$TunnelTests.test_connect_put_request	  s    'V%%
 			QwZ..w78		%b),,dii8,,dii8 9;<=iinn))	+ 	=Aiinn))	+r   c                (   V P                   P                  R R4       V P                   P                  RRR4       V P                  V P                   P                  P
                  V P
                  4       V P                  V P                   P                  P                  \        P                  4       V P                  RV P                   P                  P                  4       V P                  RV P                   P                  P                  4       R# )z
[1:2:3::4]i  r   r   r      CONNECT [1:2:3::4]:1234   Host: [1:2:3::4]:1234Nr   r  r   r   r   r   r   r   ro  r   r   r1   s   &r   test_connect_put_request_ipv6)TunnelTests.test_connect_put_request_ipv6	  s    		\40		%b),,dii8,,f.>.>?0$))..2E2EF.		0C0CDr   c                &   V P                   P                  R 4       V P                   P                  RRR4       V P                  V P                   P                  P
                  V P
                  4       V P                  V P                   P                  P                  \        P                  4       V P                  RV P                   P                  P                  4       V P                  RV P                   P                  P                  4       R# )z[1:2:3::4]:1234r   r   r   r  r  Nr  r1   s   &r   "test_connect_put_request_ipv6_port.TunnelTests.test_connect_put_request_ipv6_port	  s    		./		%b),,dii8,,f.>.>?0$))..2E2EF.		0C0CDr   c                   R pRP                  V4      pV P                  P                  ^4       V P                  V4      V P                  n        V P                  P	                  R4       \
        P                  ! 4       ;_uu_ 4       pV P                  P                  RRR4       RRR4       XP                  4       P                  4       pV P                  RP                  V4      V4       R#   + '       g   i     LQ; i)z
X-Dummy: 1zHTTP/1.0 200 OK
{}

r|  r   r   r   Nz
header: {})r   r   set_debuglevelrl   r  r   r   r   r  r  r   )r   expected_headerrp  r  r  s   &    r   test_tunnel_debuglog TunnelTests.test_tunnel_debuglog	  s    &7>>O		  #'+'>'>}'M		$		./$$&&&IIeS"- '!,,.l))/:EB '&s   C..C>	c                l   RpRP                  RP                  V4      4      pV P                  V4      V P                  n        V P                  P	                  R4       V P                  P                  RRR4       V P                  P                  4       pV P                  WP                  4       4       R# )	X-DummyHTTP/1.0 200 OK
{0}

:r|  r   r   r   Nr  1)	r   r   rl   r   r  r   get_proxy_response_headersr   itemsr   r  rp  r   s   &   r   test_proxy_response_headers'TunnelTests.test_proxy_response_headers	  s    * &/!:; 	
 (,'>'>}'M		$		./		%b)))668o}}7r   c                   RpRP                  RP                  V4      4      pV P                  V4      V P                  n        V P                  P	                  RRR4       V P                  P                  4       pV P                  V4       R# )r  r  r  r   r   r   Nr  )r   r   rl   r   r   r  r  r  s   &   r   test_no_proxy_response_headers*TunnelTests.test_no_proxy_response_headers	  ss    * &/!:; 	
 (,'>'>}'M		$		%b)))668'"r   c                >  a R oRV3R llpWP                   n        V P                   P                  R4       R p V P                   P                  RRR4       V P                  V4       V P                  SP                  4       R #   \         d   pTp R p?L@R p?ii ; i)Nc                 @   < \        R V ^ ,          V ^,          R7      oS# )zHTTP/1.1 404 NOT FOUND

rv  rw  )r  r  r  r   s   &&&r   rl   8TunnelTests.test_tunnel_leak.<locals>._create_connection	  s%    0QZQZD
 Kr   r|  r   r   r   ry  )r   rl   r  r   rO   r   rD  r   )r   rl   r  er   s   &   @r   test_tunnel_leakTunnelTests.test_tunnel_leak	  s    	 (:		$		./	IIfc2. 	S!(()	  	C	s   B BBB)r   r   r   N)r>   r?   r@   rA   r*  r  rl   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rD   rE   rF   s   @r   rm  rm    s{     	N!
JDD-+++$+$+	5M +EEC8#* *r   rm  __main__)	verbosity)=r  rP   httpr   r   rB   r   osrM  r  r  r  r  r   TestCaserr  r   test.supportr   r   requires_working_socketpathdirnamerG  herer   r  r  r  r{  rz  chunk_extensionr|  r  r:  r}  r  r   rI   rC   rV   r   re   ry   r  r  r?  r$  r`  rd  rI  ro  r  r  r  r  r%  rV  rm  r>   mainr5   r   r   <module>r     s     # 	  	  	      " &   t ,	wwx dJ>GGLLz>B #%77<<*7$  	-  N 
O+f4 - B* 2:: $2v44 2"z;( z;z5h 5,}8 }@D' D'NA(x A(HJ)9 J
. , DV2( V2r7 7>+( +\E.h E.Pv8 v8r]Fh ]F@!%x !%FM*( M*` zMMA r   