File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,9 @@ def __iter__(self) -> Iterator[bytes]:
50
50
raise StreamConsumed ()
51
51
52
52
self ._is_stream_consumed = True
53
- if hasattr (self ._stream , "read" ):
53
+ if hasattr (self ._stream , "read" ) and not isinstance (
54
+ self ._stream , SyncByteStream
55
+ ):
54
56
# File-like interfaces should use 'read' directly.
55
57
chunk = self ._stream .read (self .CHUNK_SIZE ) # type: ignore
56
58
while chunk :
@@ -75,7 +77,9 @@ async def __aiter__(self) -> AsyncIterator[bytes]:
75
77
raise StreamConsumed ()
76
78
77
79
self ._is_stream_consumed = True
78
- if hasattr (self ._stream , "aread" ):
80
+ if hasattr (self ._stream , "aread" ) and not isinstance (
81
+ self ._stream , AsyncByteStream
82
+ ):
79
83
# File-like interfaces should use 'aread' directly.
80
84
chunk = await self ._stream .aread (self .CHUNK_SIZE ) # type: ignore
81
85
while chunk :
Original file line number Diff line number Diff line change @@ -28,6 +28,18 @@ def data():
28
28
assert response .reason_phrase == "OK"
29
29
30
30
31
+ def test_post_byte_stream (server ):
32
+ class Data (httpx .SyncByteStream ):
33
+ def __iter__ (self ):
34
+ yield b"Hello"
35
+ yield b", "
36
+ yield b"world!"
37
+
38
+ response = httpx .post (server .url , content = Data ())
39
+ assert response .status_code == 200
40
+ assert response .reason_phrase == "OK"
41
+
42
+
31
43
def test_options (server ):
32
44
response = httpx .options (server .url )
33
45
assert response .status_code == 200
You can’t perform that action at this time.
0 commit comments