Skip to content

Commit

Permalink
Fix different cases of response header names
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Oct 24, 2024
1 parent 591de66 commit 2211880
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/atproto_client/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,12 @@ class Response:


def _convert_headers_to_dict(headers: httpx.Headers) -> t.Dict[str, str]:
headers_dict: t.Dict[str, str] = {}
"""Converts custom case-insensitive multi-dict of HTTPX to pure dict.
for key, value in headers.raw:
str_key = key.decode(headers.encoding)
str_value = value.decode(headers.encoding)
if str_key in headers_dict:
headers_dict[str_key] += f', {str_value}'
else:
headers_dict[str_key] = str_value

return headers_dict
Note:
Concatenate headers into a single comma separated value when a key occurs multiple times.
"""
return {key: value for key, value in headers.items()}


def _parse_response(response: httpx.Response) -> Response:
Expand Down

0 comments on commit 2211880

Please sign in to comment.