Skip to content

Commit

Permalink
Fix server bug
Browse files Browse the repository at this point in the history
In cases were the Content-Length value was greater than the actual
length of the HTTP body being send, the server entered in an infinite
loop.

This was quickly fixed by adding an extra condition to the loop were
the data was read in.
  • Loading branch information
sergioburdisso committed Feb 14, 2020
1 parent a0131f0 commit d106d68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyss3/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ def __send_as_json__(sock, data):
def __recvall_body__(sock, data, length):
"""Receive all HTTP message body."""
body = get_http_body(data)
while len(body) < length:
body += sock.recv(RECV_BUFFER).decode()
while len(body) < length and data:
data = sock.recv(RECV_BUFFER).decode()
body += data
return url_decode(body)

@staticmethod
Expand Down

0 comments on commit d106d68

Please sign in to comment.