Mercurial > public > mercurial-scm > hg-stable
diff mercurial/httppeer.py @ 37544:55b5ba8d4e68
wireproto: client reactor support for receiving frames
We can now feed received frames into the client reactor and it will
validate their sanity, dispatch them appropriately.
The hacky HTTP peer has been updated to use the new code. No
existing tests changed, somewhat proving the code works as
expected.
Rudimentary unit tests for the new functionality have been
implemented.
Differential Revision: https://phab.mercurial-scm.org/D3224
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 09 Apr 2018 16:54:20 -0700 |
parents | 01361be9e2dc |
children | 93397c4633f6 |
line wrap: on
line diff
--- a/mercurial/httppeer.py Mon Apr 09 15:32:01 2018 -0700 +++ b/mercurial/httppeer.py Mon Apr 09 16:54:20 2018 -0700 @@ -551,18 +551,19 @@ self.ui.note(_('received %r\n') % frame) - if frame.typeid == wireprotoframing.FRAME_TYPE_BYTES_RESPONSE: - if frame.flags & wireprotoframing.FLAG_BYTES_RESPONSE_CBOR: - payload = util.bytesio(frame.payload) + action, meta = reactor.onframerecv(frame) + + if action == 'responsedata': + if meta['cbor']: + payload = util.bytesio(meta['data']) decoder = cbor.CBORDecoder(payload) - while payload.tell() + 1 < len(frame.payload): + while payload.tell() + 1 < len(meta['data']): results.append(decoder.decode()) else: - results.append(frame.payload) + results.append(meta['data']) else: - error.ProgrammingError('unhandled frame type: %d' % - frame.typeid) + error.ProgrammingError('unhandled action: %s' % action) return results