Skip to content

Commit

Permalink
Force responseHeaders to lower case to respect case-insensitivity
Browse files Browse the repository at this point in the history
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 (ladjs/superagent#636).
Closes facebook#1138
Github Author: Ryan Pastorelle <rpastorelle@yahoo.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
  • Loading branch information
rpastorelle committed May 5, 2015
1 parent bd59150 commit 8a74a9f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Libraries/Network/XMLHttpRequestBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8a74a9f

Please sign in to comment.