Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 28530:fd2acc5046f6
http: support sending hgargs via POST body instead of in GET or headers
narrowhg (for its narrow spec) and remotefilelog (for its large batch
requests) would like to be able to make requests with argument sets so
absurdly large that they blow out total request size limit on some
http servers. As a workaround, support stuffing args at the start
of the POST body.
We will probably want to leave this behavior off by default in servers
forever, because it makes the old "POSTs are only for writes"
assumption wrong, which might break some of the simpler authentication
configurations.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 11 Mar 2016 11:37:00 -0500 |
parents | 50314dc3ae4e |
children | ae53ecc47414 |
comparison
equal
deleted
inserted
replaced
28529:045cdf47851a | 28530:fd2acc5046f6 |
---|---|
95 headers = args.pop('headers', {}) | 95 headers = args.pop('headers', {}) |
96 | 96 |
97 self.ui.debug("sending %s command\n" % cmd) | 97 self.ui.debug("sending %s command\n" % cmd) |
98 q = [('cmd', cmd)] | 98 q = [('cmd', cmd)] |
99 headersize = 0 | 99 headersize = 0 |
100 if True: | 100 # Important: don't use self.capable() here or else you end up |
101 # with infinite recursion when trying to look up capabilities | |
102 # for the first time. | |
103 postargsok = self.caps is not None and 'httppostargs' in self.caps | |
104 # TODO: support for httppostargs when data is a file-like | |
105 # object rather than a basestring | |
106 canmungedata = not data or isinstance(data, basestring) | |
107 if postargsok and canmungedata: | |
108 strargs = urllib.urlencode(sorted(args.items())) | |
109 if strargs: | |
110 if not data: | |
111 data = strargs | |
112 elif isinstance(data, basestring): | |
113 data = strargs + data | |
114 headers['X-HgArgs-Post'] = len(strargs) | |
115 else: | |
101 if len(args) > 0: | 116 if len(args) > 0: |
102 httpheader = self.capable('httpheader') | 117 httpheader = self.capable('httpheader') |
103 if httpheader: | 118 if httpheader: |
104 headersize = int(httpheader.split(',', 1)[0]) | 119 headersize = int(httpheader.split(',', 1)[0]) |
105 if headersize > 0: | 120 if headersize > 0: |