@@ -55658,17 +55658,15 @@ var Response2 = class _Response {
5565855658 this.#init = init;
5565955659 }
5566055660 if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
55661- ;
55662- this[cacheKey] = [init?.status || 200, body, headers || init?.headers ];
55661+ headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" } ;
55662+ this[cacheKey] = [init?.status || 200, body, headers];
5566355663 }
5566455664 }
5566555665 get headers() {
5566655666 const cache = this[cacheKey];
5566755667 if (cache) {
5566855668 if (!(cache[2] instanceof Headers)) {
55669- cache[2] = new Headers(
55670- cache[2] || { "content-type": "text/plain; charset=UTF-8" }
55671- );
55669+ cache[2] = new Headers(cache[2]);
5567255670 }
5567355671 return cache[2];
5567455672 }
@@ -55793,32 +55791,15 @@ var flushHeaders = (outgoing) => {
5579355791};
5579455792var responseViaCache = async (res, outgoing) => {
5579555793 let [status, body, header] = res[cacheKey];
55796- let hasContentLength = false;
55797- if (!header) {
55798- header = { "content-type": "text/plain; charset=UTF-8" };
55799- } else if (header instanceof Headers) {
55800- hasContentLength = header.has("content-length");
55794+ if (header instanceof Headers) {
5580155795 header = buildOutgoingHttpHeaders(header);
55802- } else if (Array.isArray(header)) {
55803- const headerObj = new Headers(header);
55804- hasContentLength = headerObj.has("content-length");
55805- header = buildOutgoingHttpHeaders(headerObj);
55806- } else {
55807- for (const key in header) {
55808- if (key.length === 14 && key.toLowerCase() === "content-length") {
55809- hasContentLength = true;
55810- break;
55811- }
55812- }
5581355796 }
55814- if (!hasContentLength) {
55815- if (typeof body === "string") {
55816- header["Content-Length"] = Buffer.byteLength(body);
55817- } else if (body instanceof Uint8Array) {
55818- header["Content-Length"] = body.byteLength;
55819- } else if (body instanceof Blob) {
55820- header["Content-Length"] = body.size;
55821- }
55797+ if (typeof body === "string") {
55798+ header["Content-Length"] = Buffer.byteLength(body);
55799+ } else if (body instanceof Uint8Array) {
55800+ header["Content-Length"] = body.byteLength;
55801+ } else if (body instanceof Blob) {
55802+ header["Content-Length"] = body.size;
5582255803 }
5582355804 outgoing.writeHead(status, header);
5582455805 if (typeof body === "string" || body instanceof Uint8Array) {
0 commit comments