N
ήωO5c       s   d  Z  d Z k Z k Z k Z k Z k Z k Z k Z k	 Z	 d e	 i
 f d     YZ e Z d   Z d   Z e e i d  Z e d j o e   n d S(	   sz   CGI-savvy HTTP Server.

This module builds on SimpleHTTPServer by implementing GET and POST
requests to cgi-bin scripts.

s   0.3s   CGIHTTPRequestHandlerc      s8   d  Z  d   Z d   Z d   Z d d g 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.

    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(   s   selfs   is_cgis   run_cgis
   send_error(   s   selfs7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   do_POST  s     c    s/   |  i   o |  i   Sn t i i |   Sd S(   s-   Version of send_head that support CGI scriptsN(   s   selfs   is_cgis   run_cgis   SimpleHTTPServers   SimpleHTTPRequestHandlers	   send_head(   s   selfs7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys	   send_head, s     c    s   |  i } xp |  i d rc } t |  } | |  | j o | | p | | d j o# | |  | | d f |  _ d Sn q Wd Sd S(   s§  test whether PATH corresponds to a CGI script.

        Return a tuple (dir, rest) if PATH requires running a
        CGI script, None if not.  Note that rest begins with a
        slash if it is not empty.

        The default implementation tests whether the path
        begins with one of the strings in the list
        self.cgi_directories (and the next character is a '/'
        or the end of the string).

        i    s   /i   N(   s   selfs   paths   cgi_directoriess   xs   lens   is   cgi_info(   s   selfs   paths   xs   is7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   is_cgi3 s     	 .s   /cgi-bins   /htbinc    sa  |  i \ } } t i | d  } | d j o" | |  | | d f \ } } n d } t i | d  } | d j o | |  | | f \ } } n | d f \ } } | d | } |  i |  } t i i |  o |  i d d |  d Sn t i i |  o |  i d	 d
 |  d Sn t |  o |  i d	 d |  d Sn t   } |  i d d  |  i i   t i   }	 |	 d j o< t i |	 d  \ }	 }
 |
 o |  i d |
  n d Sn yc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 <|  i+ i- d  } | o | | d <n g  } xa |  i+ i0 d  d rK } | d  t i2 j o | i3 t i4 |   n | t i5 | d   } q	Wt i6 | d!  | d" <|  i+ i- d#  } | o | | d$ <n t i8 | d% d&  } y t i: |  Wn t i; j
 o n Xt i< |  i= i>   d  t i< |  i i>   d  | G| G| GHt i? | | | g |  Wn- |  i i@ |  iA |  i*  t iB d'  n Xd S((   s   Execute a CGI script.s   ?i    i   s    s   /i  s   No such CGI script (%s)Ni  s#   CGI script is not a plain file (%s)s!   CGI script is not executable (%s)iΘ   s   Script output followss   CGI script exit status x%xs   SERVER_SOFTWAREs   SERVER_NAMEs   CGI/1.1s   GATEWAY_INTERFACEs   SERVER_PROTOCOLs   SERVER_PORTs   REQUEST_METHODs	   PATH_INFOs   PATH_TRANSLATEDs   SCRIPT_NAMEs   QUERY_STRINGs   REMOTE_HOSTs   REMOTE_ADDRs   CONTENT_TYPEs   content-lengths   CONTENT_LENGTHs   accepti   s   ,s   HTTP_ACCEPTs
   user-agents   HTTP_USER_AGENTs   +s    i   (C   s   selfs   cgi_infos   dirs   rests   strings   rfinds   is   querys   finds   scripts
   scriptnames   translate_paths
   scriptfiles   oss   paths   existss
   send_errors   isfiles
   executables
   nobody_uids   nobodys   send_responses   wfiles   flushs   forks   pids   waitpids   stss	   log_errors   envs   version_strings   servers   server_names   protocol_versions   strs   server_ports   commands   urllibs   unquotes   uqrests   address_strings   hosts   client_addresss   headerss   types	   getheaders   lengths   accepts   getallmatchingheaderss   lines
   whitespaces   appends   strips   splits
   joinfieldss   uas   replaces   decoded_querys   setuids   errors   dup2s   rfiles   filenos   execves   handle_errors   requests   _exit(   s   selfs   dirs   rests   is   querys   scripts
   scriptnames
   scriptfiles   nobodys   pids   stss   envs   uqrests   hosts   lengths   accepts   lines   uas   decoded_querys7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   run_cgiL s     "	


 (   s   __doc__s   do_POSTs	   send_heads   is_cgis   cgi_directoriess   run_cgi(    s7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   CGIHTTPRequestHandler s    			c     so   t  o t  Sn k }  y |  i d  d a  Wn8 |  i j
 o) d t t d   |  i     a  n Xt  Sd S(   s$   Internal routine to get nobody's uids   nobodyi   i   c    s   |  d S(   Ni   (   s   x(   s   xs7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   <lambda>² s    N(   s   nobodys   pwds   getpwnams   errors   maxs   maps   getpwall(   s   pwds7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys
   nobody_uid© s      'c    sF   y t  i |   } Wn t  i j
 o d Sn X| d d @d j Sd S(   s   Test for executable file.i    iI   N(   s   oss   stats   paths   sts   error(   s   paths   sts7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys
   executableΆ s     	c    s   t  i |  |  d  S(   N(   s   SimpleHTTPServers   tests   HandlerClasss   ServerClass(   s   HandlerClasss   ServerClasss7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   testΏ s    s   __main__N(   s   __doc__s   __version__s   oss   syss   times   sockets   strings   urllibs   BaseHTTPServers   SimpleHTTPServers   SimpleHTTPRequestHandlers   CGIHTTPRequestHandlers   Nones   nobodys
   nobody_uids
   executables
   HTTPServers   tests   __name__(    s7   /var/tmp/python-root/usr/lib/python1.5/CGIHTTPServer.pys   ? s    			