comparison tests/sshprotoext.py @ 36074:2f7290555c96

wireproto: introduce type for raw byte responses (API) Right now we simply return a str/bytes instance for simple responses. I want all wire protocol response types to be strongly typed. So let's invent and use a type for raw bytes responses. .. api:: Wire protocol command handlers now return a wireprototypes.bytesresponse instead of a raw bytes instance. Protocol handlers will continue handling bytes instances. However, any extensions wrapping wire protocol commands will need to handle the new type. Differential Revision: https://phab.mercurial-scm.org/D2089
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 07 Feb 2018 20:27:36 -0800
parents bf676267f64f
children 7db243288afb
comparison
equal deleted inserted replaced
36073:cd6ab329c5c7 36074:2f7290555c96
47 # Respond to unknown commands with an empty reply. 47 # Respond to unknown commands with an empty reply.
48 wireprotoserver._sshv1respondbytes(self._fout, b'') 48 wireprotoserver._sshv1respondbytes(self._fout, b'')
49 l = self._fin.readline() 49 l = self._fin.readline()
50 assert l == b'between\n' 50 assert l == b'between\n'
51 rsp = wireproto.dispatch(self._repo, self._proto, b'between') 51 rsp = wireproto.dispatch(self._repo, self._proto, b'between')
52 wireprotoserver._sshv1respondbytes(self._fout, rsp) 52 wireprotoserver._sshv1respondbytes(self._fout, rsp.data)
53 53
54 super(prehelloserver, self).serve_forever() 54 super(prehelloserver, self).serve_forever()
55 55
56 class upgradev2server(wireprotoserver.sshserver): 56 class upgradev2server(wireprotoserver.sshserver):
57 """Tests behavior for clients that issue upgrade to version 2.""" 57 """Tests behavior for clients that issue upgrade to version 2."""
72 self._fin.read(81) 72 self._fin.read(81)
73 73
74 # Send the upgrade response. 74 # Send the upgrade response.
75 self._fout.write(b'upgraded %s %s\n' % (token, name)) 75 self._fout.write(b'upgraded %s %s\n' % (token, name))
76 servercaps = wireproto.capabilities(self._repo, self._proto) 76 servercaps = wireproto.capabilities(self._repo, self._proto)
77 rsp = b'capabilities: %s' % servercaps 77 rsp = b'capabilities: %s' % servercaps.data
78 self._fout.write(b'%d\n' % len(rsp)) 78 self._fout.write(b'%d\n' % len(rsp))
79 self._fout.write(rsp) 79 self._fout.write(rsp)
80 self._fout.write(b'\n') 80 self._fout.write(b'\n')
81 self._fout.flush() 81 self._fout.flush()
82 82