Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 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 | a2df85adface |
children | d0db3462d568 |
comparison
equal
deleted
inserted
replaced
2487:041363739ca8 | 2505:01b856927970 |
---|---|
74 else: | 74 else: |
75 env['CONTENT_TYPE'] = self.headers.typeheader | 75 env['CONTENT_TYPE'] = self.headers.typeheader |
76 length = self.headers.getheader('content-length') | 76 length = self.headers.getheader('content-length') |
77 if length: | 77 if length: |
78 env['CONTENT_LENGTH'] = length | 78 env['CONTENT_LENGTH'] = length |
79 accept = [] | 79 for header in [h for h in self.headers.keys() \ |
80 for line in self.headers.getallmatchingheaders('accept'): | 80 if h not in ('content-type', 'content-length')]: |
81 if line[:1] in "\t\n\r ": | 81 hkey = 'HTTP_' + header.replace('-', '_').upper() |
82 accept.append(line.strip()) | 82 hval = self.headers.getheader(header) |
83 else: | 83 hval = hval.replace('\n', '').strip() |
84 accept = accept + line[7:].split(',') | 84 if hval: |
85 env['HTTP_ACCEPT'] = ','.join(accept) | 85 env[hkey] = hval |
86 env['SERVER_PROTOCOL'] = self.request_version | |
86 | 87 |
87 req = hgrequest(self.rfile, self.wfile, env) | 88 req = hgrequest(self.rfile, self.wfile, env) |
88 self.send_response(200, "Script output follows") | 89 self.send_response(200, "Script output follows") |
89 self.close_connection = self.server.make_and_run_handler(req) | 90 self.close_connection = self.server.make_and_run_handler(req) |
90 | 91 |