@hono/node-server
Advanced tools
| export { } | ||
| export { } |
| export { } | ||
| export { } |
+29
-10
@@ -261,4 +261,4 @@ "use strict"; | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -270,3 +270,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -405,11 +407,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -416,0 +435,0 @@ outgoing.writeHead(status, header); |
+29
-10
@@ -222,4 +222,4 @@ // src/server.ts | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -231,3 +231,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -366,11 +368,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -377,0 +396,0 @@ outgoing.writeHead(status, header); |
+29
-10
@@ -253,4 +253,4 @@ "use strict"; | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -262,3 +262,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -397,11 +399,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -408,0 +427,0 @@ outgoing.writeHead(status, header); |
+29
-10
@@ -219,4 +219,4 @@ // src/listener.ts | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -228,3 +228,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -363,11 +365,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -374,0 +393,0 @@ outgoing.writeHead(status, header); |
@@ -25,2 +25,2 @@ import { IncomingMessage } from 'node:http'; | ||
| export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream }; | ||
| export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream }; |
@@ -25,2 +25,2 @@ import { IncomingMessage } from 'node:http'; | ||
| export { GlobalRequest, type IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream }; | ||
| export { GlobalRequest, IncomingMessageWithWrapBodyStream, Request, RequestError, abortControllerKey, getAbortController, newRequest, toRequestError, wrapBodyStream }; |
@@ -8,3 +8,3 @@ import { OutgoingHttpHeaders } from 'node:http'; | ||
| string | ReadableStream, | ||
| Record<string, string> | Headers | OutgoingHttpHeaders | ||
| Record<string, string> | [string, string][] | Headers | OutgoingHttpHeaders | undefined | ||
| ]; | ||
@@ -27,2 +27,2 @@ declare const GlobalResponse: { | ||
| export { GlobalResponse, type InternalCache, Response, cacheKey }; | ||
| export { GlobalResponse, InternalCache, Response, cacheKey }; |
@@ -8,3 +8,3 @@ import { OutgoingHttpHeaders } from 'node:http'; | ||
| string | ReadableStream, | ||
| Record<string, string> | Headers | OutgoingHttpHeaders | ||
| Record<string, string> | [string, string][] | Headers | OutgoingHttpHeaders | undefined | ||
| ]; | ||
@@ -27,2 +27,2 @@ declare const GlobalResponse: { | ||
| export { GlobalResponse, type InternalCache, Response, cacheKey }; | ||
| export { GlobalResponse, InternalCache, Response, cacheKey }; |
+5
-3
@@ -56,4 +56,4 @@ "use strict"; | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -65,3 +65,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -68,0 +70,0 @@ return cache[2]; |
@@ -30,4 +30,4 @@ // src/response.ts | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -39,3 +39,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -42,0 +44,0 @@ return cache[2]; |
@@ -17,2 +17,2 @@ import { Env, Context, MiddlewareHandler } from 'hono'; | ||
| export { type ServeStaticOptions, serveStatic }; | ||
| export { ServeStaticOptions, serveStatic }; |
@@ -17,2 +17,2 @@ import { Env, Context, MiddlewareHandler } from 'hono'; | ||
| export { type ServeStaticOptions, serveStatic }; | ||
| export { ServeStaticOptions, serveStatic }; |
+29
-10
@@ -257,4 +257,4 @@ "use strict"; | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -266,3 +266,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -401,11 +403,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -412,0 +431,0 @@ outgoing.writeHead(status, header); |
+29
-10
@@ -222,4 +222,4 @@ // src/server.ts | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -231,3 +231,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -366,11 +368,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -377,0 +396,0 @@ outgoing.writeHead(status, header); |
+3
-3
@@ -1,3 +0,3 @@ | ||
| import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http'; | ||
| import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2'; | ||
| import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http'; | ||
| import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2'; | ||
| import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https'; | ||
@@ -44,2 +44,2 @@ | ||
| export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType }; | ||
| export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType }; |
+3
-3
@@ -1,3 +0,3 @@ | ||
| import { IncomingMessage, ServerResponse, ServerOptions as ServerOptions$1, createServer, Server } from 'node:http'; | ||
| import { Http2ServerRequest, Http2ServerResponse, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer, Http2Server, Http2SecureServer } from 'node:http2'; | ||
| import { IncomingMessage, ServerResponse, Server, ServerOptions as ServerOptions$1, createServer } from 'node:http'; | ||
| import { Http2ServerRequest, Http2ServerResponse, Http2Server, Http2SecureServer, ServerOptions as ServerOptions$3, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2'; | ||
| import { ServerOptions as ServerOptions$2, createServer as createServer$1 } from 'node:https'; | ||
@@ -44,2 +44,2 @@ | ||
| export type { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType }; | ||
| export { CustomErrorHandler, FetchCallback, Http2Bindings, HttpBindings, NextHandlerOption, Options, ServerOptions, ServerType }; |
+2
-2
@@ -5,6 +5,6 @@ import { OutgoingHttpHeaders } from 'node:http'; | ||
| declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>; | ||
| declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>; | ||
| declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined; | ||
| declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<void>; | ||
| declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined; | ||
| declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders; | ||
| export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader }; |
+2
-2
@@ -5,6 +5,6 @@ import { OutgoingHttpHeaders } from 'node:http'; | ||
| declare function readWithoutBlocking(readPromise: Promise<ReadableStreamReadResult<Uint8Array>>): Promise<ReadableStreamReadResult<Uint8Array> | undefined>; | ||
| declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<undefined>; | ||
| declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<undefined> | undefined; | ||
| declare function writeFromReadableStreamDefaultReader(reader: ReadableStreamDefaultReader<Uint8Array>, writable: Writable, currentReadPromise?: Promise<ReadableStreamReadResult<Uint8Array>> | undefined): Promise<void>; | ||
| declare function writeFromReadableStream(stream: ReadableStream<Uint8Array>, writable: Writable): Promise<void> | undefined; | ||
| declare const buildOutgoingHttpHeaders: (headers: Headers | HeadersInit | null | undefined) => OutgoingHttpHeaders; | ||
| export { buildOutgoingHttpHeaders, readWithoutBlocking, writeFromReadableStream, writeFromReadableStreamDefaultReader }; |
+29
-10
@@ -255,4 +255,4 @@ "use strict"; | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -264,3 +264,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -399,11 +401,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -410,0 +429,0 @@ outgoing.writeHead(status, header); |
+29
-10
@@ -219,4 +219,4 @@ // src/listener.ts | ||
| if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) { | ||
| headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" }; | ||
| this[cacheKey] = [init?.status || 200, body, headers]; | ||
| ; | ||
| this[cacheKey] = [init?.status || 200, body, headers || init?.headers]; | ||
| } | ||
@@ -228,3 +228,5 @@ } | ||
| if (!(cache[2] instanceof Headers)) { | ||
| cache[2] = new Headers(cache[2]); | ||
| cache[2] = new Headers( | ||
| cache[2] || { "content-type": "text/plain; charset=UTF-8" } | ||
| ); | ||
| } | ||
@@ -363,11 +365,28 @@ return cache[2]; | ||
| let [status, body, header] = res[cacheKey]; | ||
| if (header instanceof Headers) { | ||
| let hasContentLength = false; | ||
| if (!header) { | ||
| header = { "content-type": "text/plain; charset=UTF-8" }; | ||
| } else if (header instanceof Headers) { | ||
| hasContentLength = header.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(header); | ||
| } else if (Array.isArray(header)) { | ||
| const headerObj = new Headers(header); | ||
| hasContentLength = headerObj.has("content-length"); | ||
| header = buildOutgoingHttpHeaders(headerObj); | ||
| } else { | ||
| for (const key in header) { | ||
| if (key.length === 14 && key.toLowerCase() === "content-length") { | ||
| hasContentLength = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| if (!hasContentLength) { | ||
| if (typeof body === "string") { | ||
| header["Content-Length"] = Buffer.byteLength(body); | ||
| } else if (body instanceof Uint8Array) { | ||
| header["Content-Length"] = body.byteLength; | ||
| } else if (body instanceof Blob) { | ||
| header["Content-Length"] = body.size; | ||
| } | ||
| } | ||
@@ -374,0 +393,0 @@ outgoing.writeHead(status, header); |
+1
-1
| { | ||
| "name": "@hono/node-server", | ||
| "version": "1.19.10", | ||
| "version": "1.19.11", | ||
| "description": "Node.js Adapter for Hono", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
209899
2.33%6155
2.6%2
-33.33%