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:
parent
bd591505f1
commit
8a74a9f7c3
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue