summaryrefslogtreecommitdiffstats
path: root/Lib/CGIHTTPServer.py
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-10-03 18:16:52 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-10-03 18:16:52 (GMT)
commita9bd0cc67e77d465ae747071377407f00d62f19c (patch)
treea1a14bedc803b1b128d7868f52f8842003205836 /Lib/CGIHTTPServer.py
parentec2ee17cf8a94f637f195ba8fd32399a27e08c9f (diff)
downloadcpython-a9bd0cc67e77d465ae747071377407f00d62f19c.zip
cpython-a9bd0cc67e77d465ae747071377407f00d62f19c.tar.gz
cpython-a9bd0cc67e77d465ae747071377407f00d62f19c.tar.bz2
Merged revisions 85202 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85202 | senthil.kumaran | 2010-10-03 23:25:45 +0530 (Sun, 03 Oct 2010) | 4 lines Fix Issue9272 - Change CGIHTTPServer to give the child program a copy of os.environ ........
Diffstat (limited to 'Lib/CGIHTTPServer.py')
-rw-r--r--Lib/CGIHTTPServer.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
index e8494a4..ed37348 100644
--- a/Lib/CGIHTTPServer.py
+++ b/Lib/CGIHTTPServer.py
@@ -29,6 +29,7 @@ import urllib
import BaseHTTPServer
import SimpleHTTPServer
import select
+import copy
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
@@ -154,7 +155,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
# XXX Much of the following could be prepared ahead of time!
- env = {}
+ env = copy.deepcopy(os.environ)
env['SERVER_SOFTWARE'] = self.version_string()
env['SERVER_NAME'] = self.server.server_name
env['GATEWAY_INTERFACE'] = 'CGI/1.1'
@@ -216,7 +217,6 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'):
env.setdefault(k, "")
- os.environ.update(env)
self.send_response(200, "Script output follows")
@@ -248,7 +248,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
pass
os.dup2(self.rfile.fileno(), 0)
os.dup2(self.wfile.fileno(), 1)
- os.execve(scriptfile, args, os.environ)
+ os.execve(scriptfile, args, env)
except:
self.server.handle_error(self.request, self.client_address)
os._exit(127)
@@ -274,7 +274,8 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
p = subprocess.Popen(cmdline,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
- stderr = subprocess.PIPE
+ stderr = subprocess.PIPE,
+ env = env
)
if self.command.lower() == "post" and nbytes > 0:
data = self.rfile.read(nbytes)