comparison mercurial/httppeer.py @ 39445:cdb56f295b03

httppeer: use our CBOR decoder We just implemented our own CBOR decoder. Let's use it in httppeer. Differential Revision: https://phab.mercurial-scm.org/D4465
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 28 Aug 2018 15:10:56 -0700
parents 3c6f7eebc010
children 1fc39367eafd
comparison
equal deleted inserted replaced
39444:45d12c49c3f3 39445:cdb56f295b03
14 import socket 14 import socket
15 import struct 15 import struct
16 import weakref 16 import weakref
17 17
18 from .i18n import _ 18 from .i18n import _
19 from .thirdparty import (
20 cbor,
21 )
22 from . import ( 19 from . import (
23 bundle2, 20 bundle2,
24 error, 21 error,
25 httpconnection, 22 httpconnection,
26 pycompat, 23 pycompat,
33 wireprotov1peer, 30 wireprotov1peer,
34 wireprotov2peer, 31 wireprotov2peer,
35 wireprotov2server, 32 wireprotov2server,
36 ) 33 )
37 from .utils import ( 34 from .utils import (
35 cborutil,
38 interfaceutil, 36 interfaceutil,
39 stringutil, 37 stringutil,
40 ) 38 )
41 39
42 httplib = util.httplib 40 httplib = util.httplib
911 raise error.ProgrammingError('unexpected content-type: %s' % ct) 909 raise error.ProgrammingError('unexpected content-type: %s' % ct)
912 910
913 if advertisev2: 911 if advertisev2:
914 if ct == 'application/mercurial-cbor': 912 if ct == 'application/mercurial-cbor':
915 try: 913 try:
916 info = cbor.loads(rawdata) 914 info = cborutil.decodeall(rawdata)[0]
917 except cbor.CBORDecodeError: 915 except cborutil.CBORDecodeError:
918 raise error.Abort(_('error decoding CBOR from remote server'), 916 raise error.Abort(_('error decoding CBOR from remote server'),
919 hint=_('try again and consider contacting ' 917 hint=_('try again and consider contacting '
920 'the server operator')) 918 'the server operator'))
921 919
922 # We got a legacy response. That's fine. 920 # We got a legacy response. That's fine.