You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but the server responds with anything else (e.g. application/pdf) then Reqwest still attempts to decode the response body as JSON. Looking at the code, the culprit seems to be the success() function:
functionsuccess(resp){vartype=o['type']||resp&&setType(resp.getResponseHeader('Content-Type'))// resp can be undefined in IE...
here, o['type'] picks the content type of the request, thus prioritizing it over the content type of the response. Further down, this causes the mentioned attempt to decode as JSON what is not JSON.
As a fix, I’d propose to either swap the two sides of the || operator, or to completely remove the o['type'].
The text was updated successfully, but these errors were encountered:
It seems to me that the
Content-type
of a response is handled incorrectly. For example, if I create a request sending JSON data:but the server responds with anything else (e.g.
application/pdf
) then Reqwest still attempts to decode the response body as JSON. Looking at the code, the culprit seems to be thesuccess()
function:here,
o['type']
picks the content type of the request, thus prioritizing it over the content type of the response. Further down, this causes the mentioned attempt to decode as JSON what is not JSON.As a fix, I’d propose to either swap the two sides of the
||
operator, or to completely remove theo['type']
.The text was updated successfully, but these errors were encountered: