This patch is my attempt to work around the Mozilla bug. It makes response.getHeader() work as expected for a CORS request, which it currentlyo does not.
This patch does 3 things:
Renames the res variable to xhr in response.js. This makes sense, because it is an xhr, and is less likely to be confused with Response.
Stores the response's xhr in this.xhr, so the Response methods have access to it and don't need to pass it around.
Makes response.getHeader call xhr.getResponseHeader directly if the header isn't in the header hash.
The first 2 were necessary cleanup to make the 3rd possible. It touches a lot of code, but most of the changes are trivial.
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
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.
Oh Firefox....
Mozilla bug #608735 has been open for over a year, and it's not clear if it will get fixed soon.
The bug description is basically this:
If an XHR is a CORS request, then xhr.getAllResponseHeaders will always return {}.
xhr.getResponseHeader still works as expected.
The jQuery guys have been complaining about this bug and passing around patches here:
http://bugs.jquery.com/ticket/10338
This patch is my attempt to work around the Mozilla bug. It makes response.getHeader() work as expected for a CORS request, which it currentlyo does not.
This patch does 3 things:
The first 2 were necessary cleanup to make the 3rd possible. It touches a lot of code, but most of the changes are trivial.