@inf-mcp/mcp-server 0.2.2 → 0.2.3

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
@@ -7336,7 +7336,7 @@ var InflectivApiError = class extends Error {
7336
7336
  this.name = "InflectivApiError";
7337
7337
  }
7338
7338
  };
7339
- function httpRequest(url, options) {
7339
+ function httpRequest(url, options, maxRedirects = 3) {
7340
7340
  return new Promise((resolve, reject) => {
7341
7341
  const parsed = new URL(url);
7342
7342
  const transport = parsed.protocol === "https:" ? https : http;
@@ -7350,8 +7350,17 @@ function httpRequest(url, options) {
7350
7350
  const chunks = [];
7351
7351
  res.on("data", (chunk) => chunks.push(chunk));
7352
7352
  res.on("end", () => {
7353
+ const statusCode = res.statusCode ?? 0;
7354
+ if (maxRedirects > 0 && [301, 302, 307, 308].includes(statusCode)) {
7355
+ const location = res.headers.location;
7356
+ if (location) {
7357
+ const redirectUrl = new URL(location, url).toString();
7358
+ resolve(httpRequest(redirectUrl, options, maxRedirects - 1));
7359
+ return;
7360
+ }
7361
+ }
7353
7362
  resolve({
7354
- status: res.statusCode ?? 0,
7363
+ status: statusCode,
7355
7364
  body: Buffer.concat(chunks).toString("utf-8")
7356
7365
  });
7357
7366
  });