Skip to content

Commit

Permalink
When setting headers, fallback to utf-8 if no encoding is specified…
Browse files Browse the repository at this point in the history
… yet. (#820)

* Headers: fallback to utf8 encoding

* Headers.__setitem__: use utf8 only if encoding is not set
  • Loading branch information
oczkers committed Feb 24, 2020
1 parent efe9f61 commit 50d337e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions httpx/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ def __setitem__(self, key: str, value: str) -> None:
Set the header `key` to `value`, removing any duplicate entries.
Retains insertion order.
"""
set_key = key.lower().encode(self.encoding)
set_value = value.encode(self.encoding)
set_key = key.lower().encode(self._encoding or "utf-8")
set_value = value.encode(self._encoding or "utf-8")

found_indexes = []
for idx, (item_key, _) in enumerate(self._list):
Expand Down

0 comments on commit 50d337e

Please sign in to comment.