Testclient does not treat readable data correctly #1561
Replies: 2 comments
-
We changed the HTTP client from requests to |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'll preemptively close this as outdated, but please let me know. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think this is a potential issue with the TestClient
When posting streaming data, a client call like
can be processed by a server route with a helper method
However this doesn't work with the TestClient, i needed the following workaround on the server
IMO the test client should treat body arguments with a
read
method as therequests
library does, converting it to chunks:https://github.com/python/cpython/blob/c26af2bc531eb114c378cdad81935f6e838a7ee0/Lib/http/client.py#L1045
There seems to be some handling for a request body that is a generator, See
starlette/starlette/testclient.py
Line 212 in 87641dc
but IMO this should be extended to all
body
arguments that have aread
method (for compatibility with therequests
library)Shall I create an issue , and maybe contribute a PR?
Beta Was this translation helpful? Give feedback.
All reactions