Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix different cases of response header names #415

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] = {}
"""Convert custom case-insensitive multi-dict of HTTPX to pure dict with lowercased keys.

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 dict(headers.items())


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