Show More
@@ -12,11 +12,18 b' class ErrorResponse(Exception):' | |||
|
12 | 12 | def __init__(self, code, message=None): |
|
13 | 13 | Exception.__init__(self) |
|
14 | 14 | self.code = code |
|
15 |
if message |
|
|
16 | from httplib import responses | |
|
17 | self.message = responses.get(code, 'Error') | |
|
15 | if message: | |
|
16 | self.message = message | |
|
18 | 17 | else: |
|
19 | self.message = message | |
|
18 | self.message = _statusmessage(code) | |
|
19 | ||
|
20 | def _statusmessage(code): | |
|
21 | from BaseHTTPServer import BaseHTTPRequestHandler | |
|
22 | responses = BaseHTTPRequestHandler.responses | |
|
23 | return responses.get(code, ('Error', 'Unknown error'))[0] | |
|
24 | ||
|
25 | def statusmessage(code): | |
|
26 | return '%d %s' % (code, _statusmessage(code)) | |
|
20 | 27 | |
|
21 | 28 | def get_mtime(repo_path): |
|
22 | 29 | store_path = os.path.join(repo_path, ".hg") |
@@ -13,6 +13,7 b' from mercurial.i18n import gettext as _' | |||
|
13 | 13 | from mercurial import mdiff, ui, hg, util, archival, streamclone, patch |
|
14 | 14 | from mercurial import revlog, templater |
|
15 | 15 | from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen |
|
16 | from common import statusmsg | |
|
16 | 17 | |
|
17 | 18 | def _up(p): |
|
18 | 19 | if p[0] != "/": |
@@ -8,7 +8,7 b'' | |||
|
8 | 8 | |
|
9 | 9 | import socket, cgi, errno |
|
10 | 10 | from mercurial.i18n import gettext as _ |
|
11 | from common import ErrorResponse | |
|
11 | from common import ErrorResponse, statusmessage | |
|
12 | 12 | |
|
13 | 13 | class wsgiapplication(object): |
|
14 | 14 | def __init__(self, destmaker): |
@@ -53,15 +53,10 b' class _wsgirequest(object):' | |||
|
53 | 53 | if self.server_write is None: |
|
54 | 54 | if not self.headers: |
|
55 | 55 | raise RuntimeError("request.write called before headers sent (%s)." % thing) |
|
56 | code = None | |
|
57 | 56 | if isinstance(status, ErrorResponse): |
|
58 |
|
|
|
57 | status = statusmessage(status.code) | |
|
59 | 58 | elif isinstance(status, int): |
|
60 |
|
|
|
61 | if code: | |
|
62 | from httplib import responses | |
|
63 | status = '%d %s' % ( | |
|
64 | code, responses.get(code, 'Error')) | |
|
59 | status = statusmessage(status) | |
|
65 | 60 | self.server_write = self.start_response(status, |
|
66 | 61 | self.headers) |
|
67 | 62 | self.start_response = None |
General Comments 0
You need to be logged in to leave comments.
Login now