Skip to content
Myr

When setting headers, fallback to `utf-8` if no encoding is specified yet. (#820)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Headers: fallback to utf8 encoding * Headers.__setitem__: use utf8 only if encoding is not set

authored by Piotr Staroszczyk · committed by GitHub · parent efe9f61 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:httpx/_models.py+2 added-2 removed
513 unmodified lines
514 """515 Set the header `key` to `value`, removing any duplicate entries.516 Retains insertion order.517 """518 set_key = key.lower().encode(self.encoding)519 set_value = value.encode(self.encoding)518 set_key = key.lower().encode(self._encoding or "utf-8")519 set_value = value.encode(self._encoding or "utf-8")520521 found_indexes = []522 for idx, (item_key, _) in enumerate(self._list):523 if item_key == set_key:
684 unmodified lines