Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/web/__pycache__/twcgi.cpython-310.pyc
o

�b�.�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZGdd	�d	e
jej�ZGd
d�de
j�ZGdd
�d
e�ZGdd�deje
j�ZdS)zH
I hold resource classes and helper classes that deal with CGI scripts.
�N)�protocol)�Logger)�filepath)�pb)�http�resource�server�staticc@s$eZdZdd�Zdd�Zdd�ZdS)�CGIDirectorycCstj�|�tj�||�dS�N)r�Resource�__init__r�FilePath)�self�pathname�r�3/usr/lib/python3/dist-packages/twisted/web/twcgi.pyr
szCGIDirectory.__init__cCs6|�|�}|��s
tjjS|��rt|j�St|j�Sr)	�child�existsr	�File�
childNotFound�isdirr
�path�	CGIScript)rr�request�fnprrr�getChilds


zCGIDirectory.getChildcCst�d�}|�|�S)Nz1CGI directories do not support directory listing.)r�
NoResource�render)rr�notFoundrrrr$s�
zCGIDirectory.renderN)�__name__�
__module__�__qualname__r
rrrrrrr
s	r
c@s2eZdZdZdZd
dd�Zdd�Zgfdd	�ZdS)rz�
    L{CGIScript} is a resource which runs child processes according to the CGI
    specification.

    The implementation is complex due to the fact that it requires asynchronous
    IPC with an external process with an unpleasant protocol.
    �NcCs$||_|dur
ddlm}||_dS)zA
        Initialize, with the name of a CGI script file.
        Nr)�reactor)�filename�twisted.internetr$�_reactor)rr%�registryr$rrrr
6s
zCGIScript.__init__c
Cs�dd�|j�}|���d�d}tj|d|jt|��j	�|j
||j|jd�	}|�
�j}|dur4||d<|j}|rBdd�|�|d	<t|d
�r`|j�dd�|j��}|j�dd�t|�|d<z|j�d
�}Wntywd|d<g}	Ynw|j|dd�}
|d<d|
vr�g}	n
dd�|
�d�D�}	|����D]\}}|�dd���}
|dvr�d|
}
|||
<q�tj��D]\}}||vr�|||<q�|�|||	�tjS)a
        Do various things to conform to the CGI specification.

        I will set up the usual slew of environment variables, then spin off a
        process.

        @type request: L{twisted.web.http.Request}
        @param request: An HTTP request.
        �/�:rzCGI/1.1)	�SERVER_SOFTWARE�SERVER_NAME�GATEWAY_INTERFACE�SERVER_PROTOCOL�SERVER_PORT�REQUEST_METHOD�SCRIPT_NAME�SCRIPT_FILENAME�REQUEST_URIN�REMOTE_ADDR�/�	PATH_INFO�content��CONTENT_LENGTH�?��QUERY_STRINGr#�=cSsg|]
}tj�|����qSr)�urllib�parse�unquote�decode)�.0�xrrr�
<listcomp>ssz$CGIScript.render.<locals>.<listcomp>�+�-�_)scontent-typescontent-lengthsproxysHTTP_)�join�prepath�getRequestHostname�splitr�version�clientproto�str�getHost�port�methodr%�uri�getClientAddress�host�postpath�hasattrr7�seek�tell�index�
ValueError�
getAllHeaders�items�replace�upper�os�environ�
runProcess�NOT_DONE_YET)rr�
scriptName�
serverName�env�ip�pp�length�qindex�qargs�qs�title�header�envname�key�valuerrrrBsX
�


�
�zCGIScript.renderc	Cs4t|�}|j�||j|jg||tj�|j��dS)aI
        Run the cgi script.

        @type env: A L{dict} of L{str}, or L{None}
        @param env: The environment variables to pass to the process that will
            get spawned. See
            L{twisted.internet.interfaces.IReactorProcess.spawnProcess} for
            more information about environments and process creation.

        @type request: L{twisted.web.http.Request}
        @param request: An HTTP request.

        @type qargs: A L{list} of L{str}
        @param qargs: The command line arguments to pass to the process that
            will get spawned.
        N)�CGIProcessProtocolr'�spawnProcessr%r_r�dirname�rrerrj�prrrra�s
�zCGIScript.runProcess)NN)r r!r"�__doc__�isLeafr
rrarrrrr+s
Arc@s eZdZdZdZgfdd�ZdS)�FilteredScripta
    I am a special version of a CGI script, that uses a specific executable.

    This is useful for interfacing with other scripting languages that adhere
    to the CGI standard. My C{filter} attribute specifies what executable to
    run, and my C{filename} init parameter describes which script to pass to
    the first argument of that script.

    To customize me for a particular location of a CGI interpreter, override
    C{filter}.

    @type filter: L{str}
    @ivar filter: The absolute path to the executable.
    z/usr/bin/catc	Cs8t|�}|j�||j|j|jg||tj�|j��dS)ad
        Run a script through the C{filter} executable.

        @type env: A L{dict} of L{str}, or L{None}
        @param env: The environment variables to pass to the process that will
            get spawned. See
            L{twisted.internet.interfaces.IReactorProcess.spawnProcess}
            for more information about environments and process creation.

        @type request: L{twisted.web.http.Request}
        @param request: An HTTP request.

        @type qargs: A L{list} of L{str}
        @param qargs: The command line arguments to pass to the process that
            will get spawned.
        N)rqr'rr�filterr%r_rrsrtrrrra�s�zFilteredScript.runProcessN)r r!r"rvryrarrrrrx�srxc@s�eZdZdZdZdZdZe�ZdZ	dd�Z
dd�Zd	d
�Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)rqr#r�FcC�|��dSr)�resumeProducing�r�issuerrrr�view_resumeProducing��z'CGIProcessProtocol.view_resumeProducingcCr{r)�pauseProducingr}rrr�view_pauseProducing�r�z&CGIProcessProtocol.view_pauseProducingcCr{r)�
stopProducingr}rrr�view_stopProducing�r�z%CGIProcessProtocol.view_stopProducingcC�|j��dSr)�	transportr|�rrrrr|��z"CGIProcessProtocol.resumeProducingcCr�r)r�r�r�rrrr��r�z!CGIProcessProtocol.pauseProducingcCr�r)r��loseConnectionr�rrrr��r�z CGIProcessProtocol.stopProducingcCs||_|j���|j�dSr)r�notifyFinish�addBoth�	_finished)rrrrrr
�szCGIProcessProtocol.__init__cCsH|j�|d�|jj�dd�|jj��}|r|j�|�|j��dS)Nr#r)r�registerProducerr7rW�readr��write�
closeStdin)rr7rrr�connectionMade�sz!CGIProcessProtocol.connectionMadecCs|j||_dSr)�	errortext)r�errorrrr�errReceived�szCGIProcessProtocol.errReceivedc
	Cs�|jr�|j|}g}dD]}|�|�}|dkr|�||f�q|r�d|j_|��|d\}}|d|�|_|dt|�d�}|j�|�}|D]b}|�d�}	|	dkr\|j	j
d|d�qH|d|	���}
||	dd�}|
d	krw|j�t
j�|
d
kr�z
t|dd��}Wnty�|j	�
d�YqHw|j�|�qH|
��d
vr�|jj�|
|�qH||t|�d�}d|_|jr�||_|js�|j�|�dSdS)z)
        Handle a chunk of input
        )s

s

s

s

���Nrr8s: z)ignoring malformed CGI header: {header!r})rmslocationsstatus�zmalformed status header)sserversdate)�handling_headers�
headertext�find�appendr�defaultContentType�sort�lenrK�_logr��lower�setResponseCoder�FOUND�int�
BaseException�responseHeaders�addRawHeaderr�)
r�output�text�
headerEnds�	delimiter�	headerend�	linebreak�headersrm�br�
headerName�
headerText�	statusNumrrr�outReceived�sX

�
�����zCGIProcessProtocol.outReceivedcCs�|jjdkr|jjd|jj|jjd�|jr"|jjd|jj|jd�|jrD|jjd|jj|jd�|j	sD|j�
t�t
jdd	��|j��|j	sS|j��|j��dSdS)
Nrz*CGI {uri} exited with exit code {exitCode})rR�exitCodez"Errors from CGI {uri}: {errorText})rR�	errorTextz/Premature end of headers in {uri}: {headerText})rRr�zCGI Script Errorz Premature end of script headers.)rpr�r�r�rrRr�r�r��_requestFinishedr�r�	ErrorPager�INTERNAL_SERVER_ERRORr�unregisterProducer�finish)r�reasonrrr�processEnded0s>�����
�zCGIProcessProtocol.processEndedcCs
d|_dS)zc
        Record the end of the response generation for the request being
        serviced.
        TN)r�)r�ignoredrrrr�Qs
zCGIProcessProtocol._finishedN)r r!r"r��headers_writtenr�r�rr�r�rr�r�r|r�r�r
r�r�r�r�r�rrrrrq�s&:!rq)rvr_r>r&r�twisted.loggerr�twisted.pythonr�twisted.spreadr�twisted.webrrrr	rrr
rrx�ProcessProtocol�Viewablerqrrrr�<module>ss-

Spamworldpro Mini