fix compability issue
This commit is contained in:
parent
15c163e73d
commit
f55fad0e29
@ -48,15 +48,24 @@ if (VALID_REQURL) {
|
|||||||
if (contentType !== undefined) {
|
if (contentType !== undefined) {
|
||||||
contentType = contentType.toLowerCase();
|
contentType = contentType.toLowerCase();
|
||||||
}
|
}
|
||||||
|
const rspHeaders = { ...r.headers };
|
||||||
|
for (let key in rspHeaders) {
|
||||||
|
if (rspHeaders.hasOwnProperty(key)) {
|
||||||
|
if (key === "content-disposition" || key === "Content-Disposition") {
|
||||||
|
rspHeaders[key] = encodeURIComponent(rspHeaders[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// console.log(`requesting url=${options.url}`);
|
// console.log(`requesting url=${options.url}`);
|
||||||
// console.log(`contentType=${contentType}`);
|
// console.log(`contentType=${contentType}`);
|
||||||
|
// console.log(`rspHeaders=${JSON.stringify(rspHeaders)}`)
|
||||||
|
|
||||||
// let r2: Response = undefined;
|
// let r2: Response = undefined;
|
||||||
// if (contentType.includes("xml")) {
|
// if (contentType.includes("xml")) {
|
||||||
// r2 = new Response(r.text, {
|
// r2 = new Response(r.text, {
|
||||||
// status: r.status,
|
// status: r.status,
|
||||||
// statusText: getReasonPhrase(r.status),
|
// statusText: getReasonPhrase(r.status),
|
||||||
// headers: r.headers,
|
// headers: rspHeaders,
|
||||||
// });
|
// });
|
||||||
// } else if (
|
// } else if (
|
||||||
// contentType.includes("json") ||
|
// contentType.includes("json") ||
|
||||||
@ -70,7 +79,7 @@ if (VALID_REQURL) {
|
|||||||
// {
|
// {
|
||||||
// status: r.status,
|
// status: r.status,
|
||||||
// statusText: getReasonPhrase(r.status),
|
// statusText: getReasonPhrase(r.status),
|
||||||
// headers: r.headers,
|
// headers: rspHeaders,
|
||||||
// });
|
// });
|
||||||
// } else if (contentType.includes("text")) {
|
// } else if (contentType.includes("text")) {
|
||||||
// // avoid text/json,
|
// // avoid text/json,
|
||||||
@ -78,7 +87,7 @@ if (VALID_REQURL) {
|
|||||||
// r2 = new Response(r.text, {
|
// r2 = new Response(r.text, {
|
||||||
// status: r.status,
|
// status: r.status,
|
||||||
// statusText: getReasonPhrase(r.status),
|
// statusText: getReasonPhrase(r.status),
|
||||||
// headers: r.headers,
|
// headers: rspHeaders,
|
||||||
// });
|
// });
|
||||||
// } else if (
|
// } else if (
|
||||||
// contentType.includes("octet-stream") ||
|
// contentType.includes("octet-stream") ||
|
||||||
@ -89,7 +98,7 @@ if (VALID_REQURL) {
|
|||||||
// r2 = new Response(r.arrayBuffer, {
|
// r2 = new Response(r.arrayBuffer, {
|
||||||
// status: r.status,
|
// status: r.status,
|
||||||
// statusText: getReasonPhrase(r.status),
|
// statusText: getReasonPhrase(r.status),
|
||||||
// headers: r.headers,
|
// headers: rspHeaders,
|
||||||
// });
|
// });
|
||||||
// } else {
|
// } else {
|
||||||
// throw Error(
|
// throw Error(
|
||||||
@ -105,13 +114,13 @@ if (VALID_REQURL) {
|
|||||||
r2 = new Response(null, {
|
r2 = new Response(null, {
|
||||||
status: r.status,
|
status: r.status,
|
||||||
statusText: getReasonPhrase(r.status),
|
statusText: getReasonPhrase(r.status),
|
||||||
headers: r.headers,
|
headers: rspHeaders,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
r2 = new Response(r.arrayBuffer, {
|
r2 = new Response(r.arrayBuffer, {
|
||||||
status: r.status,
|
status: r.status,
|
||||||
statusText: getReasonPhrase(r.status),
|
statusText: getReasonPhrase(r.status),
|
||||||
headers: r.headers,
|
headers: rspHeaders,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user