Skip to content

Commit 17fbdb2

Browse files
committed
fix unbound local in content encoding
1 parent 231f555 commit 17fbdb2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

httpx/_content.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ def encode_content(
133133
return headers, IteratorByteStream(content) # type: ignore
134134

135135
elif isinstance(content, AsyncIterable):
136-
if isinstance(content, AsyncFile):
137-
content_length_or_none = peek_filelike_length(content)
138-
if content_length_or_none is None:
139-
headers = {"Transfer-Encoding": "chunked"}
140-
else:
136+
if isinstance(content, AsyncFile) and (
137+
content_length_or_none := peek_filelike_length(content)
138+
):
141139
headers = {"Content-Length": str(content_length_or_none)}
140+
else:
141+
headers = {"Transfer-Encoding": "chunked"}
142142
return headers, AsyncIteratorByteStream(content)
143143

144144
raise TypeError(f"Unexpected type for 'content', {type(content)!r}")

0 commit comments

Comments
 (0)