changeset 28484:da6f713ab480

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.
author Augie Fackler <augie@google.com>
date Fri, 11 Mar 2016 11:26:12 -0500
parents 6f38ec428a19
children d3893900f6c8
files mercurial/httppeer.py
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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)