Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotov2server.py @ 39448:660879e49b46
wireprotov2server: use our CBOR encoder
Again, test output changed slightly because of map key ordering
differences. This shouldn't matter.
I could have called oncommandresponsereadygen() with the raw output
from the stream encoder. However, this changed test output further.
I left a TODO to follow up on that later.
Differential Revision: https://phab.mercurial-scm.org/D4468
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 28 Aug 2018 18:12:04 -0700 |
parents | 856f381ad74b |
children | 07b58266bce3 |
comparison
equal
deleted
inserted
replaced
39447:5f4a9ada5ab5 | 39448:660879e49b46 |
---|---|
7 from __future__ import absolute_import | 7 from __future__ import absolute_import |
8 | 8 |
9 import contextlib | 9 import contextlib |
10 | 10 |
11 from .i18n import _ | 11 from .i18n import _ |
12 from .thirdparty import ( | |
13 cbor, | |
14 ) | |
15 from . import ( | 12 from . import ( |
16 encoding, | 13 encoding, |
17 error, | 14 error, |
18 pycompat, | 15 pycompat, |
19 streamclone, | 16 streamclone, |
20 util, | 17 util, |
21 wireprotoframing, | 18 wireprotoframing, |
22 wireprototypes, | 19 wireprototypes, |
23 ) | 20 ) |
24 from .utils import ( | 21 from .utils import ( |
22 cborutil, | |
25 interfaceutil, | 23 interfaceutil, |
26 ) | 24 ) |
27 | 25 |
28 FRAMINGTYPE = b'application/mercurial-exp-framing-0005' | 26 FRAMINGTYPE = b'application/mercurial-exp-framing-0005' |
29 | 27 |
300 rsp = dispatch(repo, proto, command['command']) | 298 rsp = dispatch(repo, proto, command['command']) |
301 | 299 |
302 res.status = b'200 OK' | 300 res.status = b'200 OK' |
303 res.headers[b'Content-Type'] = FRAMINGTYPE | 301 res.headers[b'Content-Type'] = FRAMINGTYPE |
304 | 302 |
303 # TODO consider adding a type to represent an iterable of values to | |
304 # be CBOR encoded. | |
305 if isinstance(rsp, wireprototypes.cborresponse): | 305 if isinstance(rsp, wireprototypes.cborresponse): |
306 encoded = cbor.dumps(rsp.value, canonical=True) | 306 # TODO consider calling oncommandresponsereadygen(). |
307 encoded = b''.join(cborutil.streamencode(rsp.value)) | |
307 action, meta = reactor.oncommandresponseready(outstream, | 308 action, meta = reactor.oncommandresponseready(outstream, |
308 command['requestid'], | 309 command['requestid'], |
309 encoded) | 310 encoded) |
310 elif isinstance(rsp, wireprototypes.v2streamingresponse): | 311 elif isinstance(rsp, wireprototypes.v2streamingresponse): |
311 action, meta = reactor.oncommandresponsereadygen(outstream, | 312 action, meta = reactor.oncommandresponsereadygen(outstream, |