@modelcontextprotocol/server-pdf 1.2.0 → 1.2.2

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
@@ -33231,15 +33231,14 @@ var Response2 = class _Response {
33231
33231
  this.#init = init;
33232
33232
  }
33233
33233
  if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
33234
- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" };
33235
- this[cacheKey] = [init?.status || 200, body, headers];
33234
+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers];
33236
33235
  }
33237
33236
  }
33238
33237
  get headers() {
33239
33238
  const cache = this[cacheKey];
33240
33239
  if (cache) {
33241
33240
  if (!(cache[2] instanceof Headers)) {
33242
- cache[2] = new Headers(cache[2]);
33241
+ cache[2] = new Headers(cache[2] || { "content-type": "text/plain; charset=UTF-8" });
33243
33242
  }
33244
33243
  return cache[2];
33245
33244
  }
@@ -33333,17 +33332,9 @@ var buildOutgoingHttpHeaders = (headers) => {
33333
33332
  return res;
33334
33333
  };
33335
33334
  var X_ALREADY_SENT = "x-hono-already-sent";
33336
- var webFetch = global.fetch;
33337
33335
  if (typeof global.crypto === "undefined") {
33338
33336
  global.crypto = crypto2;
33339
33337
  }
33340
- global.fetch = (info, init) => {
33341
- init = {
33342
- compress: false,
33343
- ...init
33344
- };
33345
- return webFetch(info, init);
33346
- };
33347
33338
  var outgoingEnded = Symbol("outgoingEnded");
33348
33339
  var handleRequestError = () => new Response(null, {
33349
33340
  status: 400
@@ -33371,15 +33362,32 @@ var flushHeaders = (outgoing) => {
33371
33362
  };
33372
33363
  var responseViaCache = async (res, outgoing) => {
33373
33364
  let [status, body, header] = res[cacheKey];
33374
- if (header instanceof Headers) {
33365
+ let hasContentLength = false;
33366
+ if (!header) {
33367
+ header = { "content-type": "text/plain; charset=UTF-8" };
33368
+ } else if (header instanceof Headers) {
33369
+ hasContentLength = header.has("content-length");
33375
33370
  header = buildOutgoingHttpHeaders(header);
33371
+ } else if (Array.isArray(header)) {
33372
+ const headerObj = new Headers(header);
33373
+ hasContentLength = headerObj.has("content-length");
33374
+ header = buildOutgoingHttpHeaders(headerObj);
33375
+ } else {
33376
+ for (const key in header) {
33377
+ if (key.length === 14 && key.toLowerCase() === "content-length") {
33378
+ hasContentLength = true;
33379
+ break;
33380
+ }
33381
+ }
33376
33382
  }
33377
- if (typeof body === "string") {
33378
- header["Content-Length"] = Buffer.byteLength(body);
33379
- } else if (body instanceof Uint8Array) {
33380
- header["Content-Length"] = body.byteLength;
33381
- } else if (body instanceof Blob) {
33382
- header["Content-Length"] = body.size;
33383
+ if (!hasContentLength) {
33384
+ if (typeof body === "string") {
33385
+ header["Content-Length"] = Buffer.byteLength(body);
33386
+ } else if (body instanceof Uint8Array) {
33387
+ header["Content-Length"] = body.byteLength;
33388
+ } else if (body instanceof Blob) {
33389
+ header["Content-Length"] = body.size;
33390
+ }
33383
33391
  }
33384
33392
  outgoing.writeHead(status, header);
33385
33393
  if (typeof body === "string" || body instanceof Uint8Array) {