Skip to content

Commit

Permalink
fix(http): return xhr response headers case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsChaceD authored Sep 21, 2023
1 parent f9be9f5 commit 687b6b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
11 changes: 8 additions & 3 deletions android/capacitor/src/main/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ var nativeBridge = (function (exports) {
}
else if (this.responseType === 'blob') {
this.response = new Blob([responseString], {
type: "application/json",
type: 'application/json',
});
}
else if (this.responseType === 'arraybuffer') {
Expand Down Expand Up @@ -668,7 +668,7 @@ var nativeBridge = (function (exports) {
}
let returnString = '';
for (const key in this._headers) {
if (key != 'Set-Cookie') {
if (key.toLowerCase() !== 'set-cookie') {
returnString += key + ': ' + this._headers[key] + '\r\n';
}
}
Expand All @@ -679,7 +679,12 @@ var nativeBridge = (function (exports) {
if (isRelativeURL(this._url)) {
return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name);
}
return this._headers[name];
for (const key in this._headers) {
if (key.toLowerCase() === name.toLowerCase()) {
return this._headers[key];
}
}
return null;
};
Object.setPrototypeOf(xhr, prototype);
return xhr;
Expand Down
9 changes: 7 additions & 2 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ const initBridge = (w: any): void => {

let returnString = '';
for (const key in this._headers) {
if (key != 'Set-Cookie') {
if (key.toLowerCase() !== 'set-cookie') {
returnString += key + ': ' + this._headers[key] + '\r\n';
}
}
Expand All @@ -802,7 +802,12 @@ const initBridge = (w: any): void => {
name,
);
}
return this._headers[name];
for (const key in this._headers) {
if (key.toLowerCase() === name.toLowerCase()) {
return this._headers[key];
}
}
return null;
};

Object.setPrototypeOf(xhr, prototype);
Expand Down
11 changes: 8 additions & 3 deletions ios/Capacitor/Capacitor/assets/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ var nativeBridge = (function (exports) {
}
else if (this.responseType === 'blob') {
this.response = new Blob([responseString], {
type: "application/json",
type: 'application/json',
});
}
else if (this.responseType === 'arraybuffer') {
Expand Down Expand Up @@ -668,7 +668,7 @@ var nativeBridge = (function (exports) {
}
let returnString = '';
for (const key in this._headers) {
if (key != 'Set-Cookie') {
if (key.toLowerCase() !== 'set-cookie') {
returnString += key + ': ' + this._headers[key] + '\r\n';
}
}
Expand All @@ -679,7 +679,12 @@ var nativeBridge = (function (exports) {
if (isRelativeURL(this._url)) {
return win.CapacitorWebXMLHttpRequest.getResponseHeader.call(this, name);
}
return this._headers[name];
for (const key in this._headers) {
if (key.toLowerCase() === name.toLowerCase()) {
return this._headers[key];
}
}
return null;
};
Object.setPrototypeOf(xhr, prototype);
return xhr;
Expand Down

0 comments on commit 687b6b1

Please sign in to comment.