+
    üÐj;  ã                   óÒ  € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ R	IHt ^ R
IH t H!t! Rt"Rt#Rt$Rt%Rt&Rt'Rt(Rt)Rt* ! R R]PV                  4      t, ! R R4      t- ! R R]-]P\                  4      t/ ! R R]-]P\                  4      t0 ! R R]P\                  4      t1 ! R R]P\                  4      t2R  t3R# )!z!
Tests for L{twisted.web.twcgi}.
N)ÚBytesIO)ÚaddressÚerrorÚ
interfacesÚreactor)ÚConnectionLost)ÚfailureÚlogÚutil)Úunittest)ÚclientÚhttpÚhttp_headersÚresourceÚserverÚtwcgi)ÚINTERNAL_SERVER_ERRORÚ	NOT_FOUND)Ú_render)ÚDummyChannelÚDummyRequestz2print("Header: OK")
print("")
print("cgi output")
zJprint("Header: spam")
print("Header: eggs")
print("")
print("cgi output")
z+print("XYZ")
print("")
print("cgi output")
zPprint("Server: monkeys")
print("Date: last year")
print("")
print("cgi output")
a&  # This is an example of a correctly-written CGI script which reads a body
# from stdin, which only reads env['CONTENT_LENGTH'] bytes.

import os, sys

body_length = int(os.environ.get('CONTENT_LENGTH',0))
indata = sys.stdin.read(body_length)
print("Header: OK")
print("")
print("readinput ok")
a+  # This is an example of the typical (incorrect) CGI script which expects
# the server to close stdin when the body of the request is complete.
# A correct CGI should only read env['CONTENT_LENGTH'] bytes.

import sys

indata = sys.stdin.read()
print("Header: OK")
print("")
print("readallinput ok")
zMprint("content-type: text/cgi-duplicate-test")
print("")
print("cgi output")
z†import json
import os
print("")
print("")
vals = {x:y for x,y in os.environ.items() if x.startswith("HTTP_")}
print(json.dumps(vals))
z]import os
param = str(os.environ['QUERY_STRING'])
print("Header: OK")
print("")
print(param)
c                   ó.   € ] tR t^bt]P
                  tRtR# )ÚPythonScript© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__ÚsysÚ
executableÚfilterÚ__static_attributes__r   ó    Ú;/usr/lib/python3/dist-packages/twisted/web/test/test_cgi.pyr   r   b   s   † Ø�^‰^„Fr"   r   c                   ó2   a € ] tR t^ft o R tR tR tRtV tR# )Ú_StartServerAndTearDownMixinc                óD  € \         P                  ! 4       p\        P                  ! \        V4      pVP                  R \        V4      4       \        P                  ! V4      p\        P                  ! ^ V4      V n        V P                  P                  4       P                  # )s   cgi)r   ÚResourcer
   ÚsibpathÚ__file__ÚputChildr   r   ÚSiter   Ú	listenTCPÚpÚgetHostÚport)ÚselfÚcgiÚrootÚcgipathÚsites   &&   r#   ÚstartServerÚ(_StartServerAndTearDownMixin.startServerg   sl   € Ü× Ò Ó"ˆÜ—,’,œx¨Ó-ˆØ�‰�fœl¨7Ó3Ô4Ü�{Š{˜4Ó ˆÜ×"Ò" 1 dÓ+ˆŒØ�v‰v�~‰~Ó×$Ñ$Ð$r"   c                ó`   € \        V R R4      '       d   V P                  P                  4       # R# )r-   N)Úgetattrr-   ÚstopListening)r0   s   &r#   ÚtearDownÚ%_StartServerAndTearDownMixin.tearDowno   s)   € Ü�4˜˜d×#Ò#Ø—6‘6×'Ñ'Ó)Ð)ñ $r"   c                óä   € \         P                  P                  V P                  4       4      p\	        VR 4      ;_uu_ 4       pVP                  V4       RRR4       V#   + '       g   i     T# ; i)ÚwtN)ÚosÚpathÚabspathÚmktempÚopenÚwrite)r0   ÚsourceÚcgiFilenameÚcgiFiles   &&  r#   ÚwriteCGIÚ%_StartServerAndTearDownMixin.writeCGIs   sO   € Ü—g‘g—o‘o d§k¡k£mÓ4ˆÜ�+˜t×$Ô$¨Ø�M‰M˜&Ô!÷ %àÐ÷ %Ö$àÐús   ÁAÁA/	)r-   N)	r   r   r   r   r5   r:   rG   r!   Ú__classdictcell__©Ú__classdict__s   @r#   r%   r%   f   s   ø‡ € ò%ò*÷ð r"   r%   c                   óè   a € ] tR t^zt o Rt]P                  P                  ]4      '       g   Rt	R t
R tR tR tR tR tR	 tR
 t^]n        R tR t^]n        R tR t^]n        R tR tRtV tR# )ÚCGITestsz$
Tests for L{twcgi.FilteredScript}.
z5CGI tests require a functional reactor.spawnProcess()c                óP  € V P                  \        4      pV P                  V4      pR V3,          pVP                  R4      p\        P
                  ! \        4      P                  RV4      pVP                  \        P                  4       VP                  V P                  4       V# )úhttp://localhost:%d/cgiÚasciió   GET)rG   Ú	DUMMY_CGIr5   Úencoder   ÚAgentr   ÚrequestÚaddCallbackÚreadBodyÚ
_testCGI_1)r0   rE   ÚportnumÚurlÚds   &    r#   Útest_CGIÚCGITests.test_CGI‚   sz   € Ø—m‘m¤IÓ.ˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ�LŠLœÓ!×)Ñ)¨&°#Ó6ˆØ	�‰”f—o‘oÔ&Ø	�‰�d—o‘oÔ&Øˆr"   c                ór   € V P                  VR \        P                  P                  R4      ,           4       R# )s
   cgi outputrP   N)ÚassertEqualr>   ÚlineseprS   )r0   Úress   &&r#   rX   ÚCGITests._testCGI_1�   s&   € Ø×Ñ˜˜m¬b¯j©j×.?Ñ.?ÀÓ.HÕHÖIr"   c                ó:  a € S P                  \        4      pS P                  V4      pRV3,          pVP                  R4      p\        P
                  ! \        4      pVP                  RV4      pVP                  \        4       V 3R lpVP                  V4       V# )zK
If the CGI script emits a I{Server} or I{Date} header, these are
ignored.
rO   rP   rQ   c                 ó´   <€ SP                  R V P                  P                  R4      4       SP                  RV P                  P                  R4      4       R# )Úmonkeysr   z	last yearÚdateN)ÚassertNotInÚheadersÚgetRawHeaders©Úresponser0   s   &€r#   ÚcheckResponseÚ;CGITests.test_protectedServerAndDate.<locals>.checkResponsež   sE   ø€ Ø×Ñ˜Y¨×(8Ñ(8×(FÑ(FÀxÓ(PÔQØ×Ñ˜[¨(×*:Ñ*:×*HÑ*HÈÓ*PÖQr"   )
rG   ÚSPECIAL_HEADER_CGIr5   rS   r   rT   r   rU   rV   ÚdiscardBody©r0   rE   rY   rZ   Úagentr[   rl   s   f      r#   Útest_protectedServerAndDateÚ$CGITests.test_protectedServerAndDate�   s�   ø€ ð
 —m‘mÔ$6Ó7ˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ—’œWÓ%ˆØ�M‰M˜& #Ó&ˆØ	�‰”kÔ"õ	Rð 	
�‰�mÔ$Øˆr"   c                ó:  a € S P                  \        4      pS P                  V4      pRV3,          pVP                  R4      p\        P
                  ! \        4      pVP                  RV4      pVP                  \        4       V 3R lpVP                  V4       V# )zŒ
If the CGI script emits a I{content-type} header, make sure that the
server doesn't add an additional (duplicate) one, as per ticket 4786.
rO   rP   rQ   c                 ó`   <€ SP                  V P                  P                  R 4      R.4       V # )zcontent-typeztext/cgi-duplicate-test©r_   rh   ri   rj   s   &€r#   rl   ÚBCGITests.test_noDuplicateContentTypeHeaders.<locals>.checkResponse³   s2   ø€ Ø×ÑØ× Ñ ×.Ñ.¨~Ó>Ø*Ð+ôð ˆOr"   )
rG   Ú$NO_DUPLICATE_CONTENT_TYPE_HEADER_CGIr5   rS   r   rT   r   rU   rV   ro   rp   s   f      r#   Ú"test_noDuplicateContentTypeHeadersÚ+CGITests.test_noDuplicateContentTypeHeaders¥   s€   ø€ ð
 —m‘mÔ$HÓIˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ—’œWÓ%ˆØ�M‰M˜& #Ó&ˆØ	�‰”kÔ"õ	ð 	
�‰�mÔ$Øˆr"   c                óˆ  a € S P                  \        4      pS P                  V4      pRV3,          pVP                  R4      p\        P
                  ! \        4      p\        P                  ! RR.RR./4      pVP                  RW5R7      pV 3R	 lpVP                  \        P                  4       VP                  V4       V# )
zF
The CGI script is never called with the Proxy header passed through.
rO   rP   s   Proxys   foos   X-Innocent-Headers   barrQ   )rh   c                 ó¨   <€ \         P                  ! V P                  R 4      4      pSP                  \	        VP                  4       4      0 Rm4       R# )rP   N>   Ú	HTTP_HOSTÚHTTP_CONNECTIONÚHTTP_X_INNOCENT_HEADER)ÚjsonÚloadsÚdecoder_   ÚsetÚkeys)rk   rh   r0   s   & €r#   rl   Ú7CGITests.test_noProxyPassthrough.<locals>.checkResponseÎ   s9   ø€ Ü—j’j §¡°Ó!9Ó:ˆGØ×ÑÜ�G—L‘L“NÓ#ÚJör"   )rG   ÚHEADER_OUTPUT_CGIr5   rS   r   rT   r   r   ÚHeadersrU   rV   rW   )r0   rE   rY   rZ   rq   rh   r[   rl   s   f       r#   Útest_noProxyPassthroughÚ CGITests.test_noProxyPassthrough½   s©   ø€ ð —m‘mÔ$5Ó6ˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆä—’œWÓ%ˆä×&Ò&Ø˜�xÐ!5¸°xÐ@ó
ˆð �M‰M˜& #ˆMÓ7ˆõ	ð 	
�‰”f—o‘oÔ&Ø	�‰�mÔ$Øˆr"   c                ó:  a € S P                  \        4      pS P                  V4      pRV3,          pVP                  R4      p\        P
                  ! \        4      pVP                  RV4      pVP                  \        4       V 3R lpVP                  V4       V# )zX
If a CGI script emits two instances of the same header, both are sent
in the response.
rO   rP   rQ   c                 ób   <€ SP                  V P                  P                  R 4      RR.4       R# )ÚheaderÚspamÚeggsNrv   rj   s   &€r#   rl   Ú7CGITests.test_duplicateHeaderCGI.<locals>.checkResponseç   s*   ø€ Ø×Ñ˜X×-Ñ-×;Ñ;¸HÓEÈÐPVÐGWÖXr"   )
rG   ÚDUAL_HEADER_CGIr5   rS   r   rT   r   rU   rV   ro   rp   s   f      r#   Útest_duplicateHeaderCGIÚ CGITests.test_duplicateHeaderCGIÙ   s€   ø€ ð
 —m‘m¤OÓ4ˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ—’œWÓ%ˆØ�M‰M˜& #Ó&ˆØ	�‰”kÔ"õ	Yð 	
�‰�mÔ$Øˆr"   c                óº  a a€ S P                  \        4      pS P                  V4      pRV3,          pVP                  R4      p\        P
                  ! \        4      pVP                  RV4      pVP                  \        4       . oV3R lp\        P                  ! V4       S P                  \        P                  V4       VV 3R lpVP                  V4       V# )z6
Check for the error message in the duplicated header
rO   rP   rQ   c                 óR   <€ SP                  \        P                  ! V 4      4       R # ©N)Úappendr	   ÚtextFromEventDict)Ú	eventDictÚloggedMessagess   &€r#   Ú
addMessageÚ4CGITests.test_malformedHeaderCGI.<locals>.addMessageû   s   ø€ Ø×!Ñ!¤#×"7Ò"7¸	Ó"BÖCr"   c                 óL   <€ SP                  R \        R4      ,           S4       R# )zignoring malformed CGI header: s   XYZN)ÚassertInÚrepr)Úignoredr™   r0   s   &€€r#   rl   Ú7CGITests.test_malformedHeaderCGI.<locals>.checkResponse  s   ø€ Ø�M‰MØ1´D¸³LÕ@À.ör"   )rG   ÚBROKEN_HEADER_CGIr5   rS   r   rT   r   rU   rV   ro   r	   ÚaddObserverÚ
addCleanupÚremoveObserver)	r0   rE   rY   rZ   rq   r[   rš   rl   r™   s	   f       @r#   Útest_malformedHeaderCGIÚ CGITests.test_malformedHeaderCGIí   s­   ù€ ð —m‘mÔ$5Ó6ˆà×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ—’œWÓ%ˆØ�M‰M˜& #Ó&ˆØ	�‰”kÔ"Øˆõ	Dô 	�Š˜
Ô#Ø�‰œ×*Ñ*¨JÔ7ö	ð
 	
�‰�mÔ$Øˆr"   c                ó  € \         P                  P                  V P                  4       4      p\	        VR 4      ;_uu_ 4       pVP                  \        4       RRR4       V P                  V4      p\        P                  ! \        4      pRV3,          pVP                  R4      pVP                  RV4      pVP                  \        P                  4       VP                  V P                  4       V#   + '       g   i     L¤; i)r=   NrO   rP   rQ   )r>   r?   r@   rA   rB   rC   ÚREADINPUT_CGIr5   r   rT   r   rS   rU   rV   rW   Ú_test_ReadEmptyInput_1©r0   rE   rF   rY   rq   rZ   r[   s   &      r#   Útest_ReadEmptyInputÚCGITests.test_ReadEmptyInput	  s´   € Ü—g‘g—o‘o d§k¡k£mÓ4ˆÜ�+˜t×$Ô$¨Ø�M‰Mœ-Ô(÷ %ð ×"Ñ" ;Ó/ˆÜ—’œWÓ%ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆØ�M‰M˜& #Ó&ˆØ	�‰”f—o‘oÔ&Ø	�‰�d×1Ñ1Ô2Øˆ÷ %×$ús   ÁC4Ã4D	c                óp   € R \         P                   2pVP                  R4      pV P                  W4       R# ©zreadinput okrP   N©r>   r`   rS   r_   ©r0   ra   Úexpecteds   && r#   r©   ÚCGITests._test_ReadEmptyInput_1  ó.   € Ø!¤"§*¡* Ð.ˆØ—?‘? 7Ó+ˆØ×Ñ˜Ö'r"   c           	     óL  € \         P                  P                  V P                  4       4      p\	        VR 4      ;_uu_ 4       pVP                  \        4       RRR4       V P                  V4      p\        P                  ! \        4      pRV3,          pVP                  R4      pVP                  VR\        P                  ! \        R4      4      R7      pVP                  \        P                   4       VP                  V P"                  4       V#   + '       g   i     LÃ; i©r=   NrO   rP   s   POSTs   Here is your stdin)ÚuriÚmethodÚbodyProducer)r>   r?   r@   rA   rB   rC   r¨   r5   r   rT   r   rS   rU   ÚFileBodyProducerr   rV   rW   Ú_test_ReadInput_1rª   s   &      r#   Útest_ReadInputÚCGITests.test_ReadInput  sÓ   € Ü—g‘g—o‘o d§k¡k£mÓ4ˆÜ�+˜t×$Ô$¨Ø�M‰Mœ-Ô(÷ %ð ×"Ñ" ;Ó/ˆÜ—’œWÓ%ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆØ�M‰MØØÜ×0Ò0´Ð9NÓ1OÓPð ó 
ˆð
 	
�‰”f—o‘oÔ&Ø	�‰�d×,Ñ,Ô-Øˆ÷ %×$ús   ÁDÄD#	c                óp   € R \         P                   2pVP                  R4      pV P                  W4       R# r®   r¯   r°   s   && r#   rº   ÚCGITests._test_ReadInput_12  r³   r"   c           	     óH  € \         P                  P                  V P                  4       4      p\	        VR 4      ;_uu_ 4       pVP                  \        4       RRR4       V P                  V4      pRV3,          pVP                  R4      p\        P                  ! \        4      P                  VR\        P                  ! \        R4      4      R7      pVP                  \        P                   4       VP                  V P"                  4       V#   + '       g   i     LÁ; irµ   )r>   r?   r@   rA   rB   rC   ÚREADALLINPUT_CGIr5   rS   r   rT   r   rU   r¹   r   rV   rW   Ú_test_ReadAllInput_1)r0   rE   rF   rY   rZ   r[   s   &     r#   Útest_ReadAllInputÚCGITests.test_ReadAllInput7  sÑ   € Ü—g‘g—o‘o d§k¡k£mÓ4ˆÜ�+˜t×$Ô$¨Ø�M‰MÔ*Ô+÷ %ð ×"Ñ" ;Ó/ˆØ'¨7¨*Õ4ˆØ�j‰j˜Ó!ˆÜ�LŠLœÓ!×)Ñ)ØØÜ×0Ò0´Ð9NÓ1OÓPð *ó 
ˆð
 	
�‰”f—o‘oÔ&Ø	�‰�d×/Ñ/Ô0Øˆ÷ %×$ús   ÁDÄD!	c                óp   € R \         P                   2pVP                  R4      pV P                  W4       R# )zreadallinput okrP   Nr¯   r°   s   && r#   rÁ   ÚCGITests._test_ReadAllInput_1J  s.   € Ø$¤R§Z¡Z LÐ1ˆØ—?‘? 7Ó+ˆØ×Ñ˜Ö'r"   c                óø   €  ! R R4      pV! 4       p\        RR.4      p\        P                  ! RRR4      Vn        \        P
                  ! RVR	7      p\        WC4       V P                  VP                  4       R
# )z_
L{twcgi.FilteredScript.runProcess} uses the reactor passed as an
argument to the constructor.
c                   ó.   a € ] tR tRt o RtRtR tRtV tR# )Ú5CGITests.test_useReactorArgument.<locals>.FakeReactoriU  z:
A fake reactor recording whether spawnProcess is called.
Fc                ó   € RV n         R# )z‡
Set the C{called} flag to C{True} if C{spawnProcess} is called.

@param args: Positional arguments.
@param kwargs: Keyword arguments.
TN©Úcalled)r0   ÚargsÚkwargss   &*,r#   ÚspawnProcessÚBCGITests.test_useReactorArgument.<locals>.FakeReactor.spawnProcess\  s   € ð #�–r"   rÊ   N)	r   r   r   r   Ú__doc__rË   rÎ   r!   rI   rJ   s   @r#   ÚFakeReactorrÈ   U  s   ø‡ € ñð ˆF÷#ð #r"   rÑ   ÚaÚbÚTCPú	127.0.0.1é90  z
dummy-file©r   N)	r   r   ÚIPv4Addressr   r   ÚFilteredScriptr   Ú
assertTruerË   )r0   rÑ   ÚfakeReactorrU   r   s   &    r#   Útest_useReactorArgumentÚ CGITests.test_useReactorArgumentO  se   € ÷	#ñ 	#ñ  "“mˆÜ  S˜zÓ*ˆÜ ×,Ò,¨U°KÀÓGˆŒÜ×'Ò'¨¸kÔJˆÜ�Ô"à�‰˜×*Ñ*Ö+r"   r   N)r   r   r   r   rÐ   r   ÚIReactorProcessÚ
providedByr   Úskipr\   rX   rr   ry   rˆ   r‘   r¥   r«   Útimeoutr©   r»   rº   rÂ   rÁ   rÜ   r!   rI   rJ   s   @r#   rM   rM   z   s”   ø‡ € ñð ×%Ñ%×0Ñ0°×9Ò9ØFˆò	òJòò*ò0ò8ò(ò8ð #$ÐÔò(ò
ð$ €NÔò(ò
ð" !"ÐÔò(÷
,ð ,r"   rM   c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚCGIScriptTestsin  z
Tests for L{twcgi.CGIScript}.
c                ó2  € V P                  \        4      pV P                  V4      pRV3,          p\        P                  ! \
        4      pVP                  RV4      pVP                  \        P                  4       VP                  V P                  4       V# )zS
If the CGI script is passed URL parameters, do not fall over,
as per ticket 9887.
s"   http://localhost:%d/cgi?param=1234rQ   )
rG   ÚURL_PARAMETER_CGIr5   r   rT   r   rU   rV   rW   Ú_test_urlParameters_1)r0   rE   rY   rZ   rq   r[   s   &     r#   Útest_urlParametersÚ!CGIScriptTests.test_urlParameterss  st   € ð
 —m‘mÔ$5Ó6ˆØ×"Ñ" ;Ó/ˆØ3°w°jÕ@ˆÜ—’œWÓ%ˆØ�M‰M˜& #Ó&ˆØ	�‰”f—o‘oÔ&Ø	�‰�d×0Ñ0Ô1Øˆr"   c                óp   € R \         P                   2pVP                  R4      pV P                  W4       R# )z
param=1234rP   Nr¯   r°   s   && r#   ræ   Ú$CGIScriptTests._test_urlParameters_1�  s.   € Ø¤§
¡
˜|Ð,ˆØ—?‘? 7Ó+ˆØ×Ñ˜Ö'r"   c                ó$  €  ! R R4      pV! 4       p\         P                  ! V P                  4       VR7      p\        RR.4      p\        P
                  ! RRR4      Vn        \        W44       V P                  VP                  R	,          R
4       R# )z\
L{twcgi.CGIScript.render} sets the process environment
I{PATH_INFO} from the request path.
c                   ó*   a € ] tR tRt o RtR tRtV tR# )Ú1CGIScriptTests.test_pathInfo.<locals>.FakeReactoriŒ  zB
A fake reactor recording the environment passed to spawnProcess.
c                ó   € W@n         R# )zÉ
Store the C{env} L{dict} to an instance attribute.

@param process: Ignored
@param filename: Ignored
@param args: Ignored
@param env: The environment L{dict} which will be stored
@param wdir: Ignored
N©Úprocess_env)r0   ÚprocessÚfilenamerÌ   ÚenvÚwdirs   &&&&&&r#   rÎ   Ú>CGIScriptTests.test_pathInfo.<locals>.FakeReactor.spawnProcess‘  s
   € ð $'Ö r"   rï   N)r   r   r   r   rÐ   rÎ   r!   rI   rJ   s   @r#   rÑ   rí   Œ  s   ø‡ € ñ÷
'ð 
'r"   rÑ   r×   rÒ   rÓ   rÔ   rÕ   rÖ   Ú	PATH_INFOz/a/bN)
r   Ú	CGIScriptrA   r   r   rØ   r   r   r_   rð   )r0   rÑ   Ú_reactorr   rU   s   &    r#   Útest_pathInfoÚCGIScriptTests.test_pathInfo†  sr   € ÷	'ñ 	'ñ" “=ˆÜ—?’? 4§;¡;£=¸(ÔCˆÜ  S˜zÓ*ˆÜ ×,Ò,¨U°KÀÓGˆŒÜ�Ô"à×Ñ˜×-Ñ-¨kÕ:¸FÖCr"   r   N)
r   r   r   r   rÐ   rç   ræ   rù   r!   rI   rJ   s   @r#   rã   rã   n  s    ø‡ € ñòò(÷
Dð Dr"   rã   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚCGIDirectoryTestsi¦  z"
Tests for L{twcgi.CGIDirectory}.
c                ó²   a a€ \         P                  ! S P                  4       4      p\        R.4      o\	        VS4      pVV 3R lpVP                  V4       V# )zK
L{twcgi.CGIDirectory.render} sets the HTTP response code to I{NOT
FOUND}.
Ú c                 óH   <€ SP                  SP                  \        4       R # r•   ©r_   ÚresponseCoder   ©rŸ   rU   r0   s   &€€r#   Ú
cbRenderedÚ1CGIDirectoryTests.test_render.<locals>.cbRendered´  ó   ø€ Ø×Ñ˜W×1Ñ1´9Ö=r"   )r   ÚCGIDirectoryrA   r   r   rV   )r0   r   r[   r  rU   s   f   @r#   Útest_renderÚCGIDirectoryTests.test_render«  sK   ù€ ô
 ×%Ò% d§k¡k£mÓ4ˆÜ ˜tÓ$ˆÜ�H˜gÓ&ˆö	>ð 	
�‰�jÔ!Øˆr"   c                ó  a a€ S P                  4       p\        P                  ! V4       \        P                  ! V4      p\        R.4      oVP                  ! RS4      p\        VS4      pVV 3R lpVP                  V4       V# )zæ
L{twcgi.CGIDirectory.getChild} returns a resource which renders an
response with the HTTP I{NOT FOUND} status code if the indicated child
does not exist as an entry in the directory used to initialized the
L{twcgi.CGIDirectory}.
Úfooc                 óH   <€ SP                  SP                  \        4       R # r•   r   r  s   &€€r#   r  Ú8CGIDirectoryTests.test_notFoundChild.<locals>.cbRenderedÈ  r  r"   )	rA   r>   Úmakedirsr   r  r   ÚgetChildr   rV   )r0   r?   r   Úchildr[   r  rU   s   f     @r#   Útest_notFoundChildÚ$CGIDirectoryTests.test_notFoundChildº  sn   ù€ ð �{‰{‹}ˆÜ
�Š�DÔÜ×%Ò% dÓ+ˆÜ ˜wÓ'ˆØ×!Ò! %¨Ó1ˆÜ�E˜7Ó#ˆö	>ð 	
�‰�jÔ!Øˆr"   r   N)	r   r   r   r   rÐ   r  r  r!   rI   rJ   s   @r#   rü   rü   ¦  s   ø‡ € ñò÷ð r"   rü   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚCGIProcessProtocolTestsiÏ  z(
Tests for L{twcgi.CGIProcessProtocol}.
c                óú   € \        R.4      p\        P                  ! V4      pVP                  \        P
                  ! \        P                  ! 4       4      4       V P                  VP                  \        4       R# )z¢
If the process communicating with L{CGIProcessProtocol} ends before
finishing writing out headers, the response has I{INTERNAL SERVER
ERROR} as its status code.
rþ   N)r   r   ÚCGIProcessProtocolÚprocessEndedr   ÚFailurer   ÚProcessTerminatedr_   r  r   )r0   rU   Úprotocols   &  r#   Útest_prematureEndOfHeadersÚ2CGIProcessProtocolTests.test_prematureEndOfHeadersÔ  sW   € ô  ˜tÓ$ˆÜ×+Ò+¨GÓ4ˆØ×ÑœgŸošo¬e×.EÒ.EÓ.GÓHÔIØ×Ñ˜×-Ñ-Ô/DÖEr"   c                ó@  € \        4       p\        P                  ! VR4      p\        P                  ! V4      pVP                  \        P                  ! \        R4      4      4       VP                  \        P                  ! \        P                  ! 4       4      4       R# )zO
Ensure that the CGI process ends cleanly when the request connection
is lost.
TzConnection doneN)r   r   ÚRequestr   r  ÚconnectionLostr   r  r   r  r   r  )r0   r[   rU   r  s   &   r#   Útest_connectionLostÚ+CGIProcessProtocolTests.test_connectionLostß  sh   € ô
 ‹NˆÜ—,’,˜q $Ó'ˆÜ×+Ò+¨GÓ4ˆØ×ÑœwŸš¬~Ð>OÓ/PÓQÔRØ×ÑœgŸošo¬e×.EÒ.EÓ.GÓHÖIr"   r   N)	r   r   r   r   rÐ   r  r  r!   rI   rJ   s   @r#   r  r  Ï  s   ø‡ € ñò	F÷	Jð 	Jr"   r  c                óV   a € \         P                  ! S 4      P                  V 3R l4      # )z^
Discard the body of a HTTP response.

@param response: The response.

@return: The response.
c                 ó   <€ S# r•   r   )Ú_rk   s   &€r#   Ú<lambda>ÚdiscardBody.<locals>.<lambda>ó  s   ø€ ¹8r"   )r   rW   rV   )rk   s   fr#   ro   ro   ë  s    ø€ ô �?Š?˜8Ó$×0Ñ0Ô1CÓDÐDr"   )4rÐ   r€   r>   r   Úior   Útwisted.internetr   r   r   r   Útwisted.internet.errorr   Útwisted.pythonr   r	   r
   Útwisted.trialr   Útwisted.webr   r   r   r   r   r   Útwisted.web.httpr   r   Útwisted.web.test._utilr   Útwisted.web.test.requesthelperr   r   rR   r�   r¡   rn   r¨   rÀ   rx   r†   rå   rÙ   r   r%   ÚTestCaserM   rã   rü   r  ro   r   r"   r#   Ú<module>r0     s÷   ðñó Û 	Û 
Ý ç @Ó @Ý 1ß -Ñ -Ý "ß K× Kß =Ý *ß Eð€	ð€ðÐ ðÐ ð€ðÐ ð(Ð $ðÐ ðÐ ô�5×'Ñ'ô ÷ñ ô(q,Ð+¨X×->Ñ->ô q,ôh5DÐ1°8×3DÑ3Dô 5Dôp&˜×)Ñ)ô &ôRJ˜h×/Ñ/ô Jô8Er"   