Dont throw/catch transform exceptions on 304#3036
Closed
pebl-work wants to merge 3 commits intoaxios:masterfrom
Closed
Dont throw/catch transform exceptions on 304#3036pebl-work wants to merge 3 commits intoaxios:masterfrom
pebl-work wants to merge 3 commits intoaxios:masterfrom
Conversation
Dont try to parse response data from 304 requests, as it is suppose to not have a body. The real problem is A) https://github.com/axios/axios/blob/36f0ad2f985c3289018f0fdaaddf309cc9458d9b/lib/adapters/xhr.js#L28 in some browsers set response/responseText to "" in XMLHttpRequest. At this point B) https://github.com/axios/axios/blob/36f0ad2f985c3289018f0fdaaddf309cc9458d9b/lib/adapters/xhr.js#L61 the response/responseText is copied directly without checking if there should be a body; copying "". The same problem at this place: C) https://github.com/axios/axios/blob/5b08fc4ac7ecc896efa37952645ea578a3609fc2/lib/core/dispatchRequest.js#L56 And finally at the patched line, where the "" is attempted to be parsed as JSON, which it is not, nor should be. I dont think A) will change, and changing B+C) is a lot of complex code for very little.
Member
|
@pebl-work please can you fix the conflicts in this branch, update it to the latest master, and let me know so I can review it fully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dont try to parse response data from 304 requests, as it is suppose to not have a body.
The real problem is A)
axios/lib/adapters/xhr.js
Line 28 in 36f0ad2
in some browsers set response/responseText to "" in XMLHttpRequest.
At this point B)
axios/lib/adapters/xhr.js
Line 61 in 36f0ad2
the response/responseText is copied directly without checking if there should be a body; copying "".
The same problem at this place: C)
axios/lib/core/dispatchRequest.js
Line 57 in 5b08fc4
And finally at the patched line, where the "" is attempted to be parsed as JSON, which it is not, nor should be.
I dont think A) will change, and changing B+C) is a lot of complex code for very little.