Skip to content

Commit

Permalink
Merge pull request #57 from ccrighton/phew_issue_56
Browse files Browse the repository at this point in the history
Ensure that all form data is read to content-length
  • Loading branch information
Gadgetoid authored Jun 26, 2024
2 parents 61c0195 + f0063cb commit 751c404
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion phew/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,14 @@ async def _handle_request(reader, writer):
if request.headers["content-type"].startswith("application/json"):
request.data = await _parse_json_body(reader, request.headers)
if request.headers["content-type"].startswith("application/x-www-form-urlencoded"):
form_data = await reader.read(int(request.headers["content-length"]))
form_data = b""
content_length = int(request.headers["content-length"])
while content_length > 0:
data = await reader.read(content_length)
if len(data) == 0:
break
content_length -= len(data)
form_data += data
request.form = _parse_query_string(form_data.decode())

route = _match_route(request)
Expand Down

0 comments on commit 751c404

Please sign in to comment.