Mercurial > hg
comparison mercurial/wireprotov2server.py @ 37722:89a16704114c
wireprotov2: define response data as CBOR
Previously, response data was defined as a stream of bytes. We had
the option to declare it as CBOR using a frame flag.
We've converged all wire protocol commands exposed on version 2 to
CBOR. I think consistency is important. The overhead to encoding
things with CBOR is minimal. Even a very large bytestring can be
efficiently encoded using an indefinite length bytestring. Now,
there are limitations with consumers not being able to efficiently
stream large CBOR values. But these feel like solvable problems.
This commit removes the "is CBOR" frame flag from command response
frames and defines the frame as always consisting of a stream of
CBOR values.
The framing protocol media type has been bumped to reflect this
BC change.
Differential Revision: https://phab.mercurial-scm.org/D3382
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 14 Apr 2018 12:07:31 -0700 |
parents | 23c4ddda7bbe |
children | deff7cf7eefd |
comparison
equal
deleted
inserted
replaced
37721:f7673845b167 | 37722:89a16704114c |
---|---|
24 wireproto, | 24 wireproto, |
25 wireprotoframing, | 25 wireprotoframing, |
26 wireprototypes, | 26 wireprototypes, |
27 ) | 27 ) |
28 | 28 |
29 FRAMINGTYPE = b'application/mercurial-exp-framing-0003' | 29 FRAMINGTYPE = b'application/mercurial-exp-framing-0004' |
30 | 30 |
31 HTTP_WIREPROTO_V2 = wireprototypes.HTTP_WIREPROTO_V2 | 31 HTTP_WIREPROTO_V2 = wireprototypes.HTTP_WIREPROTO_V2 |
32 | 32 |
33 def handlehttpv2request(rctx, req, res, checkperm, urlparts): | 33 def handlehttpv2request(rctx, req, res, checkperm, urlparts): |
34 from .hgweb import common as hgwebcommon | 34 from .hgweb import common as hgwebcommon |
307 rsp.data) | 307 rsp.data) |
308 elif isinstance(rsp, wireprototypes.cborresponse): | 308 elif isinstance(rsp, wireprototypes.cborresponse): |
309 encoded = cbor.dumps(rsp.value, canonical=True) | 309 encoded = cbor.dumps(rsp.value, canonical=True) |
310 action, meta = reactor.onbytesresponseready(outstream, | 310 action, meta = reactor.onbytesresponseready(outstream, |
311 command['requestid'], | 311 command['requestid'], |
312 encoded, | 312 encoded) |
313 iscbor=True) | |
314 else: | 313 else: |
315 action, meta = reactor.onapplicationerror( | 314 action, meta = reactor.onapplicationerror( |
316 _('unhandled response type from wire proto command')) | 315 _('unhandled response type from wire proto command')) |
317 | 316 |
318 if action == 'sendframes': | 317 if action == 'sendframes': |