# HG changeset patch # User Alexander Schremmer # Date 1145745247 -7200 # Node ID c0729a7f6f8aabf00d097ffec91c45136b701da1 # Parent 9383ba6b069ab6f2dac33ba6ad3192c7fe450392 Fixed path handling of the standalone server, fixed typo. diff -r 9383ba6b069a -r c0729a7f6f8a mercurial/hgweb.py --- a/mercurial/hgweb.py Sun Apr 23 00:31:09 2006 +0200 +++ b/mercurial/hgweb.py Sun Apr 23 00:34:07 2006 +0200 @@ -11,10 +11,22 @@ from demandload import demandload demandload(globals(), "mdiff time re socket zlib errno ui hg ConfigParser") demandload(globals(), "tempfile StringIO BaseHTTPServer util SocketServer") -demandload(globals(), "archival mimetypes templater") +demandload(globals(), "archival mimetypes templater urllib") from node import * from i18n import gettext as _ +def splitURI(uri): + """ Return path and query splited from uri + + Just like CGI environment, the path is unquoted, the query is + not. + """ + if '?' in uri: + path, query = uri.split('?', 1) + else: + path, query = uri, '' + return urllib.unquote(path), query + def up(p): if p[0] != "/": p = "/" + p @@ -918,6 +930,7 @@ BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs) class hgwebhandler(BaseHTTPServer.BaseHTTPRequestHandler): + def log_error(self, format, *args): errorlog.write("%s - - [%s] %s\n" % (self.address_string(), self.log_date_time_string(), @@ -939,18 +952,15 @@ self.do_POST() def do_hgweb(self): - query = "" - p = self.path.find("?") - if p: - query = self.path[p + 1:] - query = query.replace('+', ' ') - + path_info, query = splitURI(self.path) + env = {} env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['REQUEST_METHOD'] = self.command env['SERVER_NAME'] = self.server.server_name env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_URI'] = "/" + env['PATH_INFO'] = path_info if query: env['QUERY_STRING'] = query host = self.address_string() @@ -977,7 +987,7 @@ self.send_response(200, "Script output follows") if webdir_conf: - hgwebobj = hgwebdir(hgwebdir_conf) + hgwebobj = hgwebdir(webdir_conf) else: hgwebobj = hgweb(repo.__class__(repo.ui, repo.origroot)) hgwebobj.run(req)