
La¸2c      sÕ     d  Z   d  	 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     sQ    d  Z   d    d „  Z , d „  Z 3 d „  Z J d d g Z L 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   sB     % d  ' |  i ƒ  o ( |  i ƒ  n * |  i d d ƒ d S(   sD   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   selfs#   /usr/lib/python1.4/CGIHTTPServer.pys   do_POSTc   sB   , - d  . |  i ƒ  o / |  i ƒ  Sn 1 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   selfs#   /usr/lib/python1.4/CGIHTTPServer.pys	   send_headc   s¦   3 ? d  A |  i } C x |  i d C ro } D t | ƒ } E | |  | j o | | p | | d j o) F | |  | | d f |  _ G d Sn q% WH d Sd S(   so  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   is#   /usr/lib/python1.4/CGIHTTPServer.pys   is_cgis   /cgi-bins   /htbinc   sO  L M d  N |  i \ } } O t i | d ƒ } P | d j o% Q | |  | | d f \ } } n
 S d } T t i | d ƒ } U | d j o! V | |  | | f \ } } n X | d f \ } } Y | d | } Z |  i | ƒ } [ t i i | ƒ o# \ |  i d d | ƒ ] d Sn ^ t i i | ƒ o# _ |  i d	 d
 | ƒ a d Sn b t | ƒ o# c |  i d	 d | ƒ e d Sn f t ƒ  } g |  i d d ƒ h |  i i ƒ  i t i ƒ  }	 j |	 d j oH l t i |	 d ƒ \ }	 }
 m |
 o n |  i d |
 ƒ n o d Sn q yät h  } u |  i ƒ  | d <v |  i i  | d <w d | d <x |  i! | d <y t" |  i i# ƒ | d <z |  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  }  xm |  i+ i0 d ƒ d  rT } Ž | d  t i2 j o  | i3 t i4 | ƒ ƒ n ‘ | t i5 | d  ƒ } q²W’ t i6 | d! ƒ | d" <“ |  i+ i- d# ƒ } ” | o • | | d$ <n — k8 } ˜ | i9 d% d& | ƒ } ™ y š t i; | ƒ Wn › t i< j
 o
 œ n X t i= |  i> i? ƒ  d ƒ ž t i= |  i i? ƒ  d ƒ Ÿ | G| G| GH  t i@ | | | g | ƒ Wn6 £ ¤ |  i iA |  iB |  i* ƒ ¥ t iC 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   (D   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   regsubs   gsubs   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   regsubs   decoded_querys#   /usr/lib/python1.4/CGIHTTPServer.pys   run_cgi(   s   __doc__s   do_POSTs	   send_heads   is_cgis   cgi_directoriess   run_cgi(    s#   /usr/lib/python1.4/CGIHTTPServer.pys   CGIHTTPRequestHandlerc    s”   ª « d  ¬ ­ t  o ® t  Sn ¯ k }  ° y ± |  i d ƒ d a  Wn> ² |  i j
 o, ³ d t t d „  |  i ƒ  ƒ ƒ a  n X´ t  Sd S(   s$   Internal routine to get nobody's uids   nobodyi   i   c   s   ³ |  d S(   Ni   (   s   x(   s   xs#   /usr/lib/python1.4/CGIHTTPServer.pys   <lambda>N(   s   nobodys   pwds   getpwnams   errors   maxs   maps   getpwall(   s   pwds#   /usr/lib/python1.4/CGIHTTPServer.pys
   nobody_uidc   s_   · ¸ d  ¹ 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   sts#   /usr/lib/python1.4/CGIHTTPServer.pys
   executablec   sd   À Â k  } Ã | i d d !d g j o$ Ä t ƒ  } Å | i ƒ  Æ d  Sn Ç t i |  | ƒ d  S(   Ni   i   s   -r(	   s   syss   argvs	   MyArchives   dbs   regenindicess   SimpleHTTPServers   tests   HandlerClasss   ServerClass(   s   HandlerClasss   ServerClasss   syss   dbs#   /usr/lib/python1.4/CGIHTTPServer.pys   tests   __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__(    s#   /usr/lib/python1.4/CGIHTTPServer.pys   ?