-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better compatibility with requests library #3610
Comments
I think that doesn't worth much since aiohttp and requests are very different libraries and there is no reason to lie about the opposite by API mimic. By declaring or taking some actions to have API compatibility with the requests we get the thin path to bound ourself with this compatibility which we'll have to maintain and support. It's also not about names and aliases, but behaviour as well. These two bits are not the only difference between aiohttp client and requests and aiohttp never declared as drop-in async requests replacement. So why should we be? On other hand, some beginner tutorial about requests-to-aiohttp migration which shows differences between libraries could be useful. |
I agree. |
Hi gents, I agree that greater compatibility with |
We have |
Good point, and in fact I do like Just to make it clear once more: it is neither proposed to replace P,S: Why not propose changes into |
Sorry, no. |
Long story short
aiohttp.ClientSession()
is mostly compatible withrequests.Session()
(albeitasync def
vsdef
, of course). It is very convenient, as existingrequests
code can be converted toaiohttp
straightforwardly. However, there are some minor incompatibilities.It is easy to improve compatibility with
requests
without sacrifices, and is proposed to do so.Expected behaviour
In
requests
, multipart-encoded files are passed viafiles
argument whileaiohttp.ClientSession
usesdata
for that:http://docs.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file
https://docs.aiohttp.org/en/stable/client_quickstart.html#post-a-multipart-encoded-file
It is proposed that
aiohttp.ClientSession
also additionally recognizesfiles
argument, processing it asdata
if set (effectively a compatibility alias).Requests response object has
status_code
, whileaiohttp.ClientResponse
usesstatus
:http://docs.python-requests.org/en/master/api/#requests.Response.status_code
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientResponse.status
It is proposed that
aiohttp.ClientResponse
additionally providesstatus_code
compatibility alias.Your environment
requests 2.21.0, aiohttp 3.5.2
The text was updated successfully, but these errors were encountered: