Skip to content

Commit 3d01ec4

Browse files
committed
Fix: ? always in debug messages and only first value was displayed
1 parent b3d5577 commit 3d01ec4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

adafruit_httpserver/request.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def get_list(self, field_name: str, *, safe=True) -> List[str]:
6565
return super().get_list(field_name, safe=safe)
6666

6767
def __str__(self) -> str:
68-
return "&".join(f"{key}={value}" for key, value in self.items())
68+
return "&".join(
69+
f"{field_name}={value}"
70+
for field_name in self.fields
71+
for value in self.get_list(field_name)
72+
)
6973

7074

7175
class File:
@@ -469,9 +473,7 @@ def _parse_request_header(
469473

470474
method, path, http_version = start_line.strip().split()
471475

472-
if "?" not in path:
473-
path += "?"
474-
476+
path = path if "?" in path else path + "?"
475477
path, query_string = path.split("?", 1)
476478

477479
query_params = QueryParams(query_string)

adafruit_httpserver/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def _debug_response_sent(response: "Response", time_elapsed: float):
512512
client_ip = response._request.client_address[0]
513513
method = response._request.method
514514
query_params = response._request.query_params
515-
path = response._request.path + f"?{query_params or ''}"
515+
path = response._request.path + (f"?{query_params}" if query_params else "")
516516
req_size = len(response._request.raw_request)
517517
status = response._status
518518
res_size = response._size

0 commit comments

Comments
 (0)