fix util.dump_response to work with bytes as header values

This commit is contained in:
Mike Fährmann
2023-12-06 23:03:34 +01:00
parent 6a4218aa23
commit bdebe4597a

View File

@@ -275,7 +275,7 @@ Response Headers
if hide_auth:
authorization = req_headers.get("Authorization")
if authorization:
atype, sep, _ = authorization.partition(" ")
atype, sep, _ = str(authorization).partition(" ")
req_headers["Authorization"] = atype + " ***" if sep else "***"
cookie = req_headers.get("Cookie")
@@ -291,15 +291,17 @@ Response Headers
r"(^|, )([^ =]+)=[^,;]*", r"\1\2=***", set_cookie,
)
fmt_nv = "{}: {}".format
fp.write(outfmt.format(
request=request,
response=response,
request_headers="\n".join(
name + ": " + value
fmt_nv(name, value)
for name, value in req_headers.items()
),
response_headers="\n".join(
name + ": " + value
fmt_nv(name, value)
for name, value in res_headers.items()
),
).encode())