Skip to content
Discussion options

You must be logged in to vote
  • Double check you're using the latest version of httpx.
  • You want content=... for byte uploads not data=....

If you take a look at the internals you'll see that we do prefer .read(chunk_size) where possible...

httpx/httpx/_content.py

Lines 50 to 64 in b82fbe2

def __iter__(self) -> Iterator[bytes]:
if self._is_stream_consumed and self._is_generator:
raise StreamConsumed()
self._is_stream_consumed = True
if hasattr(self._stream, "read"):
# File-like interfaces should use 'read' directly.
chunk = self._stream.read(self.CHUNK_SIZE) # type: ignore
while chunk:
yield chunk
chunk = self._stream.read(self.CHUNK_SIZE) # type: ignore

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ysn2233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants