comparison mercurial/httppeer.py @ 37411:3e1688711efd

wireproto: turn client capabilities into sets, sorted on the wire Differential Revision: https://phab.mercurial-scm.org/D3169
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 06 Apr 2018 21:50:01 +0200
parents e826fe7a08c7
children 61e405fb6372
comparison
equal deleted inserted replaced
37410:a6651f5e2c78 37411:3e1688711efd
280 headers[r'Content-Type'] = r'application/mercurial-0.1' 280 headers[r'Content-Type'] = r'application/mercurial-0.1'
281 281
282 # Tell the server we accept application/mercurial-0.2 and multiple 282 # Tell the server we accept application/mercurial-0.2 and multiple
283 # compression formats if the server is capable of emitting those 283 # compression formats if the server is capable of emitting those
284 # payloads. 284 # payloads.
285 protoparams = [] 285 protoparams = set()
286 286
287 mediatypes = set() 287 mediatypes = set()
288 if self._caps is not None: 288 if self._caps is not None:
289 mt = self.capable('httpmediatype') 289 mt = self.capable('httpmediatype')
290 if mt: 290 if mt:
291 protoparams.append('0.1') 291 protoparams.add('0.1')
292 mediatypes = set(mt.split(',')) 292 mediatypes = set(mt.split(','))
293 293
294 if '0.2tx' in mediatypes: 294 if '0.2tx' in mediatypes:
295 protoparams.append('0.2') 295 protoparams.add('0.2')
296 296
297 if '0.2tx' in mediatypes and self.capable('compression'): 297 if '0.2tx' in mediatypes and self.capable('compression'):
298 # We /could/ compare supported compression formats and prune 298 # We /could/ compare supported compression formats and prune
299 # non-mutually supported or error if nothing is mutually supported. 299 # non-mutually supported or error if nothing is mutually supported.
300 # For now, send the full list to the server and have it error. 300 # For now, send the full list to the server and have it error.
301 comps = [e.wireprotosupport().name for e in 301 comps = [e.wireprotosupport().name for e in
302 util.compengines.supportedwireengines(util.CLIENTROLE)] 302 util.compengines.supportedwireengines(util.CLIENTROLE)]
303 protoparams.append('comp=%s' % ','.join(comps)) 303 protoparams.add('comp=%s' % ','.join(comps))
304 304
305 if protoparams: 305 if protoparams:
306 protoheaders = encodevalueinheaders(' '.join(protoparams), 306 protoheaders = encodevalueinheaders(' '.join(sorted(protoparams)),
307 'X-HgProto', 307 'X-HgProto',
308 headersize or 1024) 308 headersize or 1024)
309 for header, value in protoheaders: 309 for header, value in protoheaders:
310 headers[header] = value 310 headers[header] = value
311 varyheaders.append(header) 311 varyheaders.append(header)