Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/protocol.py @ 14093:ce99d887585f
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.
author | Steven Brown <StevenGBrown@gmail.com> |
---|---|
date | Sun, 01 May 2011 01:04:37 +0800 |
parents | 3458c15ab2f0 |
children | d10c6835497e |
comparison
equal
deleted
inserted
replaced
14092:222c8ec7a274 | 14093:ce99d887585f |
---|---|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import cStringIO, zlib, sys, urllib | 8 import cgi, cStringIO, itertools, zlib, sys, urllib |
9 from mercurial import util, wireproto | 9 from mercurial import util, wireproto |
10 from common import HTTP_OK | 10 from common import HTTP_OK |
11 | 11 |
12 HGTYPE = 'application/mercurial-0.1' | 12 HGTYPE = 'application/mercurial-0.1' |
13 | 13 |
14 class webproto(object): | 14 class webproto(object): |
15 def __init__(self, req): | 15 def __init__(self, req): |
16 self.req = req | 16 self.req = req |
17 self.response = '' | 17 self.response = '' |
18 def getargs(self, args): | 18 def getargs(self, args): |
19 knownargs = self._args() | |
19 data = {} | 20 data = {} |
20 keys = args.split() | 21 keys = args.split() |
21 for k in keys: | 22 for k in keys: |
22 if k == '*': | 23 if k == '*': |
23 star = {} | 24 star = {} |
24 for key in self.req.form.keys(): | 25 for key in knownargs.keys(): |
25 if key != 'cmd' and key not in keys: | 26 if key != 'cmd' and key not in keys: |
26 star[key] = self.req.form[key][0] | 27 star[key] = knownargs[key][0] |
27 data['*'] = star | 28 data['*'] = star |
28 else: | 29 else: |
29 data[k] = self.req.form[k][0] | 30 data[k] = knownargs[k][0] |
30 return [data[k] for k in keys] | 31 return [data[k] for k in keys] |
32 def _args(self): | |
33 args = self.req.form.copy() | |
34 chunks = [] | |
35 for i in itertools.count(1): | |
36 h = self.req.env.get('HTTP_X_ARG_' + str(i)) | |
37 if h is None: | |
38 break | |
39 chunks += [h] | |
40 args.update(cgi.parse_qs(''.join(chunks), keep_blank_values=True)) | |
41 return args | |
31 def getfile(self, fp): | 42 def getfile(self, fp): |
32 length = int(self.req.env['CONTENT_LENGTH']) | 43 length = int(self.req.env['CONTENT_LENGTH']) |
33 for s in util.filechunkiter(self.req, limit=length): | 44 for s in util.filechunkiter(self.req, limit=length): |
34 fp.write(s) | 45 fp.write(s) |
35 def redirect(self): | 46 def redirect(self): |