http-browserify
http-browserify copied to clipboard
Work-around for Moz bug #608735
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:
- Renames the
res
variable toxhr
in response.js. This makes sense, because it is an xhr, and is less likely to be confused withResponse
. - 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
callxhr.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.