changeset 30569:07bcd1bf6151

httppeer: assign Vary request header last In preparation for adding another value to it in a subsequent patch. While I was here, I added some empty lines because walls of text are hard to read.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 28 Nov 2016 21:07:51 -0800
parents e118233172fe
children 7fbc8a742b4d
files mercurial/httppeer.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Mon Nov 28 20:46:42 2016 -0800
+++ b/mercurial/httppeer.py	Mon Nov 28 21:07:51 2016 -0800
@@ -111,6 +111,7 @@
         self.ui.debug("sending %s command\n" % cmd)
         q = [('cmd', cmd)]
         headersize = 0
+        varyheaders = []
         # Important: don't use self.capable() here or else you end up
         # with infinite recursion when trying to look up capabilities
         # for the first time.
@@ -137,13 +138,11 @@
                 headerfmt = 'X-HgArg-%s'
                 contentlen = headersize - len(headerfmt % '000' + ': \r\n')
                 headernum = 0
-                varyheaders = []
                 for i in xrange(0, len(encargs), contentlen):
                     headernum += 1
                     header = headerfmt % str(headernum)
                     headers[header] = encargs[i:i + contentlen]
                     varyheaders.append(header)
-                headers['Vary'] = ','.join(varyheaders)
             else:
                 q += sorted(args.items())
         qs = '?%s' % urlreq.urlencode(q)
@@ -158,7 +157,10 @@
             headers['X-HgHttp2'] = '1'
         if data is not None and 'Content-Type' not in headers:
             headers['Content-Type'] = 'application/mercurial-0.1'
+
+        headers['Vary'] = ','.join(varyheaders)
         req = self.requestbuilder(cu, data, headers)
+
         if data is not None:
             self.ui.debug("sending %s bytes\n" % size)
             req.add_unredirected_header('Content-Length', '%d' % size)