@hono/node-server 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -384,18 +384,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
384
384
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
385
385
  const internalBody = getInternalBody(res);
386
386
  if (internalBody) {
387
- if (internalBody.length) {
388
- resHeaderRecord["content-length"] = internalBody.length;
389
- }
390
- outgoing.writeHead(res.status, resHeaderRecord);
391
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
392
- outgoing.end(internalBody.source);
393
- } else if (internalBody.source instanceof Blob) {
394
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
387
+ const { length, source, stream } = internalBody;
388
+ if (source instanceof Uint8Array && source.byteLength !== length) {
395
389
  } else {
396
- await writeFromReadableStream(internalBody.stream, outgoing);
390
+ if (length) {
391
+ resHeaderRecord["content-length"] = length;
392
+ }
393
+ outgoing.writeHead(res.status, resHeaderRecord);
394
+ if (typeof source === "string" || source instanceof Uint8Array) {
395
+ outgoing.end(source);
396
+ } else if (source instanceof Blob) {
397
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
398
+ } else {
399
+ await writeFromReadableStream(stream, outgoing);
400
+ }
401
+ return;
397
402
  }
398
- } else if (res.body) {
403
+ }
404
+ if (res.body) {
399
405
  const {
400
406
  "transfer-encoding": transferEncoding,
401
407
  "content-encoding": contentEncoding,
package/dist/index.mjs CHANGED
@@ -345,18 +345,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
345
345
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
346
346
  const internalBody = getInternalBody(res);
347
347
  if (internalBody) {
348
- if (internalBody.length) {
349
- resHeaderRecord["content-length"] = internalBody.length;
350
- }
351
- outgoing.writeHead(res.status, resHeaderRecord);
352
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
353
- outgoing.end(internalBody.source);
354
- } else if (internalBody.source instanceof Blob) {
355
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
348
+ const { length, source, stream } = internalBody;
349
+ if (source instanceof Uint8Array && source.byteLength !== length) {
356
350
  } else {
357
- await writeFromReadableStream(internalBody.stream, outgoing);
351
+ if (length) {
352
+ resHeaderRecord["content-length"] = length;
353
+ }
354
+ outgoing.writeHead(res.status, resHeaderRecord);
355
+ if (typeof source === "string" || source instanceof Uint8Array) {
356
+ outgoing.end(source);
357
+ } else if (source instanceof Blob) {
358
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
359
+ } else {
360
+ await writeFromReadableStream(stream, outgoing);
361
+ }
362
+ return;
358
363
  }
359
- } else if (res.body) {
364
+ }
365
+ if (res.body) {
360
366
  const {
361
367
  "transfer-encoding": transferEncoding,
362
368
  "content-encoding": contentEncoding,
package/dist/listener.js CHANGED
@@ -378,18 +378,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
378
378
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
379
379
  const internalBody = getInternalBody(res);
380
380
  if (internalBody) {
381
- if (internalBody.length) {
382
- resHeaderRecord["content-length"] = internalBody.length;
383
- }
384
- outgoing.writeHead(res.status, resHeaderRecord);
385
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
386
- outgoing.end(internalBody.source);
387
- } else if (internalBody.source instanceof Blob) {
388
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
381
+ const { length, source, stream } = internalBody;
382
+ if (source instanceof Uint8Array && source.byteLength !== length) {
389
383
  } else {
390
- await writeFromReadableStream(internalBody.stream, outgoing);
384
+ if (length) {
385
+ resHeaderRecord["content-length"] = length;
386
+ }
387
+ outgoing.writeHead(res.status, resHeaderRecord);
388
+ if (typeof source === "string" || source instanceof Uint8Array) {
389
+ outgoing.end(source);
390
+ } else if (source instanceof Blob) {
391
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
392
+ } else {
393
+ await writeFromReadableStream(stream, outgoing);
394
+ }
395
+ return;
391
396
  }
392
- } else if (res.body) {
397
+ }
398
+ if (res.body) {
393
399
  const {
394
400
  "transfer-encoding": transferEncoding,
395
401
  "content-encoding": contentEncoding,
package/dist/listener.mjs CHANGED
@@ -342,18 +342,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
342
342
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
343
343
  const internalBody = getInternalBody(res);
344
344
  if (internalBody) {
345
- if (internalBody.length) {
346
- resHeaderRecord["content-length"] = internalBody.length;
347
- }
348
- outgoing.writeHead(res.status, resHeaderRecord);
349
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
350
- outgoing.end(internalBody.source);
351
- } else if (internalBody.source instanceof Blob) {
352
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
345
+ const { length, source, stream } = internalBody;
346
+ if (source instanceof Uint8Array && source.byteLength !== length) {
353
347
  } else {
354
- await writeFromReadableStream(internalBody.stream, outgoing);
348
+ if (length) {
349
+ resHeaderRecord["content-length"] = length;
350
+ }
351
+ outgoing.writeHead(res.status, resHeaderRecord);
352
+ if (typeof source === "string" || source instanceof Uint8Array) {
353
+ outgoing.end(source);
354
+ } else if (source instanceof Blob) {
355
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
356
+ } else {
357
+ await writeFromReadableStream(stream, outgoing);
358
+ }
359
+ return;
355
360
  }
356
- } else if (res.body) {
361
+ }
362
+ if (res.body) {
357
363
  const {
358
364
  "transfer-encoding": transferEncoding,
359
365
  "content-encoding": contentEncoding,
package/dist/server.js CHANGED
@@ -380,18 +380,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
380
380
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
381
381
  const internalBody = getInternalBody(res);
382
382
  if (internalBody) {
383
- if (internalBody.length) {
384
- resHeaderRecord["content-length"] = internalBody.length;
385
- }
386
- outgoing.writeHead(res.status, resHeaderRecord);
387
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
388
- outgoing.end(internalBody.source);
389
- } else if (internalBody.source instanceof Blob) {
390
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
383
+ const { length, source, stream } = internalBody;
384
+ if (source instanceof Uint8Array && source.byteLength !== length) {
391
385
  } else {
392
- await writeFromReadableStream(internalBody.stream, outgoing);
386
+ if (length) {
387
+ resHeaderRecord["content-length"] = length;
388
+ }
389
+ outgoing.writeHead(res.status, resHeaderRecord);
390
+ if (typeof source === "string" || source instanceof Uint8Array) {
391
+ outgoing.end(source);
392
+ } else if (source instanceof Blob) {
393
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
394
+ } else {
395
+ await writeFromReadableStream(stream, outgoing);
396
+ }
397
+ return;
393
398
  }
394
- } else if (res.body) {
399
+ }
400
+ if (res.body) {
395
401
  const {
396
402
  "transfer-encoding": transferEncoding,
397
403
  "content-encoding": contentEncoding,
package/dist/server.mjs CHANGED
@@ -345,18 +345,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
345
345
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
346
346
  const internalBody = getInternalBody(res);
347
347
  if (internalBody) {
348
- if (internalBody.length) {
349
- resHeaderRecord["content-length"] = internalBody.length;
350
- }
351
- outgoing.writeHead(res.status, resHeaderRecord);
352
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
353
- outgoing.end(internalBody.source);
354
- } else if (internalBody.source instanceof Blob) {
355
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
348
+ const { length, source, stream } = internalBody;
349
+ if (source instanceof Uint8Array && source.byteLength !== length) {
356
350
  } else {
357
- await writeFromReadableStream(internalBody.stream, outgoing);
351
+ if (length) {
352
+ resHeaderRecord["content-length"] = length;
353
+ }
354
+ outgoing.writeHead(res.status, resHeaderRecord);
355
+ if (typeof source === "string" || source instanceof Uint8Array) {
356
+ outgoing.end(source);
357
+ } else if (source instanceof Blob) {
358
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
359
+ } else {
360
+ await writeFromReadableStream(stream, outgoing);
361
+ }
362
+ return;
358
363
  }
359
- } else if (res.body) {
364
+ }
365
+ if (res.body) {
360
366
  const {
361
367
  "transfer-encoding": transferEncoding,
362
368
  "content-encoding": contentEncoding,
package/dist/vercel.js CHANGED
@@ -378,18 +378,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
378
378
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
379
379
  const internalBody = getInternalBody(res);
380
380
  if (internalBody) {
381
- if (internalBody.length) {
382
- resHeaderRecord["content-length"] = internalBody.length;
383
- }
384
- outgoing.writeHead(res.status, resHeaderRecord);
385
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
386
- outgoing.end(internalBody.source);
387
- } else if (internalBody.source instanceof Blob) {
388
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
381
+ const { length, source, stream } = internalBody;
382
+ if (source instanceof Uint8Array && source.byteLength !== length) {
389
383
  } else {
390
- await writeFromReadableStream(internalBody.stream, outgoing);
384
+ if (length) {
385
+ resHeaderRecord["content-length"] = length;
386
+ }
387
+ outgoing.writeHead(res.status, resHeaderRecord);
388
+ if (typeof source === "string" || source instanceof Uint8Array) {
389
+ outgoing.end(source);
390
+ } else if (source instanceof Blob) {
391
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
392
+ } else {
393
+ await writeFromReadableStream(stream, outgoing);
394
+ }
395
+ return;
391
396
  }
392
- } else if (res.body) {
397
+ }
398
+ if (res.body) {
393
399
  const {
394
400
  "transfer-encoding": transferEncoding,
395
401
  "content-encoding": contentEncoding,
package/dist/vercel.mjs CHANGED
@@ -342,18 +342,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
342
342
  const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
343
343
  const internalBody = getInternalBody(res);
344
344
  if (internalBody) {
345
- if (internalBody.length) {
346
- resHeaderRecord["content-length"] = internalBody.length;
347
- }
348
- outgoing.writeHead(res.status, resHeaderRecord);
349
- if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) {
350
- outgoing.end(internalBody.source);
351
- } else if (internalBody.source instanceof Blob) {
352
- outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer()));
345
+ const { length, source, stream } = internalBody;
346
+ if (source instanceof Uint8Array && source.byteLength !== length) {
353
347
  } else {
354
- await writeFromReadableStream(internalBody.stream, outgoing);
348
+ if (length) {
349
+ resHeaderRecord["content-length"] = length;
350
+ }
351
+ outgoing.writeHead(res.status, resHeaderRecord);
352
+ if (typeof source === "string" || source instanceof Uint8Array) {
353
+ outgoing.end(source);
354
+ } else if (source instanceof Blob) {
355
+ outgoing.end(new Uint8Array(await source.arrayBuffer()));
356
+ } else {
357
+ await writeFromReadableStream(stream, outgoing);
358
+ }
359
+ return;
355
360
  }
356
- } else if (res.body) {
361
+ }
362
+ if (res.body) {
357
363
  const {
358
364
  "transfer-encoding": transferEncoding,
359
365
  "content-encoding": contentEncoding,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/node-server",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Node.js Adapter for Hono",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",