Mercurial > hg
comparison mercurial/hgweb/wsgicgi.py @ 2558:1120302009d7
hgweb: fix unbundle.
After the WSGI changes, even if a push over HTTP succeeds, apache
complains about "Premature end of script headers: hgwebdir.cgi" and
returns a "HTTP Error 500: Internal Server Error", making the local hg
abort.
The change to either of the files touched by this patch is enough to fix
this, but I think changing both is a more robust solution.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Mon, 03 Jul 2006 00:33:19 -0300 |
parents | d0db3462d568 |
children | eb0b4a2d70a9 |
comparison
equal
deleted
inserted
replaced
2557:1727ff712a4e | 2558:1120302009d7 |
---|---|
25 else: | 25 else: |
26 environ['wsgi.url_scheme'] = 'http' | 26 environ['wsgi.url_scheme'] = 'http' |
27 | 27 |
28 headers_set = [] | 28 headers_set = [] |
29 headers_sent = [] | 29 headers_sent = [] |
30 out = sys.stdout | |
30 | 31 |
31 def write(data): | 32 def write(data): |
32 if not headers_set: | 33 if not headers_set: |
33 raise AssertionError("write() before start_response()") | 34 raise AssertionError("write() before start_response()") |
34 | 35 |
35 elif not headers_sent: | 36 elif not headers_sent: |
36 # Before the first output, send the stored headers | 37 # Before the first output, send the stored headers |
37 status, response_headers = headers_sent[:] = headers_set | 38 status, response_headers = headers_sent[:] = headers_set |
38 sys.stdout.write('Status: %s\r\n' % status) | 39 out.write('Status: %s\r\n' % status) |
39 for header in response_headers: | 40 for header in response_headers: |
40 sys.stdout.write('%s: %s\r\n' % header) | 41 out.write('%s: %s\r\n' % header) |
41 sys.stdout.write('\r\n') | 42 out.write('\r\n') |
42 | 43 |
43 sys.stdout.write(data) | 44 out.write(data) |
44 sys.stdout.flush() | 45 out.flush() |
45 | 46 |
46 def start_response(status,response_headers,exc_info=None): | 47 def start_response(status,response_headers,exc_info=None): |
47 if exc_info: | 48 if exc_info: |
48 try: | 49 try: |
49 if headers_sent: | 50 if headers_sent: |