Mercurial > hg
comparison mercurial/httppeer.py @ 28486:50314dc3ae4e
httppeer: compute header names only once
This also helps make the code a little more readable.
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 11 Mar 2016 11:51:22 -0500 |
parents | d3893900f6c8 |
children | fd2acc5046f6 |
comparison
equal
deleted
inserted
replaced
28485:d3893900f6c8 | 28486:50314dc3ae4e |
---|---|
106 # The headers can typically carry more data than the URL. | 106 # The headers can typically carry more data than the URL. |
107 encargs = urllib.urlencode(sorted(args.items())) | 107 encargs = urllib.urlencode(sorted(args.items())) |
108 headerfmt = 'X-HgArg-%s' | 108 headerfmt = 'X-HgArg-%s' |
109 contentlen = headersize - len(headerfmt % '000' + ': \r\n') | 109 contentlen = headersize - len(headerfmt % '000' + ': \r\n') |
110 headernum = 0 | 110 headernum = 0 |
111 varyheaders = [] | |
111 for i in xrange(0, len(encargs), contentlen): | 112 for i in xrange(0, len(encargs), contentlen): |
112 headernum += 1 | 113 headernum += 1 |
113 header = headerfmt % str(headernum) | 114 header = headerfmt % str(headernum) |
114 headers[header] = encargs[i:i + contentlen] | 115 headers[header] = encargs[i:i + contentlen] |
115 varyheaders = [ | 116 varyheaders.append(header) |
116 headerfmt % str(h) for h in range(1, headernum + 1)] | |
117 headers['Vary'] = ','.join(varyheaders) | 117 headers['Vary'] = ','.join(varyheaders) |
118 else: | 118 else: |
119 q += sorted(args.items()) | 119 q += sorted(args.items()) |
120 qs = '?%s' % urllib.urlencode(q) | 120 qs = '?%s' % urllib.urlencode(q) |
121 cu = "%s%s" % (self._url, qs) | 121 cu = "%s%s" % (self._url, qs) |