From 3e9e39f774d52592beb8b4852a9d888987fa9e7d Mon Sep 17 00:00:00 2001 From: Quentin De Coninck Date: Thu, 23 Feb 2017 14:44:01 +0100 Subject: [PATCH] msg: cope with aggregated requests --- src/msg_server.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/msg_server.py b/src/msg_server.py index e5c33e3..651cb2c 100644 --- a/src/msg_server.py +++ b/src/msg_server.py @@ -49,7 +49,7 @@ class HandleClientConnectionThread(threading.Thread): buffer_data += data - if len(buffer_data) == self.msg_size: + if len(buffer_data) >= self.msg_size: stop_time = datetime.datetime.now() if start_time: self.delays.append(stop_time - start_time) @@ -57,11 +57,7 @@ class HandleClientConnectionThread(threading.Thread): response = string_generator(size=self.msg_size, chars=string.digits) start_time = datetime.datetime.now() self.connection.sendall(response.encode(ENCODING)) - buffer_data = "" - - elif len(buffer_data) > self.msg_size: - print("Too much data; break") - break + buffer_data = buffer_data[self.msg_size:] finally: # Clean up the connection