ACC SHELL
Path : /usr/lib/python/ |
|
Current File : //usr/lib/python/CGIHTTPServer.pyc |
Ńň
nÄMc @ sĹ d Z d Z d g Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d e i f d YZ
d Z e a
d Z d Z e
e i d Z e d
j o e n d S( sú CGI-savvy HTTP Server.
This module builds on SimpleHTTPServer by implementing GET and POST
requests to cgi-bin scripts.
If the os.fork() function is not present (e.g. on Windows),
os.popen2() is used as a fallback, with slightly altered semantics; if
that function is not present either (e.g. on Macintosh), only Python
scripts are supported, and they are executed by the current process.
In all cases, the implementation is intentionally naive -- all
requests are executed sychronously.
SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.
Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).
s 0.4t CGIHTTPRequestHandleri˙˙˙˙Nc B s e Z d Z e e d Z e e d Z e e d Z d Z d Z d Z
d Z d d g Z d
Z
d Z d Z RS(
s Complete HTTP server with GET, HEAD and POST commands.
GET and HEAD also support running CGI scripts.
The POST command is *only* implemented for CGI scripts.
t forkt popen2t popen3i c C s/ | i o | i n | i d d d S( sR Serve a POST request.
This is only implemented for CGI scripts.
iő s Can only POST to CGI scriptsN( t is_cgit run_cgit
send_error( t self( ( s# /usr/lib/python2.6/CGIHTTPServer.pyt do_POST5 s
c C s, | i o | i St i i | Sd S( s- Version of send_head that support CGI scriptsN( R R t SimpleHTTPServert SimpleHTTPRequestHandlert send_head( R ( ( s# /usr/lib/python2.6/CGIHTTPServer.pyR A s
c C s5 t | i } | d | i j o | | _ t St S( s° Test whether self.path corresponds to a CGI script.
Returns True and updates the cgi_info attribute to the tuple
(dir, rest) if self.path requires running a CGI script.
Returns False otherwise.
The default implementation tests whether the normalized url
path begins with one of the strings in self.cgi_directories
(and the next character is a '/' or the end of the string).
i ( t _url_collapse_path_splitt patht cgi_directoriest cgi_infot Truet False( R t splitpath( ( s# /usr/lib/python2.6/CGIHTTPServer.pyR H s
s /cgi-bins /htbinc C s
t | S( s1 Test whether argument path is an executable file.( t
executable( R R
( ( s# /usr/lib/python2.6/CGIHTTPServer.pyt
is_executable[ s c C s( t i i | \ } } | i d j S( s. Test whether argument path is a Python script.s .pys .pyw( s .pys .pyw( t osR
t splitextt lower( R R
t headt tail( ( s# /usr/lib/python2.6/CGIHTTPServer.pyt is_python_ s c ( C s | i } | i \ } } | i d t | d } xz | d j ol | | } | | d } | i | } t i i | o- | | } } | i d t | d } q7 Pq7 W| i d } | d j o | | | | d } } n d } | i d } | d j o | | | | } } n | d } } | d | }
| i |
} t i i | p | i d d |
d St i i
| p | i d d
|
d S| i |
} | pd | i p | i
p | i p | i d d |
d S| i | p | i d d |
d Sn h }
| i |
d
<| i i |
d <d |
d <| i |
d <t | i i |
d <| i |
d <t i | } | |
d <| i | |
d <|
|
d <| o | |
d <n | i } | | i d j o | |
d <n | i d |
d <| i i d } | oĚ | i } t | d j oŠ d d k } d d k } | d |
d <| d i d j oh y | i! | d } Wn | i"