diff --git a/paramiko/message.py b/paramiko/message.py index f46ab3d..3ebd4f0 100644 --- a/paramiko/message.py +++ b/paramiko/message.py @@ -60,7 +60,14 @@ class Message (object): @rtype: string """ return 'paramiko.Message(' + repr(self.packet) + ')' - + + def rewind(self): + """ + Rewind the message to the beginning as if no items had been parsed + out of it yet. + """ + self.idx = 0 + def get_remainder(self): """ Return the bytes of this Message that haven't already been parsed and diff --git a/tests/test_message.py b/tests/test_message.py index 9e4f2a4..218ab52 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -95,4 +95,8 @@ class MessageTest (unittest.TestCase): self.assertEquals(msg.get_mpint(), 0x1122334455L) self.assertEquals(msg.get_so_far(), self.__d[:13]) self.assertEquals(msg.get_remainder(), self.__d[13:]) + msg.rewind() + self.assertEquals(msg.get_int(), 5) + self.assertEquals(msg.get_so_far(), self.__d[:4]) + self.assertEquals(msg.get_remainder(), self.__d[4:])