mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Ignore the case when getting a response header (#2250)
According to the RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 "Field names are case-insensitive". For instance, Google Cloud Endpoints use "content-type" in the response.
This commit is contained in:
committed by
Hristo Hristov
parent
81288df17f
commit
6282baefd8
@@ -119,7 +119,7 @@ export class XMLHttpRequest {
|
||||
this._responseTextReader = () => r.content.toString();
|
||||
this._response = JSON.parse(this.responseText);
|
||||
|
||||
// Add toString() method to ease debugging and
|
||||
// Add toString() method to ease debugging and
|
||||
// make Angular2 response.text() method work properly.
|
||||
Object.defineProperty(this._response, "toString", {
|
||||
configurable: true,
|
||||
@@ -194,10 +194,14 @@ export class XMLHttpRequest {
|
||||
public getResponseHeader(header: string): string {
|
||||
if (types.isString(header) && this._readyState > 1
|
||||
&& this._headers
|
||||
&& this._headers[header]
|
||||
&& !this._errorFlag
|
||||
) {
|
||||
return this._headers[header];
|
||||
header = header.toLowerCase();
|
||||
for (var i in this._headers) {
|
||||
if (i.toLowerCase() === header) {
|
||||
return this._headers[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user