mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-09-03 05:10:25 +03:00
233 lines
12 KiB
Diff
233 lines
12 KiB
Diff
diff --git a/dist/index.js b/dist/index.js
|
|
index 5b00ade9d6e2916d42ea26cbb5a03d74c35778be..a4ab459fe66980cd88a132c1a35792d3d4d3b76f 100644
|
|
--- a/dist/index.js
|
|
+++ b/dist/index.js
|
|
@@ -403,11 +403,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -475,7 +476,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/index.mjs b/dist/index.mjs
|
|
index b30aec91c322070769e62128b41dd23c37e86c71..59dee1e1e4ddc5b36fefb19035cd92167ecba3fd 100644
|
|
--- a/dist/index.mjs
|
|
+++ b/dist/index.mjs
|
|
@@ -364,11 +364,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -436,7 +437,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/listener.js b/dist/listener.js
|
|
index cb081d2ac4205afce10e005d93baf0d8641f62f5..da390fa1dcf5c19c3ba714bf02c8fa87119dc73b 100644
|
|
--- a/dist/listener.js
|
|
+++ b/dist/listener.js
|
|
@@ -395,11 +395,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -467,7 +468,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/listener.mjs b/dist/listener.mjs
|
|
index d6942d693f700b693340a8d7ec076e9b21003a48..eeea2223c412214159ff2cd877eaa238cf14a888 100644
|
|
--- a/dist/listener.mjs
|
|
+++ b/dist/listener.mjs
|
|
@@ -361,11 +361,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -433,7 +434,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/server.js b/dist/server.js
|
|
index bec6481fe78d0d90967d2f7081150a4302ff1123..a943ad3c37e8b18c1b8a03ebbbe2e6f1d2b19a13 100644
|
|
--- a/dist/server.js
|
|
+++ b/dist/server.js
|
|
@@ -399,11 +399,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -471,7 +472,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/server.mjs b/dist/server.mjs
|
|
index c24137822067b1725df11983c780bcab544b2af4..e64d1d192edbcdb4280c0b910f4c0d28740f5b1f 100644
|
|
--- a/dist/server.mjs
|
|
+++ b/dist/server.mjs
|
|
@@ -364,11 +364,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -436,7 +437,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/vercel.js b/dist/vercel.js
|
|
index 63def623e8a86a0dd5bbea8cecb484407667396d..57bcf2cc7c6f8f642b07c9c72f4dea56bfcd1b0a 100644
|
|
--- a/dist/vercel.js
|
|
+++ b/dist/vercel.js
|
|
@@ -397,11 +397,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -469,7 +470,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|
|
diff --git a/dist/vercel.mjs b/dist/vercel.mjs
|
|
index 334c1c85ab8dcd389a3e3892e0e3378c9bdac87e..f5627c4f3473681dda9a6d9488145ff3f7d8c4b9 100644
|
|
--- a/dist/vercel.mjs
|
|
+++ b/dist/vercel.mjs
|
|
@@ -361,11 +361,12 @@ var responseViaCache = async (res, outgoing) => {
|
|
if (header instanceof Headers) {
|
|
header = buildOutgoingHttpHeaders(header);
|
|
}
|
|
- if (typeof body === "string") {
|
|
+ const hasContentRange = "content-range" in header || "Content-Range" in header;
|
|
+ if (!("content-length" in header || "Content-Length" in header) && hasContentRange && typeof body === "string") {
|
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
- } else if (body instanceof Uint8Array) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Uint8Array) {
|
|
header["Content-Length"] = body.byteLength;
|
|
- } else if (body instanceof Blob) {
|
|
+ } else if (!("content-length" in header || "Content-Length" in header) && hasContentRange && body instanceof Blob) {
|
|
header["Content-Length"] = body.size;
|
|
}
|
|
outgoing.writeHead(status, header);
|
|
@@ -433,7 +434,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
break;
|
|
}
|
|
}
|
|
- if (done && !("content-length" in resHeaderRecord)) {
|
|
+ if (done && !("content-length" in resHeaderRecord || "Content-Length" in resHeaderRecord) && ("content-range" in resHeaderRecord || "Content-Range" in resHeaderRecord)) {
|
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
}
|
|
}
|