The usual...

This commit is contained in:
Guido van Rossum 2000-05-08 17:31:04 +00:00
parent 0b095bc092
commit aad6761cce
56 changed files with 5040 additions and 656 deletions

View file

@ -3,6 +3,9 @@
This module builds on SimpleHTTPServer by implementing GET and POST
requests to cgi-bin scripts.
If the os.fork() function is not present, this module will not work;
SystemError will be raised instead.
"""
@ -10,15 +13,18 @@ __version__ = "0.3"
import os
import sys
import time
import socket
import string
import urllib
import BaseHTTPServer
import SimpleHTTPServer
try:
os.fork
except AttributeError:
raise SystemError, __name__ + " requires os.fork()"
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
"""Complete HTTP server with GET, HEAD and POST commands.
@ -150,6 +156,9 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
ua = self.headers.getheader('user-agent')
if ua:
env['HTTP_USER_AGENT'] = ua
co = filter(None, self.headers.getheaders('cookie'))
if co:
env['HTTP_COOKIE'] = string.join(co, ', ')
# XXX Other HTTP_* headers
decoded_query = string.replace(query, '+', ' ')
try:
@ -177,7 +186,7 @@ def nobody_uid():
import pwd
try:
nobody = pwd.getpwnam('nobody')[2]
except pwd.error:
except KeyError:
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
return nobody