@slock-ai/daemon 0.51.0 → 0.51.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/{chunk-NAMH7BB6.js → chunk-JDSI7JD5.js} +11 -2
- package/dist/cli/index.js +14 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1355,6 +1355,7 @@ import http from "http";
|
|
|
1355
1355
|
import { URL as URL2 } from "url";
|
|
1356
1356
|
var registrations = /* @__PURE__ */ new Map();
|
|
1357
1357
|
var servers = /* @__PURE__ */ new Map();
|
|
1358
|
+
var DECODED_RESPONSE_HEADERS = /* @__PURE__ */ new Set(["content-encoding", "content-length", "transfer-encoding"]);
|
|
1358
1359
|
function allocatePort() {
|
|
1359
1360
|
return 43e3 + randomBytes(2).readUInt16BE(0) % 1e4;
|
|
1360
1361
|
}
|
|
@@ -1370,6 +1371,14 @@ function ensureServer(port) {
|
|
|
1370
1371
|
server.unref();
|
|
1371
1372
|
servers.set(port, server);
|
|
1372
1373
|
}
|
|
1374
|
+
function responseHeadersForLocalProxy(upstream) {
|
|
1375
|
+
const headers = {};
|
|
1376
|
+
for (const [name, value] of upstream.headers.entries()) {
|
|
1377
|
+
if (DECODED_RESPONSE_HEADERS.has(name.toLowerCase())) continue;
|
|
1378
|
+
headers[name] = value;
|
|
1379
|
+
}
|
|
1380
|
+
return headers;
|
|
1381
|
+
}
|
|
1373
1382
|
async function handleProxyRequest(req, res) {
|
|
1374
1383
|
const auth = req.headers.authorization;
|
|
1375
1384
|
const token = typeof auth === "string" && auth.startsWith("Bearer ") ? auth.slice("Bearer ".length) : "";
|
|
@@ -1423,11 +1432,11 @@ async function handleProxyRequest(req, res) {
|
|
|
1423
1432
|
if (shouldBufferJsonResponse(upstream, target.pathname, registration)) {
|
|
1424
1433
|
const responseText = await upstream.text();
|
|
1425
1434
|
consumeVisibleResponse(registration, target, sendTarget, responseText);
|
|
1426
|
-
res.writeHead(upstream.status,
|
|
1435
|
+
res.writeHead(upstream.status, responseHeadersForLocalProxy(upstream));
|
|
1427
1436
|
res.end(responseText);
|
|
1428
1437
|
return;
|
|
1429
1438
|
}
|
|
1430
|
-
res.writeHead(upstream.status,
|
|
1439
|
+
res.writeHead(upstream.status, responseHeadersForLocalProxy(upstream));
|
|
1431
1440
|
if (upstream.body) {
|
|
1432
1441
|
const reader = upstream.body.getReader();
|
|
1433
1442
|
try {
|
package/dist/cli/index.js
CHANGED
|
@@ -14326,7 +14326,20 @@ var ApiClient = class {
|
|
|
14326
14326
|
let errorCode = null;
|
|
14327
14327
|
const contentType = res.headers.get("content-type") ?? "";
|
|
14328
14328
|
if (contentType.includes("application/json")) {
|
|
14329
|
-
|
|
14329
|
+
let parseFailed = false;
|
|
14330
|
+
const parsed = await res.json().catch(() => {
|
|
14331
|
+
parseFailed = true;
|
|
14332
|
+
return null;
|
|
14333
|
+
});
|
|
14334
|
+
if (parseFailed) {
|
|
14335
|
+
return {
|
|
14336
|
+
ok: false,
|
|
14337
|
+
status: res.status,
|
|
14338
|
+
data: null,
|
|
14339
|
+
error: `Invalid JSON response from server/proxy (HTTP ${res.status})`,
|
|
14340
|
+
errorCode: "INVALID_JSON_RESPONSE"
|
|
14341
|
+
};
|
|
14342
|
+
}
|
|
14330
14343
|
if (res.ok) {
|
|
14331
14344
|
data = parsed;
|
|
14332
14345
|
} else {
|
package/dist/core.js
CHANGED
package/dist/index.js
CHANGED