-
-
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
json request for certain media types fail #2206
Comments
You can pass a custom content_type parameter to the ClientResponse.json method, although I agree that this isn't perhaps the most sensible API. I just switched some code from using Requests to using this library and while Requests could decode the JSON without a problem, aiohttp reported an error which will trip some people up. |
Related to #2174 |
Extending the list of accepted json content types is fair easy change. |
use |
@asvetlov, unfortunately I missed the reply on Sep 11; probably my fault. However, I am not sure I agree with your statement that "
I.e., there is no reason for aiohttp to maintain whatever specific list. This is valid for any conversion step, not only for JSON. Yes, I agree that using |
What to do? Maybe you can pass a custom content type when fetching a data from your server? |
The fundamental fact is that data coming with To take a specific example. In my view, this means that the handling of the (You will find an abundance of such media types on the media type registry.) |
You would say that any |
I'd say both statements are true. |
By sending |
@asvetlov : parsing the json types from the media registry is of course nicer and better but... it is not that obvious. Would aiohttp check that registry any time the "read" function is called? Would set up some sort of a local cache for the registry that has a finite lifetime? The registry is a changing target after all... I believe just saying that "any |
Reopen the issue. |
@asvetlov : I have no idea when I could do that; I have never looked into the internal of the aiohttp code, ie, it would take me quite a while to familiarize myself with it to produce a proper PR. I can try at some point unless somebody beats me into it, but it may take a while:-( |
@asvetlov, I have looked at the code and I think I have found the few changes that are required. However, I simply will not have the time to make a proper pull request, ie, running all the necessary tests on the code overall. It would require a major setup on my machine, understanding how the test harness works, etc. Sorry, but that will not work. I will look at the code again tomorrow just to be sure, and I could then forward you (tomorrow or on Wednesday) the file where I have made some changes: |
…ntResponse.json()
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
The
resp.json()
call reports a bug if the return type is something likeapplication/XXX+json
(as opposed toapplication/json
). However,application/XXX+json
is a perfectly fine media type, "extending" the semantics (not the syntax) of the core json syntax, ie, should be parsed as bona fide json...Your environment
OS X 10.11.6, Python 3.6.2
The text was updated successfully, but these errors were encountered: