-í
æ¶<c       sÑ     d  Z    d Z  d g Z  d k Z  d k Z  d k Z  d k Z  d k Z  d e i f d „  ƒ  YZ	 e
 a !d „  Z 1d „  Z :e	 e i d „ Z ?e d j o @e ƒ  n d S(	   sr  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.

s   0.4s   CGIHTTPRequestHandlerNc      sª    t  Z d  Z ' * e e d ƒ Z + e e d ƒ Z , e e d ƒ Z 0 d Z 2 d „  Z	 > d „  Z
 E d „  Z \ d d	 g Z ^ d
 „  Z b d „  Z g 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.

    s   forks   popen2s   popen3i    c    s>   2 7 9 |  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   self(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   do_POST2 s   c    s>   > ? @ |  i ƒ  o A |  i ƒ  Sn C 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   self(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys	   send_head> s   c    s    E Q S |  i } U x} |  i DU ]o } V t | ƒ } W | |  | j o | | p | | d j o) X | |  | | d f |  _ Y d Sn q WZ d Sd S(   s±  Test whether self.path corresponds to a CGI script.

        Return a tuple (dir, rest) if self.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).

        s   /i   i    N(   s   selfs   paths   cgi_directoriess   xs   lens   is   cgi_info(   s   selfs   is   paths   x(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   is_cgiE s    	1s   /cgi-bins   /htbinc    s   ^ _ ` t  | ƒ Sd S(   s1   Test whether argument path is an executable file.N(   s
   executables   path(   s   selfs   path(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   is_executable^ s   c    s>   b c d t  i i | ƒ \ } } e | i ƒ  d d f j Sd S(   s.   Test whether argument path is a Python script.s   .pys   .pywN(   s   oss   paths   splitexts   heads   tails   lower(   s   selfs   paths   tails   head(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys	   is_pythonb s   c &   sU
  g h i |  i \ }% }
 j |
 i d ƒ } k | d j o% l |
 |  |
 | d f \ }
 }	 n
 n d }	 o |
 i d ƒ } p | d j o! q |
 |  |
 | f \ } }
 n s |
 d f \ } }
 t |% d | } u |  i
 | ƒ }# v t i i |# ƒ o# w |  i d d | ƒ x d Sn y t i i |# ƒ o# z |  i d	 d
 | ƒ | d Sn } |  i | ƒ } ~ | o€  |  i p |  i p |  i o# € |  i d	 d | ƒ ‚ d Sn ƒ |  i |# ƒ o# „ |  i d	 d | ƒ † d Sn n Š 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& t' j o Ÿ |  i% i( | d <n ¡ |  i% i& | d <¢ |  i% i) d ƒ }" £ |" o ¤ |" | d <n ¥ g  } ¦ xe |  i% i, d ƒ D¦ ]N } § | d  d j o ¨ | i. | i/ ƒ  ƒ n ª | | d i0 d  ƒ } q W« d  i1 | ƒ | d! <¬ |  i% i) d" ƒ }  ­ |  o ® |  | d# <n ¯ t3 t' |  i% i4 d$ ƒ ƒ } ° | o ± d% i1 | ƒ | d& <n ³ |  i o= ¶ x3 d d d d# d& f D¶ ] }! ¸ | i7 |! d ƒ q¤Wn º |  i8 d' d( ƒ ¼ |	 i9 d) d* ƒ } ¾ |  i oŠÀ | g } Á d+ | j o Â | i. | ƒ n Ã t< ƒ  } Ä |  i> i? ƒ  Å |  i@ i? ƒ  Æ t iA ƒ  } Ç | d j oG É t iC | d ƒ \ } }$ Ê |$ o Ë |  iE d, |$ ƒ n Ì d Sn Î yˆ Ï y Ð t iF | ƒ Wn Ñ t iG j
 o
 Ò n XÓ t iH |  i> iI ƒ  d ƒ Ô t iH |  i@ iI ƒ  d ƒ Õ t iJ |# | | ƒ Wn6 Ö × |  i iK |  iL |  i$ ƒ Ø t iM d- ƒ n XnËÚ |  i p |  i ozÜ d kN } Ý |  i o Þ t iO } n à t iQ } á t iR iS | ƒ â |# } ã |  i |# ƒ oU ä tU iV } å | iX ƒ  iY d. ƒ o ç | d/  | d0 } n è d1 | | f } n é d+ |	 j o
 d2 |	 j o ê d3 | |	 f } n ë |  iZ d4 | ƒ ì y í t[ |" ƒ } Wn î ï d } n Xð | | d5 ƒ } ñ | d } ò | d } ó |  i o ô | d6 } n õ |  i iX ƒ  d7 j o
 | d j o) ö |  i> ia | ƒ } ÷ | ic | ƒ n ø | id ƒ  ù | ie | |  i@ ƒ ú |  i oA û | ia ƒ  } ü | id ƒ  ý | o þ |  iE d8 | ƒ n n ÿ | id ƒ  }$  |$ o |  iE d, |$ ƒ n |  iZ d9 ƒ n:t iR iS | ƒ tU ig } 	tU ii } 
tU ik } tU im } y¯ zq |# g tU _g d+ | j o tU ig i. | ƒ n |  i@ tU _k |  i> tU _i to |# h  d: d; <ƒ Wd | tU _g | tU _i | tU _k | tU _m XWn1 tp j
 o" }$ |  iE d< t |$ ƒ ƒ n X|  iZ d9 ƒ d 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 a Python script (%s)s!   CGI script is not executable (%s)s   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   accepts   	
 i   s   ,s   HTTP_ACCEPTs
   user-agents   HTTP_USER_AGENTs   cookies   , s   HTTP_COOKIEiÈ   s   Script output followss   +s    s   =s   CGI script exit status %#xi   s   w.exeiûÿÿÿiüÿÿÿs   %s -u %ss   "s   %s "%s"s   command: %ss   bi   s   posts   %ss   CGI script exited OKs   __main__s   __name__s   CGI script exit status %s(q   s   selfs   cgi_infos   dirs   rests   rfinds   is   querys   finds   scripts
   scriptnames   translate_paths
   scriptfiles   oss   paths   existss
   send_errors   isfiles	   is_pythons   ispys	   have_forks   have_popen2s   have_popen3s   is_executables   envs   version_strings   servers   server_names   protocol_versions   strs   server_ports   commands   urllibs   unquotes   uqrests   address_strings   hosts   client_addresss   headerss
   typeheaders   Nones   types	   getheaders   lengths   accepts   getallmatchingheaderss   lines   appends   strips   splits   joins   uas   filters
   getheaderss   cos   ks
   setdefaults   send_responses   replaces   decoded_querys   argss
   nobody_uids   nobodys   rfiles   flushs   wfiles   forks   pids   waitpids   stss	   log_errors   setuids   errors   dup2s   filenos   execves   handle_errors   requests   _exits   shutils   popen3s   popenxs   popen2s   environs   updates   cmdlines   syss
   executables   interps   lowers   endswiths   log_messages   ints   nbytess   filess   fis   fos   fes   reads   datas   writes   closes   copyfileobjs   errorss   argvs	   save_argvs   stdins
   save_stdins   stdouts   save_stdouts   stderrs   save_stderrs   execfiles
   SystemExit(&   s   selfs   save_stdouts   cos	   save_argvs   interps   uqrests   cmdlines
   scriptnames
   save_stdins   querys   rests   shutils   decoded_querys   errorss   scripts   accepts   envs   nbytess   filess   argss   ispys   popenxs   pids   nobodys   hosts   fes   fis   lines   datas   save_stderrs   fos   is   uas   ks   lengths
   scriptfiles   stss   dir(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   run_cgig s.  %	!"	

	 	

 	
	&

(   s   __name__s
   __module__s   __doc__s   hasattrs   oss	   have_forks   have_popen2s   have_popen3s   rbufsizes   do_POSTs	   send_heads   is_cgis   cgi_directoriess   is_executables	   is_pythons   run_cgi(    (    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   CGIHTTPRequestHandler s   	c     s·   !"#$t  o %t  Sn &y 'd k }  Wn (t j
 o )d Sn X*y +|  i d ƒ d a  Wn; ,t j
 o, -d t t d „  |  i ƒ  ƒ ƒ a  n X.t  Sd S(   s$   Internal routine to get nobody's uidNiÿÿÿÿs   nobodyi   i   c    s   -|  d S(   Ni   (   s   x(   s   x(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   <lambda>-s    (   s   nobodys   pwds   ImportErrors   getpwnams   KeyErrors   maxs   maps   getpwall(   s   pwd(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys
   nobody_uid!s   
*c    s[   123y 4t  i |  ƒ } Wn  5t  i j
 o 6d Sn X7| d d @d j Sd S(   s   Test for executable file.i    iI   N(   s   oss   stats   paths   sts   error(   s   paths   st(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys
   executable1s   c    s   :<t  i |  | ƒ d  S(   N(   s   SimpleHTTPServers   tests   HandlerClasss   ServerClass(   s   HandlerClasss   ServerClass(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   test:s   s   __main__(   s   __doc__s   __version__s   __all__s   oss   syss   urllibs   BaseHTTPServers   SimpleHTTPServers   SimpleHTTPRequestHandlers   CGIHTTPRequestHandlers   Nones   nobodys
   nobody_uids
   executables
   HTTPServers   tests   __name__(   s   __all__s   SimpleHTTPServers
   executables   urllibs   CGIHTTPRequestHandlers   syss   tests
   nobody_uids   BaseHTTPServers   __version__s   os(    (    s#   /usr/lib/python2.2/CGIHTTPServer.pys   ? s   	ÿ 		