UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

44 lines (43 loc) • 1.46 kB
import { R as resolveTimerTimeoutMs } from "./number-coercion-D6u-4YD8.mjs"; import { n as asNullableObjectRecord } from "./record-coerce-CVPuDqcc.mjs"; import { t as inspectTlsCertificateError } from "./tls-certificate-errors-ddRmxWST.mjs"; import { t as cancelUnreadResponseBody } from "./http-response-body-B-i_0116.mjs"; //#region src/infra/http-tls-preflight.ts /** Probe reachability without following redirects or consuming the response body. */ async function runHttpTlsPreflight(e, t = {}) { const n = resolveTimerTimeoutMs(t.timeoutMs, 5e3); const r = t.fetchImpl ?? fetch; t.signal?.throwIfAborted(); t.assertCurrent?.(); let i; try { i = await r(e, { method: "GET", redirect: "manual", signal: t.signal ? AbortSignal.any([t.signal, AbortSignal.timeout(n)]) : AbortSignal.timeout(n) }); return { ok: true }; } catch (e) { t.signal?.throwIfAborted(); t.assertCurrent?.(); const n = inspectTlsCertificateError(e); if (n) return { ok: false, kind: "tls-cert", code: n.code, message: n.message }; const r = asNullableObjectRecord(e); const i = asNullableObjectRecord(r?.cause); return { ok: false, kind: "network", code: typeof i?.code === "string" ? i.code : void 0, message: typeof i?.message === "string" ? i.message : typeof r?.message === "string" ? r.message : String(e) }; } finally { await cancelUnreadResponseBody(i); } } //#endregion export { runHttpTlsPreflight as t };