httppeer: move size computation later in _callstream
A future change will alter some of the arg-sending logic in a way that matters
for request body size. Centralizing the logic now will make later patches
easier to review.
--- a/mercurial/httppeer.py Fri Mar 11 11:24:50 2016 -0500
+++ b/mercurial/httppeer.py Fri Mar 11 11:26:12 2016 -0500
@@ -92,19 +92,7 @@
if cmd == 'pushkey':
args['data'] = ''
data = args.pop('data', None)
- size = 0
- if util.safehasattr(data, 'length'):
- size = data.length
- elif data is not None:
- size = len(data)
headers = args.pop('headers', {})
- if data is not None and 'Content-Type' not in headers:
- headers['Content-Type'] = 'application/mercurial-0.1'
-
-
- if size and self.ui.configbool('ui', 'usehttp2', False):
- headers['Expect'] = '100-Continue'
- headers['X-HgHttp2'] = '1'
self.ui.debug("sending %s command\n" % cmd)
q = [('cmd', cmd)]
@@ -129,6 +117,16 @@
q += sorted(args.items())
qs = '?%s' % urllib.urlencode(q)
cu = "%s%s" % (self._url, qs)
+ size = 0
+ if util.safehasattr(data, 'length'):
+ size = data.length
+ elif data is not None:
+ size = len(data)
+ if size and self.ui.configbool('ui', 'usehttp2', False):
+ headers['Expect'] = '100-Continue'
+ headers['X-HgHttp2'] = '1'
+ if data is not None and 'Content-Type' not in headers:
+ headers['Content-Type'] = 'application/mercurial-0.1'
req = self.requestbuilder(cu, data, headers)
if data is not None:
self.ui.debug("sending %s bytes\n" % size)