Skip to content

What is the reason to not return body of ClientResponse after connecction is closed? #7905

Answered by Dreamsorcerer
alufrew asked this question in Q&A
Discussion options

You must be logged in to vote

P.S. Context why I do it whis way. I try to create simplistic api client. I can create my response adapter which will get needed data from ClientResponse but it seems to be an overhead when ClientResponse has all needed info and methods.

I would suggest you create that adapter. Even if we changed this, I would still recommend not passing around a Response object outside of its context. It is not designed like that, and we'll probably break your code in some way later on.

Also, creating a whole new ClientSession() in every request isn't very efficient and not doing you any favours. If you don't care about performance, then you can just use https://docs.aiohttp.org/en/stable/client_refere…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@alufrew
Comment options

Answer selected by alufrew
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants