comfyui-mcp
Version:
Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),
41 lines • 1.64 kB
JavaScript
import { createReadStream } from "node:fs";
import { ModelError } from "../../utils/errors.js";
import { redactUrlForLogs } from "../download-auth.js";
export function isHttpUrl(url) {
return url.startsWith("http://") || url.startsWith("https://");
}
function redactedRedirectLocation(location, baseUrl) {
try {
return redactUrlForLogs(new URL(location, baseUrl).toString());
}
catch {
return "[INVALID_REDIRECT_LOCATION]";
}
}
export async function uploadHttpFile(source, destination) {
const init = {
method: "PUT",
redirect: "manual",
headers: source.contentType ? { "Content-Type": source.contentType } : undefined,
body: source.path ? createReadStream(source.path) : source.data,
};
if (source.path)
init.duplex = "half";
const response = await fetch(destination.url, init);
if (response.status >= 300 && response.status < 400) {
const location = response.headers.get("location");
throw new ModelError(`HTTP upload redirect rejected: ${response.status} ${response.statusText}`, {
url: redactUrlForLogs(destination.url),
status: response.status,
location: location ? redactedRedirectLocation(location, destination.url) : undefined,
});
}
if (!response.ok) {
throw new ModelError(`HTTP upload failed: ${response.status} ${response.statusText}`, {
url: redactUrlForLogs(destination.url),
status: response.status,
});
}
return { provider: "http", url: redactUrlForLogs(destination.url) };
}
//# sourceMappingURL=http.js.map