+
    Bi,u                        ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RI Ht ^ RI	H
t
 ^ RIHt ^ RIHtHtHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIH t  ^ RI!H"t" ^ RI#t#^ RI$t$^ RI%t%^ RI&t&^ RI't'^ RI t  ! R R]4      t( ! R R]4      t)R t*R t+]*R3R lt,R t- ! R R]4      t. ! R R]4      t/ ! R R ]4      t0 ! R! R"]4      t1 ! R# R$]14      t2 ! R% R&]4      t3]4R'8X  d   ] Pj                  ! 4        R# R# )(    )mock)support)socket_helper)NoLogRequestHandler)TestCase)setup_testing_defaults)Headers)BaseHandlerBaseCGIHandlerSimpleHandler)util)	validator)
WSGIServerWSGIRequestHandler)make_server)HTTPConnection)StringIOBytesIOBufferedReader)
BaseServer)python_implementationNc                   ,   a  ] tR t^t o R tR tRtV tR# )
MockServerc                T    \         P                  ! WV4       V P                  4        R # N)r   __init__server_bind)selfserver_addressRequestHandlerClasss   &&&(/usr/lib/python3.14/test/test_wsgiref.pyr   MockServer.__init__   s    D2EF    c                Z    V P                   w  rWn        W n        V P                  4        R # r   )r   server_nameserver_portsetup_environ)r   hostports   &  r!   r   MockServer.server_bind!   s'    ((
r#   )r%   r&   N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r!   r   r      s      r#   r   c                   ,   a  ] tR t^(t o R tR tRtV tR# )MockHandlerc                Z    V P                   V n        V P                  w  V n        V n        R # r   )request
connectionrfilewfiler   s   &r!   setupMockHandler.setup*   s    ,,!%
DJr#   c                    R # r    r:   s   &r!   finishMockHandler.finish.   s    r#   )r7   r8   r9   N)r+   r,   r-   r.   r;   r?   r/   r0   r1   s   @r!   r4   r4   (   s     1 r#   r4   c                     V! R RR.4       R.# )200 OK   Hello, world!Content-Typez
text/plainDatezMon, 05 Jun 2006 18:49:54 GMTr>   environstart_responses   &&r!   	hello_apprK   2   s"    8%0  r#   c                     V! R RR.4       RP                  V R,          V R,          V R,          .4      P                  R4      .# )rB   ;HTTP_X_TEST_HEADERQUERY_STRING	PATH_INFO
iso-8859-1rD   rF   )joinencoderH   s   &&r!   
header_apprT   :   sX    8&1  HH$%w~'>  vl r#   s   GET / HTTP/1.0

c                 T   \        R ^PV \        \        4      p\        \	        V4      4      p\	        4       p\
        P                  p\        4       ;p\
        n         VP                  W43R4       V\
        n        VP                  4       VP                  4       3#   T\
        n        i ; i) )	127.0.0.1i"  )
r   r   r4   r   r   sysstderrr   finish_requestgetvalue)appdataserverinpoutolderrerrs   &&     r!   	run_amockrc   E   s    Rj+>F

'C
)CZZFz!C#*sj*<=
<<>3<<>)) 
s   B B'c                     V ! 4       p\        V4      VJ g   \        hV F  p\        V4      V8X  d   K  \        h	   \        V4       \        R V4      h  \         d     R# i ; i)zToo many items from .__next__()N)iterAssertionErrornextStopIteration)make_itmatchititems   &&  r!   compare_generic_iterrm   T   si     
B8r>Bx4   DR >CC  s   A A#"A#c                   f   a  ] tR t^it o RR l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# )IntegrationTestsc                   \        4       R ,           \        P                  P                  4       ^ ,          ,           pT P	                  TRV,           R,           T;'       d    R;'       g    R,           R,           P                  R4      4       R# )/z(HTTP/1.0 200 OK
Server: WSGIServer/0.2 zA
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
zContent-Length: 13
rV   z
Hello, world!rQ   N)r   rX   versionsplitassertEqualrS   )r   r`   
has_lengthpyvers   &&& r!   check_helloIntegrationTests.check_hellok   s    &(3.!!#A&'&(-.066 555;;	=
 $VL1	
r#   c                @    \        4       w  rV P                  V4       R # r   )rc   rw   r   r`   rb   s   &  r!   test_plain_hello!IntegrationTests.test_plain_hellox   s    ;r#   c                |    R p\        \        V4      w  r#V P                  VP                  4       R,          R4       R# )sm   GET /p%61th/?query=test HTTP/1.0
X-Test-Header: Python test 
X-Test-Header: Python test 2
Content-Length: 0

s+   Python test,Python test 2;query=test;/path/N)rc   rT   rt   
splitlines)r   r6   r`   rb   s   &   r!   test_environIntegrationTests.test_environ|   s<    % 	 Z1NNR :	
r#   c                    \        R RR,          ,           R,           R7      w  rV P                  VP                  4       ^ ,          R4       R# )s   GET    xi  s    HTTP/1.0

r]   s   HTTP/1.0 414 URI Too LongN)rc   rt   r   rz   s   &  r!   test_request_length$IntegrationTests.test_request_length   s<    'TE\":=M"MN)!,5	7r#   c                `    \        \        \        4      4      w  rV P                  VR R7       R# )F)ru   N)rc   r   rK   rw   rz   s   &  r!   test_validated_hello%IntegrationTests.test_validated_hello   s&    Yy12/r#   c                    R  p\        \        V4      4      w  r#V P                  VR4       V P                  VP	                  4       R,          R4       R# )c                     V! R R4       R.# )rB   zHello, world!rD   r>   rH   s   &&r!   bad_app>IntegrationTests.test_simple_validation_error.<locals>.bad_app   s    8%BC#$$r#   ;   A server error occurred.  Please contact the administrator.z^AssertionError: Headers (('Content-Type', 'text/plain')) must be of type list: <class 'tuple'>Nrc   r   assertEndsWithrt   r   r   r   r`   rb   s   &   r!   test_simple_validation_error-IntegrationTests.test_simple_validation_error   sQ    	% Yw/0CJ	
 	NNR 0	
r#   c                0   R  p. ROpV Ft  w  r4V P                  VR7      ;_uu_ 4        \        V! V4      4      w  rVV P                  VR4       V P                  VP	                  4       R,          V4       RRR4       Kv  	  R#   + '       g   i     K  ; i)c                    a  V 3R  lpV# )c                    < V! SR.4       R.# )rE   rC   rE   ztext/plain; charset=utf-8r>   )rI   rJ   statuss   &&r!   r   WIntegrationTests.test_status_validation_errors.<locals>.create_bad_app.<locals>.bad_app   s    v(U'VW())r#   r>   )r   r   s   f r!   create_bad_appFIntegrationTests.test_status_validation_errors.<locals>.create_bad_app   s    * Nr#   )r   r   N))200z4AssertionError: Status must be at least 4 characters)z20X OKz8AssertionError: Status message must begin w/3-digit code)200OKz;AssertionError: Status message must have a space after coder   )subTestrc   r   rt   r   )r   r   testsr   exc_messager`   rb   s   &      r!   test_status_validation_errors.IntegrationTests.test_status_validation_errors   s    	
 $)FV,,$^F%;<##CR   !1"!5{C -, $),,,s   ABBc                    R  p\        \        V4      4      w  r#V P                  VR4       V P                  VP	                  4       R,          R4       R# )c                 J    V R ,          P                  4        V! RR.4       R.# )
wsgi.inputrB      datar   )readess   &&r!   r   1IntegrationTests.test_wsgi_input.<locals>.bad_app   s(    lO  "hFGH9r#   r   rf   Nr   r   r   s   &   r!   test_wsgi_input IntegrationTests.test_wsgi_input   sO    	 Yw/0CJ	
 	NNR "2	
r#   c                V   R  p\        \        V4      4      w  r#V P                  VR4       \        P                  P                  4       ^ ,          P                  R4      p\        4       P                  R4      pVR,           V,           pV P                  RV,           R,           V4       R# )c                     V! R RR.4       R.# )rB   r   r   rG   zWed, 24 Dec 2008 13:29:32 GMTr>   r   s   &&r!   r\   3IntegrationTests.test_bytes_validation.<locals>.app   s!    h=9  9r#   z"GET / HTTP/1.0" 200 4
ascii   /s(   HTTP/1.0 200 OK
Server: WSGIServer/0.2 sV   
Content-Type: text/plain; charset=utf-8
Date: Wed, 24 Dec 2008 13:29:32 GMT

dataN)	rc   r   r   rX   rr   rs   rS   r   rt   )r   r\   r`   rb   verpyrv   s   &      r!   test_bytes_validation&IntegrationTests.test_bytes_validation   s    	 Ys^,C!;<kk!!$++G4#%,,W5T	C+,125 	r#   c                    R  p\        \        V4      RR7      w  r#V P                  R\        P                  RRRR.VP                  4       4       R# )	c                 J    V! R RR.4       V R,          P                  R4      .# )rB   rP   latin1rD   r   rS   r   s   &&r!   r\   -IntegrationTests.test_cp1252_url.<locals>.app   s1    h.9  kN))(344r#   s   GET /%80 HTTP/1.0r   s   HTTP/1.0 200 OKs   Content-Type: text/plains#   Date: Wed, 24 Dec 2008 13:29:32 GMTr#   s   /N)rc   r   rt   r   ANYr   )r   r\   r`   rb   s   &   r!   test_cp1252_url IntegrationTests.test_cp1252_url   sT    	5 cN!9;"+6 NN		r#   c                  aaa	a
a \         P                  ! \        R 4      o	R p ! R R\        \        4      p\        \        P                  ^ WR7      oV P                  SP                  4       \        P                  ! 4       oV3R lp\        P                  ! \        P                  V4      pV P                  \        P                  \        P                  V4       Ro
\        P                  ! 4       oVVV	V
V3R lp\        P                  ! VR7      pVP                  4        SP!                  4        VP#                  4        V P%                  S
\         P&                  ^d,
          4       R# )	pthread_killc                 D    V! R . 4       R\         P                  ,          .# )rB       )r   SOCK_MAX_SIZErH   s   &&r!   r\   4IntegrationTests.test_interrupted_write.<locals>.app   s     8R(G11122r#   c                       ] tR t^tRtR# )<IntegrationTests.test_interrupted_write.<locals>.WsgiHandlerr>   Nr+   r,   r-   r.   r/   r>   r#   r!   WsgiHandlerr          r#   r   )handler_classc                 (   < SP                  4        R # r   )set)signumframeinterrupteds   &&r!   signal_handler?IntegrationTests.test_interrupted_write.<locals>.signal_handler   s    OOr#   Nc                    < \        SP                  !  p V P                  R R4       V P                  4       ;_uu_ 4       pVP	                  ^d4        S! S\
        P                  4       SP                  \        ^4      R7      '       g   K;   \        TP	                  4       4      oRRR4       T P                  4        R#   + '       g   i     L"; i)GETrq   )timeoutN)r   r   r6   getresponser   signalSIGUSR1waitfloatlenclose)httpresponser   main_threadr   receivedr^   s     r!   
run_client;IntegrationTests.test_interrupted_write.<locals>.run_client  s    !6#8#89DLL$!!##xc"  fnn="''a'99x}}/ $ JJL $#s   AC C  C	)target)r   get_attributer   r   r   r   r   HOST
addCleanupserver_close	threadingEventr   	get_identThreadstarthandle_requestrR   rt   r   )r   r\   r   r   originalr   
backgroundr   r   r   r   r^   s   &      @@@@@r!   test_interrupted_write'IntegrationTests.test_interrupted_write   s     ,,V^D	3	-/A 	 ]//CS++,oo'	 ==@v~~x@))+	 	$ %%Z8
7#8#83#>?r#   r>   N)T)r+   r,   r-   r.   rw   r{   r   r   r   r   r   r   r   r   r   r/   r0   r1   s   @r!   ro   ro   i   sD     

7
0

D*
*./@ /@r#   ro   c                      a  ] tR tRt o R tRR ltR tR tRR l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# )UtilityTestsi!  c                    R VRV/p\         P                  ! V4       V P                  \         P                  ! V4      V4       V P                  VR,          V4       V P                  VR ,          V4       V# SCRIPT_NAMErP   )r   r   rt   shift_path_info)r   sn_inpi_inpartsn_outpi_outenvs   &&&&&& r!   
checkShiftUtilityTests.checkShift#  sh    U;u5##C(--c248[)&1]+F3
r#   Nc                   / p\         P                  ! V4       \        V\        4      '       d   V P	                  WA,          \        4       MK\        V\
        4      '       d   V P	                  WA,          \
        4       MV P                  WA,          V4       W/p\         P                  ! V4       V P                  WA,          V4       R # r   )r   r   
isinstancer   assertIsInstancer   rt   assertIs)r   keyvaluealtr   s   &&&& r!   checkDefaultUtilityTests.checkDefault+  s    ##C(eX&&!!#(H5g&&!!#(73SXu- i##C(ch$r#   c                b    \         P                  ! V4       V P                  W1,          V4       R # r   )r   r   rt   )r   r  r  kws   &&&,r!   checkCrossDefaultUtilityTests.checkCrossDefault;  s"    ##B''r#   c                ~    \         P                  ! V4       V P                  \         P                  ! V4      V4       R # r   )r   r   rt   application_uri)r   urir  s   &&,r!   checkAppURIUtilityTests.checkAppURI?  s+    ##B'--b1#6r#   c                ~    \         P                  ! V4       V P                  \         P                  ! W24      V4       R # r   )r   r   rt   request_uri)r   r  queryr  s   &&&,r!   checkReqURIUtilityTests.checkReqURIC  s+    ##B'))"3C8r#   c                F   W3R  lp\        WC4       V! 4       pV P                  VP                  P                  4       V F  pK  	  V P                  VP                  P                  4       VP	                  4        V P                  VP                  P                  4       R# )c                 B    \         P                  ! \        V 4      V4      # r   )r   FileWrapperr   )textsizes   &&r!   ri   %UtilityTests.checkFW.<locals>.make_itI  s    ##HTN488r#   N)rm   assertFalsefilelikeclosedr   
assertTrue)r   r  r  rj   ri   rk   rl   s   &&&&   r!   checkFWUtilityTests.checkFWG  sy     	9 	W+Y++,D  	++,

**+r#   c                    V P                  R RR RR 4       V P                  R RRRR 4       V P                  RR RRR 4       V P                  RRRRR4       V P                  RR	RRR4       R# )
rV   rq   z/xxN/az/x/yz/a/x/yz/x/r   r:   s   &r!   testSimpleShiftsUtilityTests.testSimpleShiftsY  sf    3C,4dB/Bc2.VS&$7US&#6r#   c                   V P                  R RRRR4       V P                  RRRRR4       V P                  R RRRR4       V P                  R R	RRR
4       V P                  R RRRR4       V P                  R RRRR
4       V P                  R RRRR4       V P                  R RRRR4       V P                  R RRRR4       V P                  R RRRR
4       V P                  R RRR R4       R# )z/a/bz/../yz..r&  r'  rV   z//yyz/a/b/yz//y/rq   z/./yz/./y/z///./..//y/.//z/y/z///z/a/b/z/.//z/x//r%  z/a/b/xz/.Nr(  r:   s   &r!   testNormalizedShifts!UtilityTests.testNormalizedShifts`  s    tT:GT2t4sHb9Xs;Xr:h< 0$eDr7B7GR8Xs;dFB7r#   c                    RRRRRR	R
RRRRR\        4       3R\        4       3R3 F  w  rV P                  W4       K  	  R# )SERVER_NAMEr   wsgi.errorsN)r0  rW   )SERVER_PORT80)SERVER_PROTOCOLHTTP/1.0)	HTTP_HOSTrW   )REQUEST_METHODr   )r   rV   )rP   rq   )wsgi.version   r   )wsgi.run_oncer   )wsgi.multithreadr   )wsgi.multiprocessr   )wsgi.url_schemer   )r   r   r  )r   r  r  s   &  r!   testDefaultsUtilityTests.testDefaultsm  sX    '!*%$# #$79%HJ'&
JC  c(!
r#   c                   V P                  R RRR7       V P                  RRRR7       V P                  RRRR7       V P                  RRRR7       V P                  RR	R
R7       V P                  RRR
R7       V P                  RRRR7       R# )r6  zfoo.barr0  r>  httpsonHTTPS1yesr   foor2  r3  443N)r  r:   s   &r!   testCrossDefaultsUtilityTests.testCrossDefaults  s    {9K0tD0sC0uE0eD}T>}U>r#   c                   V P                  \        P                  ! / 4      R 4       V P                  \        P                  ! RR/4      R 4       V P                  \        P                  ! RR/4      R4       V P                  \        P                  ! RR/4      R4       V P                  \        P                  ! RR/4      R4       R# )r   rF  rI  rD  rC  rH  rG  N)rt   r   guess_schemer:   s   &r!   testGuessSchemeUtilityTests.testGuessScheme  s    **2.7**GE?;VD**GD>:GD**GE?;WE**GC=97Cr#   c                8   V P                  R 4       V P                  RRR7       V P                  RRR7       V P                  RRRR	7       V P                  R
RR7       V P                  R RRR7       V P                  RRR7       V P                  RRRR7       R# )http://127.0.0.1/http://127.0.0.1/spam/spamr   http://127.0.0.1/sp%E4m   /spämzhttp://spam.example.com:2071/zspam.example.com:20712071)r6  r2  zhttp://spam.example.com/zspam.example.comrB  rW   )r6  r0  zhttps://127.0.0.1/rD  rE  zhttp://127.0.0.1:8000/8000N)r2  r6  )r  r:   s   &r!   testAppURIsUtilityTests.testAppURIs  s    ,-0gF2
K8-6 	 	C3* 	 	,,!/A 	 	C-T:1v 	 	r#   c                   V P                  R 4       V P                  RRR7       V P                  RRR7       V P                  RRRR7       V P                  R	RRR7       V P                  R
RRR7       V P                  RRRR7       V P                  RRRRR7       V P                  RRRRR7       V P                  R^ RRRR7       R# )rR  rS  rT  rU  rV  rW  zhttp://127.0.0.1/spammity/spamz	/spammityr   z http://127.0.0.1/spammity/sp%E4mz"http://127.0.0.1/spammity/spam;hamz	/spam;hamz/http://127.0.0.1/spammity/spam;cookie=1234,5678z/spam;cookie=1234,5678z%http://127.0.0.1/spammity/spam?say=nizsay=ni)r   rP   rO   z'http://127.0.0.1/spammity/spam?s%E4y=nizs%E4y=niN)r  r:   s   &r!   testReqURIsUtilityTests.testReqURIs  s   ,-0gF2
K9#w 	 	8;#z 	 	;=#{ 	 	<J#/G 	 	I@#wH 	 	NB#wJ 	 	P91#wH 	 	Nr#   c                0    V P                  R^xRR.4       R# )xyzNږxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz)r"  r:   s   &r!   testFileWrapperUtilityTests.testFileWrapper  s    XsXh$78r#   c                   R P                  4        F^  pWP                  4       VP                  4       VP                  4       3 F(  pV P	                  \
        P                  ! V4      4       K*  	  K`  	  RP                  4        F^  pWP                  4       VP                  4       VP                  4       3 F(  pV P                  \
        P                  ! V4      4       K*  	  K`  	  R# )zbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgradez4Accept Cache-Control Date Pragma Trailer Via WarningN)rs   titleupperlowerr!  r   is_hop_by_hopr  )r   hopr  s   &  r!   testHopByHopUtilityTests.testHopByHop  s    4
%'C IIKciikA 2 23 78 B	 C
%'C IIKciikA  !3!3C!89 Br#   r>   r   )r:  )r+   r,   r-   r.   r   r  r  r  r  r"  r)  r-  r?  rK  rO  rZ  r]  rd  rl  r/   r0   r1   s   @r!   r   r   !  sW     % (79,$78)&?DN&9: :r#   r   c                   2   a  ] tR tRt o R tR tR tRtV tR# )HeaderTestsi  c                   R.pV P                  \        \        4       4      ^ 4       V P                  \        \        . 4      4      ^ 4       V P                  \        \        VR,          4      4      ^4       V P                  \        VR,          4      P                  4       R .4       V P                  \        VR,          4      P	                  4       R.4       V P                  \        VR,          4      P                  4       V4       V P                  \        V4      P                  4       V4       \        4       pVR RVR&   VP                  VP                  VP                  VP                  3 F_  pV P                  V! R4      4       V P                  V! R4      4       V P                  V! R4      4       V P                  V! R4      4       Ka  	  V P                  VR,          R4       RVR&   V P                  VR,          R4       V P                  VP                  R4      R.4       V P                  VP                  RR4      R4       V P                  VP                  R	R4      R4       V P                  VP                  RR4      R4       V P                  VP                  R	R4      R4       V P                  VR,          R4       V P                  VR	,          R4       R
# )r%  r,  :NNNrI  barFooFOObazwheezooN)r%  r,  )rt   r   r	   keysvaluesitemsassertIsNot__contains__getget_all__getitem__r!  r  
setdefault)r   testhms   &   r!   testMappingInterface HeaderTests.testMappingInterface  s<   {WY+WR[)!,WT!W-.q1a)..03%8a)002SE:a)//148,,.5IeH%		1==@AOOAeH%OOAeH%OOAeH%QuX&	 A 	5%(%5%(5)5'2uV,e4uV,f5eF3U;eF3V<5%(5&)r#   c                <    V P                  \        \        R 4       R# )rI  N)assertRaises	TypeErrorr	   r:   s   &r!   testRequireListHeaderTests.testRequireList  s    )We4r#   c                   \        4       pV P                  \        V4      R 4       VP                  RRRR7       V P                  VR,          R4       V P                  \        V4      R4       VP                  RRRR	7       V P                  VP	                  R4      RR
.4       V P                  \        V4      R4       R# )z
rI  rq  spam)rt  zbar; baz="spam"zfoo: bar; baz="spam"

rr  N)cheesezbar; cheesez*foo: bar; baz="spam"
Foo: bar; cheese

)r	   rt   str
add_headerr}  r   r  s   & r!   
testExtrasHeaderTests.testExtras  s    IQ'	U5V,5#45Q >?	U5-5).	0 	Q	
r#   r>   N)	r+   r,   r-   r.   r  r  r  r/   r0   r1   s   @r!   ro  ro    s     *@5
 
r#   ro  c                   f   a  ] tR tRt o ]! ]P                  P                  4       4      tR t	Rt
V tR# )ErrorHandleri  c           
         \        V4       \        P                  ! V \        4       \        4       \	        4       VR R R7       R# )T)multithreadmultiprocessN)r   r   r   r   r   )r   r  s   &,r!   r   ErrorHandler.__init__  s.    r"')WY
B4	
r#   r>   N)r+   r,   r-   r.   dictosrI   ry  
os_environr   r/   r0   r1   s   @r!   r  r    s(      bjj&&()J
 
r#   r  c                   &   a  ] tR tRt o R tRtV tR# )TestHandleri	  c                    h r   r>   r:   s   &r!   handle_errorTestHandler.handle_error  s    r#   r>   N)r+   r,   r-   r.   r  r/   r0   r1   s   @r!   r  r  	  s      r#   r  c                   r   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V tR# )HandlerTestsi  c                   R RRRRRRRRR	/p\         P                  ! \        R
V4      ;_uu_ 4        \        RRR7      pVP                  4        RRR4       R F>  pV P	                  \        XRV,           4      VP                  RV,           ,          4       K@  	  / p\        V4       VP                  4        F  w  rVWT9  g   K  WdV&   K  	  VP                  RRR RRRRRRXP                  4       RVP                  4       RR RRRRRRRRR\        P                  /4       V P                  VP                  V4       R#   + '       g   i     L; i)!HOMEz/my/homePATHz/my/pathLANGzfr_FR.UTF-8r   test_script_namer0  test_server_namer  Yz/override/home)Xr  Nwsgi_zwsgi.r  rV   rW   r   r1  r8  r;  Fr>  r   r<  Tr=  zwsgi.file_wrapper)rr   r  r  run_oncefile_wrapperr9  )r   	swap_attrr  r'   rt   getattrrI   r   ry  update	get_stdin
get_stderrr   r  assertDictEqual)r   r  handlerattrexpectedr  r  s   &      r!   testEnvironHandlerTests.testEnviron  sU    JJM --	

 {L*EE!C.>?G!!# F%DWWgn=$__Wt^<>% x( %**,JC" % - 	$ 2; '++-7--/FUv!1!1%
 	( 	W__h7Q FEs   D>>E	c                    \        R R R / 4      pVP                  4        R F  pV P                  W!P                  4       K   	  R # )N)r>  r   r1  )r   r'   assertInrI   )r   r  r  s   &  r!   testCGIEnvironHandlerTests.testCGIEnvironJ  s7    4T"-	ACMM#yy) Br#   c                    \        R R7      qP                  4        V P                  VP                  R,          R4       \        4       qP                  4        V P                  VP                  R,          R4       R# )rD  rE  r>  rC  r   N)r  r'   rt   rI   r  s   & r!   
testSchemeHandlerTests.testSchemeP  sU    
D
!??#4#45g>
-*#45f=r#   c                    \        4       pR F"  pV P                  \        \        W4      4       K$  	  V P                  \        VP                  R4       R# )_flushr  N)r  r  r  add_cgi_vars)r
   r  NotImplementedErrorr  _write)r   r  names   &  r!   testAbstractMethods HandlerTests.testAbstractMethodsV  sE    M
D 171?C
 	-qxx@r#   c                   R  pR pR pR p\        4       pVP                  V4       V P                  VP                  P	                  4       RP                  R4      4       \        4       pVP                  V4       V P                  VP                  P	                  4       RP                  R4      4       \        4       pVP                  V4       V P                  VP                  P	                  4       R4       \        4       pVP                  V4       V P                  VP                  P	                  4       R4       R	# )
c                 F    V! R . 4       V R,          P                  R4      .# rB   r>  rQ   r   r   s   &&r!   trivial_app14HandlerTests.testContentLength.<locals>.trivial_app1a  s%    hrN'(//=>>r#   c                 P    V! R . 4      ! V R,          P                  R4      4       . # r  r   r   s   &&r!   trivial_app24HandlerTests.testContentLength.<locals>.trivial_app2e  s&    hrN1./66|DEIr#   c                 8    V! R . 4       RP                  R4      .# )rB   u   тестzutf-8r   r   s   &&r!   trivial_app34HandlerTests.testContentLength.<locals>.trivial_app3i  s    hrN.55g>??r#   c                     V! R R.4       . # )rB   )zContent-Length12345r>   r   s   &&r!   trivial_app44HandlerTests.testContentLength.<locals>.trivial_app4m  s    h345Ir#   z)Status: 200 OK
Content-Length: 4

httprQ   zStatus: 200 OK

https-   Status: 200 OK
Content-Length: 8

тестs)   Status: 200 OK
Content-Length: 12345

N)r  runrt   stdoutr[   rS   )r   r  r  r  r  r  s   &     r!   testContentLengthHandlerTests.testContentLength^  s	   	?		@	
 M	l**, F<(		* M	l**,F<(	*
 M	l**,0	1 M	l**,	r#   c                x   R  pR p\        4       pVP                  V4       V P                  VP                  P	                  4       RP                  R4      4       V P                  VP                  P	                  4       R4       \        4       pVP                  V4       V P                  VP                  P	                  4       RVP                  \        VP                  4      3,          P                  R4      VP                  ,           4       V P                  RVP                  P	                  4       4       R# )c                     V! R . 4       . # rB   r>   r   s   &&r!   non_error_app8HandlerTests.testBasicErrorOutput.<locals>.non_error_app      hrNIr#   c                     \        R 4      h) This should be caught by handlerrf   r   s   &&r!   	error_app4HandlerTests.testBasicErrorOutput.<locals>.error_app  s     !CDDr#   %Status: 200 OK
Content-Length: 0

rQ   rV   z<Status: %s
Content-Type: text/plain
Content-Length: %d

rf   N)r  r  rt   r  r[   rS   rY   error_statusr   
error_bodyr  )r   r  r  r  s   &   r!   testBasicErrorOutput!HandlerTests.testBasicErrorOutput  s    		E N	m**,F<(	* 	**,R0N	i**, nnS%678 :@9Mll		 	&(9(9(;<r#   c                "  a R oV3R lp\        4       pVP                  V4       V P                  VP                  P	                  4       RP                  R4      S,           4       V P                  RVP                  P	                  4       4       R# )   Some output has been sentc                 8   < V! R . 4      ! S4       \        R4      h)rB   r  r  )r   r   MSGs   &&r!   r  4HandlerTests.testErrorAfterOutput.<locals>.error_app  s    hrN3 !CDDr#   zStatus: 200 OK

rQ   rf   N)r  r  rt   r  r[   rS   r  rY   )r   r  r  r  s   &  @r!   testErrorAfterOutput!HandlerTests.testErrorAfterOutput  st    *	E N	i**,6,',	. 	&(9(9(;<r#   c           
     4   R  pRpRP                  R4      pR EFz  pT;'       d    RV,          ;'       g    RpR EFR  pR EFG  p\        VR7      pR	Vn        Whn        WHn        VP                  V4       V P                  W8P                  P                  4       4       \        VR7      pR
Vn        Whn        WHn        VP                  V4       VR8X  d-   V P                  VP                  P                  4       R4       K  V P                  \        P                  ! W&V3,          P                  R4      VP                  P                  4       4      W&V3,          P                  R4      VP                  P                  4       34       EKJ  	  EKU  	  EK}  	  R# )c                     V! R . 4       . # r  r>   r   s   &&r!   r  5HandlerTests.testHeaderFormats.<locals>.non_error_app  r  r#   zfHTTP/%s 200 OK\r\nDate: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n%sContent-Length: 0\r\n\r\nr  rQ   NzServer: %s
rV   HTTP/0.9)r4  FTr#   )z
FooBar/1.0N)z1.0z1.1)r  r5  zHTTP/1.1)rS   r  origin_serverhttp_versionserver_softwarer  rt   r  r[   r!  rerj   )	r   r  stdpatshortpatsswswrr   protor  s	   &        r!   testHeaderFormatsHandlerTests.testHeaderFormats  sX   	
3 	 @
&
 	 &C//)C/552B'?E#E:A&+AO%,N(+%EE-($$Xhh.?.?.AB#E:A&*AO%,N(+%EE-(j((():):)<SAHHfb\&9%A%A,%O ! 1 1 35$b\199,G ! 1 1 35# @ ( &r#   c                    R  p\        4       pVP                  V4       V P                  RVP                  P	                  4       4       R# )c                     V! R R.4       R.# )rB   r   r   r>   r   s   &&r!   r\   'HandlerTests.testBytesData.<locals>.app  s    h=  9r#   sR   Status: 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4

dataN)r  r  rt   r  r[   )r   r\   r  s   &  r!   testBytesDataHandlerTests.testBytesData  s@    	 M	c
 
 HH	!r#   c                   aa R R/oRoVV3R lp\        4       pVP                  V4       V P                  SR ,          R4       R# )close_calledFr  c                 T   < V! R . 4      ! S4        ! V3R lR\         4      pV! 4       # )rB   c                   4   <a  ] tR tRt o R tV3R ltRtV tR# )HHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterablei  c              3  *   "    Rx  \        R4      h5i)Ts   blahr  r  r:   s   &r!   __iter__QHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.__iter__  s     %,-OPPs   c                   < R SR&   R# )Tr  Nr>   )r   side_effectss   &r!   r   NHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.close  s    37L0r#   r>   N)r+   r,   r-   r.   r  r   r/   r0   )r2   r  s   @r!   CrashyIterabler	    s     Q8 8r#   r  )object)r   r   r  r  r  s   && r!   r  0HandlerTests.testCloseOnError.<locals>.error_app  s(    hrN38 8 "##r#   TN)r  r  rt   )r   r  r  r  r  s   &  @@r!   testCloseOnErrorHandlerTests.testCloseOnError  sA    &.*		$ N	in5t<r#   c                V  a \        4       o ! V3R  lR4      pRR/p\        \        4       V! 4       \        P                  V4      pRpV P                  \        V4      ;_uu_ 4        VP                  \        4       RRR4       V P                  RS4       R#   + '       g   i     L$; i)c                   4   <a  ] tR tRt o V3R ltR tRtV tR# )4HandlerTests.testPartialWrite.<locals>.PartialWriteri	  c                N   < VR ,          pSP                  V4       \        V4      # ):N   N)extendr   )r   bpartialwrittens   && r!   write:HandlerTests.testPartialWrite.<locals>.PartialWriter.write
  s"    B%w'7|#r#   c                    R # r   r>   r:   s   &r!   flush:HandlerTests.testPartialWrite.<locals>.PartialWriter.flush  s    r#   r>   N)r+   r,   r-   r.   r  r!  r/   r0   )r2   r  s   @r!   PartialWriterr  	  s     $
 r#   r#  r4  r5  zshould not do partial writesNss   HTTP/1.0 200 OK
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
Content-Length: 13

Hello, world!)
	bytearrayr   r   rX   rY   assertWarnsRegexDeprecationWarningr  rK   rt   )r   r#  rI   r  msgr  s   &    @r!   testPartialWriteHandlerTests.testPartialWrite  s    +	 	 %j1')]_cjj'J,""#5s;;EE) <  	 <;s   &BB(	c           	     x  a R R/p\         \        \        3 F  oV P                  SR7      ;_uu_ 4         ! V3R lR4      p\	        4       p\        \        4       V! 4       W14      pVP                  \        4       V P                  VP                  4       4       RRR4       K  	  R#   + '       g   i     K  ; i)r4  r5  )	exceptionc                   .   <a  ] tR tRt o V3R ltRtV tR# )EHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriteri'  c                   < Shr   r>   )r   r  r+  s   &&r!   r  KHandlerTests.testClientConnectionTerminations.<locals>.AbortingWriter.write(  s    'r#   r>   Nr+   r,   r-   r.   r  r/   r0   )r2   r+  s   @r!   AbortingWriterr-  '  s     ( (r#   r1  N)ConnectionAbortedErrorBrokenPipeErrorConnectionResetErrorr   r   r   r   r  rK   r  r[   )r   rI   r1  rY   r  r+  s   &    @r!    testClientConnectionTerminations-HandlerTests.testClientConnectionTerminations  s    $j1" 
I
 	22( ( "!')^-=vOi   !23 32

 322s   A&B((B9c                  a  ! R  R\         4      o ! V3R lR4      p\        4       pRR/p\        \        4       V! 4       W#4      pVP	                  \
        4       V P                  RVP                  4       4       V P                  VP                  4       V P                  VP                  4       V P                  VP                  4       V P                  VP                  4       R# )c                       ] tR tRtRtR# )KHandlerTests.testDontResetInternalStateOnException.<locals>.CustomExceptioni2  r>   Nr   r>   r#   r!   CustomExceptionr9  2  r   r#   r:  c                   .   <a  ] tR tRt o V3R ltRtV tR# )JHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWriteri9  c                   < Shr   r>   )r   r  r:  s   &&r!   r  PHandlerTests.testDontResetInternalStateOnException.<locals>.AbortingWriter.write:  s	    %%r#   r>   Nr0  )r2   r:  s   @r!   r1  r<  9  s     & &r#   r1  r4  r5  N)
ValueErrorr   r   r   r  rK   r  r[   assertIsNotNoneresultheadersr   rI   )r   r1  rY   rI   r  r:  s   &    @r!   %testDontResetInternalStateOnException2HandlerTests.testDontResetInternalStateOnException1  s    	j 		& 	& $j1')^%5vG	i'):; 	QXX&QYY'QXX&QYY'r#   r>   Ni  )r+   r,   r-   r.   maxDiffr  r  r  r  r  r  r  r  r  r  r(  r5  rC  r/   r0   r1   s   @r!   r  r    sT     G48l*>A0d=8=)V! =$24$( (r#   r  __main__)6unittestr   r  r   test.supportr   test.test_httpserversr   r   wsgiref.utilr   wsgiref.headersr	   wsgiref.handlersr
   r   r   wsgirefr   wsgiref.validater   wsgiref.simple_serverr   r   r   http.clientr   ior   r   r   socketserverr   platformr   r  r  r   rX   r   r   r4   rK   rT   rc   rm   ro   r   ro  r  r  r  r+   mainr>   r#   r!   <module>rU     s      & 5  / # G G  & @ - & 0 0 # * 	 	  
   $  "7 *D*u@x u@p`:8 `:D5
( 5
n
> 
, x(8 x(v	 zMMO r#   