[PATCH 1 of 4] Fix server to set up a more WSGI compliant environment

Eric Hopper hopper at omnifarious.org
Mon Jun 26 11:35:45 CDT 2006


# HG changeset patch
# User Eric Hopper <hopper at omnifarious.org>
# Node ID b33ac8b897dc533f5f71337ac866ba24dce37481
# Parent  041363739ca8abbcafce8d7418afc8dac733f764
Fix server to set up a more WSGI compliant environment.

diff -r 041363739ca8 -r b33ac8b897dc mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Fri Jun 23 08:10:06 2006 +0200
+++ b/mercurial/hgweb/server.py	Fri Jun 23 13:03:34 2006 -0700
@@ -76,13 +76,14 @@ class _hgwebhandler(object, BaseHTTPServ
         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")

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial/attachments/20060626/1e9b69d3/attachment.pgp


More information about the Mercurial mailing list