We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 231f555 commit 17fbdb2Copy full SHA for 17fbdb2
1 file changed
httpx/_content.py
@@ -133,12 +133,12 @@ def encode_content(
133
return headers, IteratorByteStream(content) # type: ignore
134
135
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:
+ if isinstance(content, AsyncFile) and (
+ content_length_or_none := peek_filelike_length(content)
+ ):
141
headers = {"Content-Length": str(content_length_or_none)}
+ else:
+ headers = {"Transfer-Encoding": "chunked"}
142
return headers, AsyncIteratorByteStream(content)
143
144
raise TypeError(f"Unexpected type for 'content', {type(content)!r}")
0 commit comments