Can I make ClientResponse instances from my custom streams?
#11703
Replies: 1 comment
-
|
We generally expect ClientResponse to be created internally by the client, so if you go this way, you may want to pin requirements to the current minor version, in case we break it in a future release. Currently, the class is created at: aiohttp/aiohttp/client_reqrep.py Lines 1405 to 1415 in 1569ad9 That's created by reading/writing to the Connection, which comes from the client's connector. So, the most robust method for you, may be to implement a custom connector, rather than patching any internals of aiohttp. That should minimise maintenance in future. Rather than needing a custom client then, you could just instruct users to do In case it becomes relevant (maybe the custom connector is not enough on it's own), you should also be aware of middlewares: Hopefully, you can achieve everything with them, rather than needing brittle monkey patching. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to add an aiohttp integration to hishel, and one of the main parts of the hishel API is that I need to somehow convert internal models to
aiohttpand vice versa.It's not clear to me what's the most accurate way to create a
ClientResponseinstance from my async iterator (an async iterator that yields the raw response body, like reading from the socket). Can someone share a code example of how to do that, or is it even possible?Beta Was this translation helpful? Give feedback.
All reactions