changeset 2505:01b856927970

Fix server to set up a more WSGI compliant environment.
author Eric Hopper <hopper@omnifarious.org>
date Tue, 27 Jun 2006 00:09:31 -0700
parents 041363739ca8
children d0db3462d568
files mercurial/hgweb/server.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/server.py	Fri Jun 23 08:10:06 2006 +0200
+++ b/mercurial/hgweb/server.py	Tue Jun 27 00:09:31 2006 -0700
@@ -76,13 +76,14 @@
         length = self.headers.getheader('content-length')
         if length:
             env['CONTENT_LENGTH'] = length
-        accept = []
-        for line in self.headers.getallmatchingheaders('accept'):
-            if line[:1] in "\t\n\r ":
-                accept.append(line.strip())
-            else:
-                accept = accept + line[7:].split(',')
-        env['HTTP_ACCEPT'] = ','.join(accept)
+        for header in [h for h in self.headers.keys() \
+                       if h not in ('content-type', 'content-length')]:
+            hkey = 'HTTP_' + header.replace('-', '_').upper()
+            hval = self.headers.getheader(header)
+            hval = hval.replace('\n', '').strip()
+            if hval:
+                env[hkey] = hval
+        env['SERVER_PROTOCOL'] = self.request_version
 
         req = hgrequest(self.rfile, self.wfile, env)
         self.send_response(200, "Script output follows")