Skip to content

Commit

Permalink
Avoid AttributeError when key or value are already decoded
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-github authored Aug 2, 2024
1 parent d9abbb5 commit 70d807b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mitmproxy2swagger/mitmproxy2swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ def main(override_args: Optional[Sequence[str]] = None):
did_find_anything = False
for key, value in body_val_bytes.items():
did_find_anything = True
body_val[key.decode("utf-8")] = value.decode("utf-8")
if type(key) != str:
key = key.decode("utf-8")
if type(value) != str:
value = value.decode("utf-8")
body_val[key] = value
if did_find_anything:
content_type = "application/x-www-form-urlencoded"
else:
Expand Down

0 comments on commit 70d807b

Please sign in to comment.