Show More
@@ -17,6 +17,7 b' import traceback' | |||||
17 | from ..i18n import _ |
|
17 | from ..i18n import _ | |
18 |
|
18 | |||
19 | from .. import ( |
|
19 | from .. import ( | |
|
20 | encoding, | |||
20 | error, |
|
21 | error, | |
21 | pycompat, |
|
22 | pycompat, | |
22 | util, |
|
23 | util, | |
@@ -67,9 +68,10 b' class _httprequesthandler(httpservermod.' | |||||
67 | httpservermod.basehttprequesthandler.__init__(self, *args, **kargs) |
|
68 | httpservermod.basehttprequesthandler.__init__(self, *args, **kargs) | |
68 |
|
69 | |||
69 | def _log_any(self, fp, format, *args): |
|
70 | def _log_any(self, fp, format, *args): | |
70 | fp.write("%s - - [%s] %s\n" % (self.client_address[0], |
|
71 | fp.write(pycompat.sysbytes( | |
71 | self.log_date_time_string(), |
|
72 | r"%s - - [%s] %s" % (self.client_address[0], | |
72 |
|
|
73 | self.log_date_time_string(), | |
|
74 | format % args)) + '\n') | |||
73 | fp.flush() |
|
75 | fp.flush() | |
74 |
|
76 | |||
75 | def log_error(self, format, *args): |
|
77 | def log_error(self, format, *args): | |
@@ -78,14 +80,14 b' class _httprequesthandler(httpservermod.' | |||||
78 | def log_message(self, format, *args): |
|
80 | def log_message(self, format, *args): | |
79 | self._log_any(self.server.accesslog, format, *args) |
|
81 | self._log_any(self.server.accesslog, format, *args) | |
80 |
|
82 | |||
81 | def log_request(self, code='-', size='-'): |
|
83 | def log_request(self, code=r'-', size=r'-'): | |
82 | xheaders = [] |
|
84 | xheaders = [] | |
83 | if util.safehasattr(self, 'headers'): |
|
85 | if util.safehasattr(self, 'headers'): | |
84 | xheaders = [h for h in self.headers.items() |
|
86 | xheaders = [h for h in self.headers.items() | |
85 | if h[0].startswith('x-')] |
|
87 | if h[0].startswith(r'x-')] | |
86 | self.log_message('"%s" %s %s%s', |
|
88 | self.log_message(r'"%s" %s %s%s', | |
87 | self.requestline, str(code), str(size), |
|
89 | self.requestline, str(code), str(size), | |
88 | ''.join([' %s:%s' % h for h in sorted(xheaders)])) |
|
90 | r''.join([r' %s:%s' % h for h in sorted(xheaders)])) | |
89 |
|
91 | |||
90 | def do_write(self): |
|
92 | def do_write(self): | |
91 | try: |
|
93 | try: | |
@@ -101,9 +103,13 b' class _httprequesthandler(httpservermod.' | |||||
101 | self._start_response("500 Internal Server Error", []) |
|
103 | self._start_response("500 Internal Server Error", []) | |
102 | self._write("Internal Server Error") |
|
104 | self._write("Internal Server Error") | |
103 | self._done() |
|
105 | self._done() | |
104 | tb = "".join(traceback.format_exception(*sys.exc_info())) |
|
106 | tb = r"".join(traceback.format_exception(*sys.exc_info())) | |
105 | self.log_error("Exception happened during processing " |
|
107 | # We need a native-string newline to poke in the log | |
106 | "request '%s':\n%s", self.path, tb) |
|
108 | # message, because we won't get a newline when using an | |
|
109 | # r-string. This is the easy way out. | |||
|
110 | newline = chr(10) | |||
|
111 | self.log_error(r"Exception happened during processing " | |||
|
112 | r"request '%s':%s%s", self.path, newline, tb) | |||
107 |
|
113 | |||
108 | def do_GET(self): |
|
114 | def do_GET(self): | |
109 | self.do_POST() |
|
115 | self.do_POST() | |
@@ -331,4 +337,4 b' def create_server(ui, app):' | |||||
331 | return cls(ui, app, (address, port), handler) |
|
337 | return cls(ui, app, (address, port), handler) | |
332 | except socket.error as inst: |
|
338 | except socket.error as inst: | |
333 | raise error.Abort(_("cannot start server at '%s:%d': %s") |
|
339 | raise error.Abort(_("cannot start server at '%s:%d': %s") | |
334 | % (address, port, inst.args[1])) |
|
340 | % (address, port, encoding.strtolocal(inst.args[1]))) |
General Comments 0
You need to be logged in to leave comments.
Login now