From c1075f38807d05e1bcac3fe2c1edf844af551de8 Mon Sep 17 00:00:00 2001 From: Steven Brown Date: Sun, 1 May 2011 01:04:37 +0800 Subject: [PATCH] httprepo: long arguments support (issue2126) Send the command arguments in the HTTP headers. The command is still part of the URL. If the server does not have the 'httpheader' capability, the client will send the command arguments in the URL as it did previously. Web servers typically allow more data to be placed within the headers than in the URL, so this approach will: - Avoid HTTP errors due to using a URL that is too large. - Allow Mercurial to implement a more efficient wire protocol. An alternate approach is to send the arguments as part of the request body. This approach has been rejected because it requires the use of POST requests, so it would break any existing configuration that relies on the request type for authentication or caching. Extensibility: - The header size is provided by the server, which makes it possible to introduce an hgrc setting for it. - The client ignores the capability value after the first comma, which allows more information to be included in the future. --- mercurial/hgweb/protocol.py | 19 ++++++++++++---- mercurial/hgweb/server.py | 6 ++++++ mercurial/httprepo.py | 21 +++++++++++++++++- mercurial/wireproto.py | 1 + tests/test-getbundle.t | 2 +- tests/test-hgweb-commands.t | 2 +- tests/test-http-proxy.t | 18 ++++++++-------- tests/test-push-http.t | 17 +++++++++++++++ tests/test-unbundlehash.t | 2 +- tests/test-wireproto.t | 43 +++++++++++++++++++++++++++++++++++++ tests/tinyproxy.py | 6 ++++++ 11 files changed, 120 insertions(+), 17 deletions(-) diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py index b58ada8669..c568c544d6 100644 --- a/mercurial/hgweb/protocol.py +++ b/mercurial/hgweb/protocol.py @@ -5,7 +5,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. -import cStringIO, zlib, sys, urllib +import cgi, cStringIO, itertools, zlib, sys, urllib from mercurial import util, wireproto from common import HTTP_OK @@ -16,18 +16,29 @@ class webproto(object): self.req = req self.response = '' def getargs(self, args): + knownargs = self._args() data = {} keys = args.split() for k in keys: if k == '*': star = {} - for key in self.req.form.keys(): + for key in knownargs.keys(): if key != 'cmd' and key not in keys: - star[key] = self.req.form[key][0] + star[key] = knownargs[key][0] data['*'] = star else: - data[k] = self.req.form[k][0] + data[k] = knownargs[k][0] return [data[k] for k in keys] + def _args(self): + args = self.req.form.copy() + chunks = [] + for i in itertools.count(1): + h = self.req.env.get('HTTP_X_ARG_' + str(i)) + if h is None: + break + chunks += [h] + args.update(cgi.parse_qs(''.join(chunks), keep_blank_values=True)) + return args def getfile(self, fp): length = int(self.req.env['CONTENT_LENGTH']) for s in util.filechunkiter(self.req, limit=length): diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py index 5dc4054ae9..1cc838adae 100644 --- a/mercurial/hgweb/server.py +++ b/mercurial/hgweb/server.py @@ -59,6 +59,12 @@ class _httprequesthandler(BaseHTTPServer.BaseHTTPRequestHandler): def log_message(self, format, *args): self._log_any(self.server.accesslog, format, *args) + def log_request(self, code='-', size='-'): + xheaders = [h for h in self.headers.items() if h[0].startswith('x-')] + self.log_message('"%s" %s %s%s', + self.requestline, str(code), str(size), + ''.join([' %s:%s' % h for h in sorted(xheaders)])) + def do_write(self): try: self.do_hgweb() diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py index b1083eaa1d..1ab5e29141 100644 --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -76,7 +76,26 @@ class httprepository(wireproto.wirerepository): data = args.pop('data', None) headers = args.pop('headers', {}) self.ui.debug("sending %s command\n" % cmd) - q = [('cmd', cmd)] + sorted(args.items()) + q = [('cmd', cmd)] + headersize = 0 + if len(args) > 0: + httpheader = self.capable('httpheader') + if httpheader: + headersize = int(httpheader.split(',')[0]) + if headersize > 0: + # The headers can typically carry more data than the URL. + encargs = urllib.urlencode(sorted(args.items())) + headerfmt = 'X-Arg-%s' + contentlen = headersize - len(headerfmt % '000' + ': \r\n') + headernum = 0 + for i in xrange(0, len(encargs), contentlen): + headernum += 1 + header = headerfmt % str(headernum) + headers[header] = encargs[i:i + contentlen] + varyheaders = [headerfmt % str(h) for h in range(1, headernum + 1)] + headers['Vary'] = ','.join(varyheaders) + else: + q += sorted(args.items()) qs = '?%s' % urllib.urlencode(q) cu = "%s%s" % (self._url, qs) req = urllib2.Request(cu, data, headers) diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py index ae144e9af3..1c68ea3d97 100644 --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -233,6 +233,7 @@ def capabilities(repo, proto): else: caps.append('streamreqs=%s' % ','.join(requiredformats)) caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority)) + caps.append('httpheader=1024') return ' '.join(caps) def changegroup(repo, proto, roots): diff --git a/tests/test-getbundle.t b/tests/test-getbundle.t index 506465f18a..87692d71e6 100644 --- a/tests/test-getbundle.t +++ b/tests/test-getbundle.t @@ -247,7 +247,7 @@ Verify we hit the HTTP server: * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) - * - - [*] "GET /?cmd=getbundle&common=c1818a9f5977dd4139a48f93f5425c67d44a9368+ea919464b16e003894c48b6cb68df3cd9411b544&heads=6b57ee934bb2996050540f84cdfc8dcad1e7267d+2114148793524fd045998f71a45b0aaf139f752b HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-arg-1:common=c1818a9f5977dd4139a48f93f5425c67d44a9368+ea919464b16e003894c48b6cb68df3cd9411b544&heads=6b57ee934bb2996050540f84cdfc8dcad1e7267d+2114148793524fd045998f71a45b0aaf139f752b (glob) $ cat error.log diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t index b07ba4e28d..c1891c01d4 100644 --- a/tests/test-hgweb-commands.t +++ b/tests/test-hgweb-commands.t @@ -952,7 +952,7 @@ capabilities $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'; echo 200 Script output follows - lookup changegroupsubset branchmap pushkey known getbundle unbundlehash unbundle=HG10GZ,HG10BZ,HG10UN + lookup changegroupsubset branchmap pushkey known getbundle unbundlehash unbundle=HG10GZ,HG10BZ,HG10UN httpheader=1024 heads diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t index 04105e6221..e7190f971a 100644 --- a/tests/test-http-proxy.t +++ b/tests/test-http-proxy.t @@ -100,21 +100,21 @@ do not use the proxy if it is in the no list $ cat proxy.log * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-arg-1:namespace=bookmarks (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-arg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-arg-1:namespace=bookmarks (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-arg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-arg-1:namespace=bookmarks (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-arg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-arg-1:namespace=bookmarks (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob) * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle&common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 HTTP/1.1" - - (glob) - * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys&namespace=bookmarks HTTP/1.1" - - (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-arg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob) + * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-arg-1:namespace=bookmarks (glob) diff --git a/tests/test-push-http.t b/tests/test-push-http.t index 139206aacb..7474d7bf8c 100644 --- a/tests/test-push-http.t +++ b/tests/test-push-http.t @@ -66,6 +66,23 @@ expect success repository tip rolled back to revision 0 (undo serve) working directory now based on revision 0 +expect success, server lacks the httpheader capability + + $ CAP=httpheader + $ . "$TESTDIR/notcapable" + $ req + pushing to http://localhost:$HGPORT/ + searching for changes + remote: adding changesets + remote: adding manifests + remote: adding file changes + remote: added 1 changesets with 1 changes to 1 files + remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http:*: (glob) + % serve errors + $ hg rollback + repository tip rolled back to revision 0 (undo serve) + working directory now based on revision 0 + expect success, server lacks the unbundlehash capability $ CAP=unbundlehash diff --git a/tests/test-unbundlehash.t b/tests/test-unbundlehash.t index 956006a6e6..a8c90106c1 100644 --- a/tests/test-unbundlehash.t +++ b/tests/test-unbundlehash.t @@ -28,4 +28,4 @@ Ensure hashed heads format is used. The hash here is always the same since the remote repository only has the null head. $ cat access.log | grep unbundle - * - - [*] "POST /?cmd=unbundle&heads=686173686564+6768033e216468247bd031a0a2d9876d79818f8f HTTP/1.1" 200 - (glob) + * - - [*] "POST /?cmd=unbundle HTTP/1.1" 200 - x-arg-1:heads=686173686564+6768033e216468247bd031a0a2d9876d79818f8f (glob) diff --git a/tests/test-wireproto.t b/tests/test-wireproto.t index 30bb717122..85e12943f5 100644 --- a/tests/test-wireproto.t +++ b/tests/test-wireproto.t @@ -23,14 +23,57 @@ HTTP: $ hg debugwireargs http://localhost:$HGPORT/ un deux trois quatre un deux trois quatre None + $ hg debugwireargs http://localhost:$HGPORT/ \ un deux trois\ qu\ \ atre + un deux trois qu atre None $ hg debugwireargs http://localhost:$HGPORT/ eins zwei --four vier eins zwei None vier None $ hg debugwireargs http://localhost:$HGPORT/ eins zwei eins zwei None None None $ hg debugwireargs http://localhost:$HGPORT/ eins zwei --five fuenf eins zwei None None None + $ hg debugwireargs http://localhost:$HGPORT/ un deux trois onethousandcharactersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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(glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=quatre&one=un&three=trois&two=deux (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=qu++atre&one=+un&three=trois+&two=deux (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=qu++atre&one=+un&three=trois+&two=deux (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=vier&one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=vier&one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:one=eins&two=zwei (glob) + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) + * - - [*] "GET /?cmd=debugwireargs HTTP/1.1" 200 - x-arg-1:four=onethousandcharactersxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&one=u x-arg-2:n&three=trois&two=deux (glob) + +HTTP without the httpheader capability: + + $ HGRCPATH="`pwd`/repo/.hgrc" + $ CAP=httpheader + $ . "$TESTDIR/notcapable" + + $ hg serve -R repo -p $HGPORT2 -d --pid-file=hg2.pid -E error2.log -A access2.log + $ cat hg2.pid >> $DAEMON_PIDS + + $ hg debugwireargs http://localhost:$HGPORT2/ un deux trois quatre + un deux trois quatre None + $ hg debugwireargs http://localhost:$HGPORT2/ eins zwei --four vier + eins zwei None vier None + $ hg debugwireargs http://localhost:$HGPORT2/ eins zwei + eins zwei None None None + $ hg debugwireargs http://localhost:$HGPORT2/ eins zwei --five fuenf + eins zwei None None None + $ cat error2.log + $ cat access2.log + * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=debugwireargs&four=quatre&one=un&three=trois&two=deux HTTP/1.1" 200 - (glob) * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob) diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py index c4ecdac804..319030ad8a 100755 --- a/tests/tinyproxy.py +++ b/tests/tinyproxy.py @@ -30,6 +30,12 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler): else: self.__base_handle() + def log_request(self, code='-', size='-'): + xheaders = [h for h in self.headers.items() if h[0].startswith('x-')] + self.log_message('"%s" %s %s%s', + self.requestline, str(code), str(size), + ''.join([' %s:%s' % h for h in sorted(xheaders)])) + def _connect_to(self, netloc, soc): i = netloc.find(':') if i >= 0: