Comments
Patch
@@ -7,6 +7,7 @@
# GNU General Public License version 2 or any later version.
import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback
+from urlparse import urlparse
from mercurial import util, error
from mercurial.hgweb import common
from mercurial.i18n import _
@@ -90,9 +91,26 @@
self.do_POST()
def do_hgweb(self):
+ env = {}
+ parsed = urlparse(self.path)
+ if parsed.scheme and parsed.netloc:
+ # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
+ # To allow for transition to absoluteURIs in all requests in
+ # future versions of HTTP, all HTTP/1.1 servers MUST accept the
+ # absoluteURI form in requests, even though HTTP/1.1 clients will
+ # only generate them in requests to proxies.
+ server = parsed.netloc
+ self.path = self.path[self.path.find(server) + len(server):]
+ colon = server.rfind(':')
+ if colon > 1:
+ server = server[:colon]
+ # https://www.python.org/dev/peps/pep-0333/#environ-variables
+ # Note, however, that HTTP_HOST , if present, should be used in
+ # preference to SERVER_NAME for reconstructing the request URL.
+ # See the URL Reconstruction section below for more detail.
+ env['HTTP_HOST'] = server
path, query = _splitURI(self.path)
- env = {}
env['GATEWAY_INTERFACE'] = 'CGI/1.1'
env['REQUEST_METHOD'] = self.command
env['SERVER_NAME'] = self.server.server_name
@@ -16,6 +16,10 @@
$ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E
errors.log
$ cat hg.pid >> $DAEMON_PIDS
+supports rfcXXX gets
+ $ (get-with-headers.py localhost:$HGPORT --headeronly
"http://localhost:$HGPORT/?cmd=capabilities")
+ 200 Script output follows
+
manifest