msg: cope with aggregated requests

This commit is contained in:
Quentin De Coninck 2017-02-23 14:44:01 +01:00
parent 5270b53209
commit 3e9e39f774

View File

@ -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