Force `responseHeaders` to lower case to respect case-insensitivity

Summary:
`XMLHttpRequest.getResponseHeader` is case-insensitive, therefor the React-Native implementation needs to mimic this behavior as to not break libraries that are dependent on this.

There is a corresponding issue in `superagent` but this is the root cause (https://github.com/visionmedia/superagent/issues/636).
Closes https://github.com/facebook/react-native/pull/1138
Github Author: Ryan Pastorelle <rpastorelle@yahoo.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
Ryan Pastorelle 2015-05-05 14:14:48 -07:00
parent bd591505f1
commit 8a74a9f7c3
1 changed files with 7 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class XMLHttpRequestBase {
getResponseHeader(header: string): ?string {
if (this.responseHeaders) {
var value = this.responseHeaders[header];
var value = this.responseHeaders[header.toLowerCase()];
return value !== undefined ? value : null;
}
return null;
@ -132,7 +132,12 @@ class XMLHttpRequestBase {
return;
}
this.status = status;
this.responseHeaders = responseHeaders || {};
// Headers should be case-insensitive
var lcResponseHeaders = {};
for (var header in responseHeaders) {
lcResponseHeaders[header.toLowerCase()] = responseHeaders[header];
}
this.responseHeaders = lcResponseHeaders;
this.responseText = responseText;
this._setReadyState(this.DONE);
this._sendLoad();