+
    üÐj<Q  ã                   ó  € R 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 ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt R R ltR R lt ! R R4      t ! R R4      t ! R R4      t]! ]4       ! R R4      4       tR.tR# )zo
An implementation of
U{Python Web Server Gateway Interface v1.0.1<http://www.python.org/dev/peps/pep-3333/>}.
)ÚSequence)Úexc_info)ÚListÚUnion)Úwarn)Úimplementer)ÚblockingCallFromThread)ÚLogger)ÚFailure)ÚINTERNAL_SERVER_ERROR)Ú	IResource)ÚNOT_DONE_YETc                óR   € V ^8„  d   QhR\         \        \        3,          R\        /# ©é   ÚstringÚreturn)r   ÚstrÚbytes)Úformats   "Ú2/usr/lib/python3/dist-packages/twisted/web/wsgi.pyÚ__annotate__r   %   s#   € ÷ +ñ +œœc¤5˜jÕ)ð +¬cñ +ó    c                ó�   € \        V \        4      '       d!   V P                  R4      P                  R4      # V P                  R4      # )a;  
Convert C{string} to a WSGI "bytes-as-unicode" string.

If it's a byte string, decode as ISO-8859-1. If it's a Unicode string,
round-trip it to bytes and back using ISO-8859-1 as the encoding.

@type string: C{str} or C{bytes}
@rtype: C{str}

@raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
ú
iso-8859-1)Ú
isinstancer   ÚencodeÚdecode©r   s   &r   Ú_wsgiStringr   %   s:   € ô �&œ#×ÒØ�}‰}˜\Ó*×1Ñ1°,Ó?Ð?à�}‰}˜\Ó*Ð*r   c                ó0   € V ^8„  d   QhR\         R\        /# r   )r   r   )r   s   "r   r   r   7   s   € ÷ 
'ñ 
'œsð 
'¤uñ 
'r   c                ó$   € V P                  R4      # )zÆ
Convert C{string} from a WSGI "bytes-as-unicode" string to an
ISO-8859-1 byte string.

@type string: C{str}
@rtype: C{bytes}

@raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
r   )r   r   s   &r   Ú_wsgiStringToBytesr"   7   s   € ð �=‰=˜Ó&Ð&r   c                   ó\   a € ] tR t^Dt o Rt]! 4       tV 3R lR ltV 3R lR ltR t	Rt
V tR# )	Ú_ErrorStreama—  
File-like object instances of which are used as the value for the
C{'wsgi.errors'} key in the C{environ} dictionary passed to the application
object.

This simply passes writes on to L{logging<twisted.logger>} system as
error events from the C{'wsgi'} system.  In the future, it may be desirable
to expose more information in the events it logs, such as the application
object which generated the message.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   Údatar   N)r   )r   Ú__classdict__s   "€r   r   Ú_ErrorStream.__annotate__R   s   ø€ ÷ Lñ L™#ð L $ñ Lr   c                óÀ   € \        V\        4      '       g(   \        RV: R\        V4      P                  : R24      hV P
                  P                  VRRV3R7       R# )zØ
Generate an event for the logging system with the given bytes as the
message.

This is called in a WSGI application thread, not the I/O thread.

@type data: str

@raise TypeError: if C{data} is not a native string.
z"write() argument must be str, not ú (Ú)ÚwsgiT)ÚsystemÚisErrorÚmessageN)r   r   Ú	TypeErrorÚtypeÚ__name__Ú_logÚerror)Úselfr&   s   &&r   ÚwriteÚ_ErrorStream.writeR   sN   € ô ˜$¤×$Ò$Ýãœ˜d›×,Ô,ð.óð ð 	�	‰	�‰˜ V°TÀDÀ7ˆÖKr   c                ó4   <€ V ^8„  d   QhRS[ S[,          RR/# )r   Úiovecr   N)r   r   )r   r'   s   "€r   r   r(   g   s   ø€ ÷ #ñ #¡¡S¥	ð #¨dñ #r   c                óF   € V P                  RP                  V4      4       R# )a"  
Join the given lines and pass them to C{write} to be handled in the
usual way.

This is called in a WSGI application thread, not the I/O thread.

@param iovec: A C{list} of C{'\n'}-terminated C{str} which will be
    logged.

@raise TypeError: if C{iovec} contains any non-native strings.
Ú N)r6   Újoin)r5   r9   s   &&r   Ú
writelinesÚ_ErrorStream.writelinesg   s   € ð 	�
‰
�2—7‘7˜5“>Ö"r   c                ó   € R# )z¨
Nothing is buffered, so flushing does nothing.  This method is required
to exist by PEP 333, though.

This is called in a WSGI application thread, not the I/O thread.
N© ©r5   s   &r   ÚflushÚ_ErrorStream.flushu   s   ‚ r   r@   N)r2   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r	   r3   r6   r=   rB   Ú__static_attributes__Ú__classdictcell__©r'   s   @r   r$   r$   D   s3   ø‡ € ñ	ñ ‹8€D÷Lð L÷*#ð #÷ð r   r$   c                   óN   a € ] tR t^~t o RtR tR	R ltR	R ltR	R ltR t	Rt
V tR# )
Ú_InputStreamal  
File-like object instances of which are used as the value for the
C{'wsgi.input'} key in the C{environ} dictionary passed to the application
object.

This only exists to make the handling of C{readline(-1)} consistent across
different possible underlying file-like object implementations.  The other
supported methods pass through directly to the wrapped object.
c                ó   € Wn         R# )z\
Initialize the instance.

This is called in the I/O thread, not a WSGI application thread.
N©Ú_wrapped)r5   Úinputs   &&r   Ú__init__Ú_InputStream.__init__‰   s	   € ð Žr   Nc                ót   € Vf   V P                   P                  4       # V P                   P                  V4      # )zk
Pass through to the underlying C{read}.

This is called in a WSGI application thread, not the I/O thread.
)rO   Úread©r5   Úsizes   &&r   rT   Ú_InputStream.read‘   s1   € ð Š<Ø—=‘=×%Ñ%Ó'Ð'Ø�}‰}×!Ñ! $Ó'Ð'r   c                ó‚   € VR8X  g   Vf   V P                   P                  4       # V P                   P                  V4      # )z¥
Pass through to the underlying C{readline}, with a size of C{-1} replaced
with a size of L{None}.

This is called in a WSGI application thread, not the I/O thread.
éÿÿÿÿ)rO   ÚreadlinerU   s   &&r   rZ   Ú_InputStream.readlineœ   s7   € ð �2Œ:˜šØ—=‘=×)Ñ)Ó+Ð+Ø�}‰}×%Ñ% dÓ+Ð+r   c                ót   € Vf   V P                   P                  4       # V P                   P                  V4      # )zp
Pass through to the underlying C{readlines}.

This is called in a WSGI application thread, not the I/O thread.
)rO   Ú	readlinesrU   s   &&r   r]   Ú_InputStream.readlines©   s1   € ð Š<Ø—=‘=×*Ñ*Ó,Ð,Ø�}‰}×&Ñ& tÓ,Ð,r   c                ó,   € \        V P                  4      # )zo
Pass through to the underlying C{__iter__}.

This is called in a WSGI application thread, not the I/O thread.
)ÚiterrO   rA   s   &r   Ú__iter__Ú_InputStream.__iter__´   s   € ô �D—M‘MÓ"Ð"r   rN   ©N)r2   rD   rE   rF   rG   rQ   rT   rZ   r]   ra   rH   rI   rJ   s   @r   rL   rL   ~   s(   ø‡ € ñòô	(ô,ô	-÷#ð #r   rL   c                   ód   a € ] tR t^½t o RtRt]! 4       tR tR t	RR lt
R tR tR	 tR
 tRtV tR# )Ú_WSGIResponseaÌ  
Helper for L{WSGIResource} which drives the WSGI application using a
threadpool and hooks it up to the L{http.Request}.

@ivar started: A L{bool} indicating whether or not the response status and
    headers have been written to the request yet.  This may only be read or
    written in the WSGI application thread.

@ivar reactor: An L{IReactorThreads} provider which is used to call methods
    on the request in the I/O thread.

@ivar threadpool: A L{ThreadPool} which is used to call the WSGI
    application object in a non-I/O thread.

@ivar application: The WSGI application object.

@ivar request: The L{http.Request} upon which the WSGI environment is
    based and to which the application's output will be sent.

@ivar environ: The WSGI environment L{dict}.

@ivar status: The HTTP response status L{str} supplied to the WSGI
    I{start_response} callable by the application.

@ivar headers: A list of HTTP response headers supplied to the WSGI
    I{start_response} callable by the application.

@ivar _requestFinished: A flag which indicates whether it is possible to
    generate more response data or not.  This is L{False} until
    L{http.Request.notifyFinish} tells us the request is done,
    then L{True}.
Fc                ó8  € R V n         Wn        W n        W0n        W@n        V P                  P                  4       P                  V P                  4       VP                  '       d$   RRP                  VP                  4      ,           pMRpVP                  '       d$   RRP                  VP                  4      ,           pMRpVP                  P                  R^4      p\        V4      ^8X  d   RpM	V^,          pVP                  4       p	R\        VP                   4      R\        V	P"                  4      R\        \%        V	P&                  4      4      R\        V4      R\        V4      R	\        V4      R
\        VP)                  R4      ;'       g    R4      R\        VP)                  R4      ;'       g    R4      R\        VP+                  4       4      R\        \%        VP-                  4       P&                  4      4      R\        VP.                  4      /V n        RV P                  n        VP4                  P7                  4        Fj  w  r«R\        V
4      P9                  4       P;                  RR4      ,           p
RP                  R V 4       4      P;                  RR4      V P0                  V
&   Kl  	  V P0                  P=                  RR$RVP?                  4       ;'       d    R;'       g    RRR RR R!R R"\A        4       R#\C        VPD                  4      /4       R# )%Fó   /r   ó   ?ÚREQUEST_METHODÚREMOTE_ADDRÚREMOTE_PORTÚSCRIPT_NAMEÚ	PATH_INFOÚQUERY_STRINGÚCONTENT_TYPEs   content-typer;   ÚCONTENT_LENGTHs   content-lengthÚSERVER_NAMEÚSERVER_PORTÚSERVER_PROTOCOLNÚHTTP_Ú-Ú_Ú,c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5irc   )r   )Ú.0Úvs   & r   Ú	<genexpr>Ú)_WSGIResponse.__init__.<locals>.<genexpr>  s   é € Ð)IÁ&¸Q¬+°a¯.¨.Ã&ùs   ‚Ú
Ú zwsgi.versionzwsgi.url_schemeÚhttpsÚhttpzwsgi.run_oncezwsgi.multithreadTzwsgi.multiprocesszwsgi.errorsz
wsgi.input)é   é    )#ÚstartedÚreactorÚ
threadpoolÚapplicationÚrequestÚnotifyFinishÚaddBothÚ	_finishedÚprepathr<   ÚpostpathÚuriÚsplitÚlenÚgetClientAddressr   ÚmethodÚhostr   ÚportÚ	getHeaderÚgetRequestHostnameÚgetHostÚclientprotoÚenvironÚdefaultContentTypeÚrequestHeadersÚgetAllRawHeadersÚupperÚreplaceÚupdateÚisSecurer$   rL   Úcontent)r5   r„   r…   r†   r‡   Ú
scriptNameÚpathInfoÚpartsÚqueryStringÚ
remotePeerÚnameÚvaluess   &&&&&       r   rQ   Ú_WSGIResponse.__init__â   s|  € ØˆŒØŒØ$ŒØ&ÔØŒØ�‰×!Ñ!Ó#×+Ñ+¨D¯N©NÔ;à�?�?ˆ?Ø §	¡	¨'¯/©/Ó :Õ:‰JàˆJà××ÐØ˜dŸi™i¨×(8Ñ(8Ó9Õ9‰HàˆHà—‘×!Ñ! $¨Ó*ˆÜˆu‹:˜Œ?Ø‰Kà �(ˆKð ×-Ñ-Ó/ˆ
àœk¨'¯.©.Ó9Øœ; z§¡Ó7Øœ;¤s¨:¯?©?Ó';Ó<Øœ; zÓ2Øœ XÓ.ØœK¨Ó4ØœK¨×(9Ñ(9¸/Ó(J×(PÐ(PÈbÓQØœk¨'×*;Ñ*;Ð<MÓ*N×*TÐ*TÐRTÓUØœ; w×'AÑ'AÓ'CÓDØœ;¤s¨7¯?©?Ó+<×+AÑ+AÓ'BÓCØœ{¨7×+>Ñ+>Ó?ð
ˆŒð" +/ˆ�‰Ô'à#×2Ñ2×CÑCÖE‰LˆDØœ[¨Ó.×4Ñ4Ó6×>Ñ>¸sÀCÓHÕHˆDð "%§¡Ñ)IÁ&Ó)IÓ!I×!QÑ!QØ�có"ˆD�L‰L˜Óñ	 Fð 	�‰×Ñà Ø! 7×#3Ñ#3Ó#5×#AÐ#A¸'×#KÐ#KÀVØ Ø" DØ# UØœ|›~ð œl¨7¯?©?Ó;ð+ö	
r   c                ó   € RV n         R# )zK
Record the end of the response generation for the request being
serviced.
TN)Ú_requestFinished)r5   Úignoreds   &&r   rŠ   Ú_WSGIResponse._finished2  s   € ð
 !%ˆÖr   Nc           	     óØ  € V P                   '       d$   Ve    V^,          P                  V^,          4      h\        V\        4      '       g/   \	        RP                  V\        V4      P                  4      4      h\        V\        4      '       d   Mk\        V\        4      '       d/   \        RV: R\        V4      P                  : R2\        R7       M'\	        RV: R\        V4      P                  : R24      hV FÒ  p\        V\        4      '       d   Mk\        V\        4      '       d/   \        RV: R\        V4      P                  : R2\        R7       M'\	        RV: R\        V4      P                  : R24      h\        V4      ^8w  d   \	        RV: 24      hV F(  p\        V\        4      '       d   K  \	        R	V: 24      h	  KÔ  	  Wn        W n        V P                   # )
zœ
The WSGI I{start_response} callable.  The given values are saved until
they are needed to generate the response.

This will be called in a non-I/O thread.
z!status must be str, not {!r} ({})zheaders should be a list, not r*   r+   )Úcategoryzheaders must be a list, not z)header should be a (str, str) tuple, not z'header must be a (str, str) tuple, not z%header must be (str, str) tuple, not )rƒ   Úwith_tracebackr   r   r0   r   r1   r2   Úlistr   r   ÚRuntimeWarningÚtupler�   ÚstatusÚheadersr6   )r5   r³   r´   ÚexcInfoÚheaderÚelems   &&&&  r   ÚstartResponseÚ_WSGIResponse.startResponse9  s“  € ð �<�<ˆ<˜GÒ/Ø˜!•*×+Ñ+¨G°A­JÓ7Ð7ô ˜&¤#×&Ò&ÜØ3×:Ñ:ØœD ›L×1Ñ1óóð ô �gœt×$Ò$ØÜ˜¤×*Ò*ÝãœD ›M×2Ô2ð4ä'öõ ãœD ›M×2Ô2ð4óð ó ˆFÜ˜&¤%×(Ò(ØÜ˜F¤H×-Ò-Ýãœt F›|×4Ô4ð6ä+öõ  ãœt F›|×4Ô4ð6óð ô �6‹{˜aÔÜÐ"IÈ&ÉÐ TÓUÐUó
 �Ü! $¬×,Ô,Ü#Ð&KÈFÉ:Ð$VÓWÐWó ñ- ð4 ŒØŒØ�z‰zÐr   c                ó~   a a€ VV 3R lp \        S P                  VS P                  4      RS n        #   RS n        i ; i)zØ
The WSGI I{write} callable returned by the I{start_response} callable.
The given bytes will be written to the response body, possibly flushing
the status and headers first.

This will be called in a non-I/O thread.
c                 ón   <€ V '       g   SP                  4        SP                  P                  S4       R # rc   )Ú_sendResponseHeadersr‡   r6   )rƒ   r&   r5   s   &€€r   Ú	wsgiWriteÚ&_WSGIResponse.write.<locals>.wsgiWriteŸ  s$   ø€ ßØ×)Ñ)Ô+Ø�L‰L×Ñ˜tÖ$r   T)r   r„   rƒ   )r5   r&   r½   s   ff r   r6   Ú_WSGIResponse.write~  s1   ù€ öB	%ð
	 Ü)¨$¯,©,¸	À4Ç<Á<ÓPàˆD�Lø˜4ˆD�Lús   ‹ 3 ³	<c                ój  € V P                   P                  R^4      w  r\        V4      pV P                  P	                  V\        V4      4       V P                   FT  w  r4VP                  4       R9  g   K  V P                  P                  P                  \        V4      \        V4      4       KV  	  R# )zü
Set the response code and response headers on the request object, but
do not flush them.  The caller is responsible for doing a write in
order for anything to actually be written out in response to the
request.

This must be called in the I/O thread.
N)ÚserverÚdate)
r³   rŽ   Úintr‡   ÚsetResponseCoder"   r´   ÚlowerÚresponseHeadersÚaddRawHeader)r5   Úcoder/   r¦   Úvalues   &    r   r¼   Ú"_WSGIResponse._sendResponseHeaders©  s†   € ð Ÿ™×)Ñ)¨$°Ó2‰ˆÜ�4‹yˆØ�‰×$Ñ$ TÔ+=¸gÓ+FÔGàŸ<œ<‰KˆDà�z‰z‹|Ð#5Ö5Ø—‘×,Ñ,×9Ñ9Ü& tÓ,Ô.@ÀÓ.Göó (r   c                óP   € V P                   P                  V P                  4       R# )zW
Start the WSGI application in the threadpool.

This must be called in the I/O thread.
N)r…   ÚcallInThreadÚrunrA   s   &r   ÚstartÚ_WSGIResponse.start½  s   € ð 	�‰×$Ñ$ T§X¡XÖ.r   c                óè  a €  S P                  S P                  S P                  4      pV F0  pV'       d   S P                  V4       S P                  '       g   K0   M	  \        VRR4      pVe   V! 4        V 3R lpS P                  P                  VS P                  4       RS n        R#   \         d;    T 3R lpS P                  P                  ! TS P                  .\        4       O5!    LMi ; i)z�
Call the WSGI application object, iterate it, and handle its output.

This must be called in a non-I/O thread (ie, a WSGI application
thread).
ÚcloseNc                 ó”   <€ SP                   '       g5   V '       g   SP                  4        SP                  P                  4        R # R # rc   )rª   r¼   r‡   Úfinish)rƒ   r5   s   &€r   Ú
wsgiFinishÚ%_WSGIResponse.run.<locals>.wsgiFinishå  s3   ø€ Ø×,×,Ð,ß"Ø×1Ñ1Ô3Ø—L‘L×'Ñ'Ö)ñ -r   c                 ó  <€ SP                   P                  R \        W!V4      R7       V '       d   SP                  P	                  4        R# SP                  P                  \        4       SP                  P                  4        R# )zWSGI application error)ÚfailureN)r3   r×   r
   r‡   ÚloseConnectionrÄ   r   rÓ   )rƒ   r1   rÉ   Ú	tracebackr5   s   &&&&€r   Ú	wsgiErrorÚ$_WSGIResponse.run.<locals>.wsgiErrorØ  s^   ø€ Ø—	‘	×!Ñ!Ø,´g¸eÈ9Ó6Uð "ô ÷ Ø—L‘L×/Ñ/Ö1à—L‘L×0Ñ0Ô1FÔGØ—L‘L×'Ñ'Ö)r   T)r†   r˜   r¸   r6   rª   Úgetattrr„   ÚcallFromThreadrƒ   ÚBaseExceptionr   )r5   ÚappIteratorr·   rÑ   rÔ   rÚ   s   f     r   rÍ   Ú_WSGIResponse.runÅ  sÇ   ø€ ð	BØ×*Ñ*¨4¯<©<¸×9KÑ9KÓLˆKÛ#�ßØ—J‘J˜tÔ$Ø×(×(Ò(Ùñ	 $ô
 ˜K¨°$Ó7ˆEØÒ Ù”õ *ð �L‰L×'Ñ'¨
°D·L±LÔAØˆŽøô- ô 	Nõ*ð �L‰L×'Ò'¨	°4·<±<ÐMÄ(Ã*ÖMð	Nús   ƒAB, ÁB, Â,AC1Ã0C1)	rª   r†   r˜   r´   r„   r‡   rƒ   r³   r…   rc   )r2   rD   rE   rF   rG   rª   r	   r3   rQ   rŠ   r¸   r6   r¼   rÎ   rÍ   rH   rI   rJ   s   @r   re   re   ½   sG   ø‡ € ñðB ÐÙ‹8€DòN
ò`%ôCòJ) òVò(/÷'ð 'r   re   c                   ó@   a € ] tR tRt o RtRtR tR tR tR t	Rt
V tR	# )
ÚWSGIResourceiï  a/  
An L{IResource} implementation which delegates responsibility for all
resources hierarchically inferior to it to a WSGI application.

The C{environ} argument passed to the application, includes the
C{REMOTE_PORT} key to complement the C{REMOTE_ADDR} key.

@ivar _reactor: An L{IReactorThreads} provider which will be passed on to
    L{_WSGIResponse} to schedule calls in the I/O thread.

@ivar _threadpool: A L{ThreadPool} which will be passed on to
    L{_WSGIResponse} to run the WSGI application object.

@ivar _application: The WSGI application object.
Tc                ó*   € Wn         W n        W0n        R # rc   )Ú_reactorÚ_threadpoolÚ_application)r5   r„   r…   r†   s   &&&&r   rQ   ÚWSGIResource.__init__  s   € ØŒØ%ÔØ'Ör   c                ó†   € \        V P                  V P                  V P                  V4      pVP	                  4        \
        # )a†  
Turn the request into the appropriate C{environ} C{dict} suitable to be
passed to the WSGI application object and then pass it on.

The WSGI application object is given almost complete control of the
rendering process.  C{NOT_DONE_YET} will always be returned in order
and response completion will be dictated by the application object, as
will the status, headers, and the response body.
)re   rä   rå   ræ   rÎ   r   )r5   r‡   Úresponses   && r   ÚrenderÚWSGIResource.render
  s9   € ô !Ø�M‰M˜4×+Ñ+¨T×->Ñ->Àó
ˆð 	�‰ÔÜÐr   c                ó   € \        R4      h)z›
Reject attempts to retrieve a child resource.  All path segments beyond
the one which refers to this resource are handled by the WSGI
application object.
z/Cannot get IResource children from WSGIResource©ÚRuntimeError)r5   r¦   r‡   s   &&&r   ÚgetChildWithDefaultÚ WSGIResource.getChildWithDefault  s   € ô ÐLÓMÐMr   c                ó   € \        R4      h)z¶
Reject attempts to add a child resource to this resource.  The WSGI
application object handles all path segments beneath this resource, so
L{IResource} children can never be found.
z0Cannot put IResource children under WSGIResourcerí   )r5   ÚpathÚchilds   &&&r   ÚputChildÚWSGIResource.putChild"  s   € ô ÐMÓNÐNr   )ræ   rä   rå   N)r2   rD   rE   rF   rG   ÚisLeafrQ   rê   rï   rô   rH   rI   rJ   s   @r   râ   râ   ï  s-   ø‡ € ñð$ €Fò(ò
ò N÷Oð Or   râ   N)rG   Úcollections.abcr   Úsysr   Útypingr   r   Úwarningsr   Úzope.interfacer   Útwisted.internet.threadsr   Útwisted.loggerr	   Útwisted.python.failurer
   Útwisted.web.httpr   Útwisted.web.resourcer   Útwisted.web.serverr   r   r"   r$   rL   re   râ   Ú__all__r@   r   r   Ú<module>r     s†   ðñõ
 %Ý ß Ý å &å ;Ý !Ý *Ý 2Ý *Ý +õ +õ$
'÷7ñ 7÷t<#ñ <#÷~oñ oñd	 ˆYÓ÷8Oð 8Oó ð8Oðv Ð
‚r   