Commit 96028d58 authored by Ian Briggs's avatar Ian Briggs
Browse files

Actually look for headers instead of assuming order

parent 71eb1ff8
......@@ -49,9 +49,12 @@ class socket:
if self.method == "POST":
beginning, self.body = self.request.decode("latin1").split("\r\n\r\n")
headers = [item.split(": ") for item in beginning.split("\r\n")[1:]]
assert headers[0][0] == "Content-Length"
content_length = headers[0][1]
content_length = None
for tup in headers:
key, val = tup
if key.lower() == "content-length":
content_length = val
assert content_length != None, "Content-Length not present in headers"
assert len(self.body) == int(content_length), len(self.body)
def makefile(self, mode, encoding, newline):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment