1
0

feat: HTTP 探针增强 — ignoreSSL、精确重定向控制、状态码范围匹配、编码自动检测

This commit is contained in:
2026-05-13 00:02:04 +08:00
parent 87d946a441
commit 2fd0f206be
16 changed files with 642 additions and 22 deletions

View File

@@ -27,7 +27,9 @@ const httpTarget: ResolvedTarget = {
group: "default",
http: {
headers: { Accept: "application/json" },
ignoreSSL: false,
maxBodyBytes: 104857600,
maxRedirects: 0,
method: "GET",
url: "https://example.com/health",
},
@@ -85,14 +87,18 @@ describe("ProbeStore", () => {
expect(t.target).toBe("https://example.com/health");
const config = JSON.parse(t.config) as {
headers: Record<string, string>;
ignoreSSL: boolean;
maxBodyBytes: number;
maxRedirects: number;
method: string;
url: string;
};
expect(config.url).toBe("https://example.com/health");
expect(config.method).toBe("GET");
expect(config.headers).toEqual({ Accept: "application/json" });
expect(config.ignoreSSL).toBe(false);
expect(config.maxBodyBytes).toBe(104857600);
expect(config.maxRedirects).toBe(0);
expect(t.interval_ms).toBe(30000);
expect(t.timeout_ms).toBe(10000);
expect(JSON.parse(t.expect!)).toEqual({ maxDurationMs: 3000, status: [200] });
@@ -283,7 +289,14 @@ describe("ProbeStore", () => {
const cascadeStore = new ProbeStore(join(tempDir, "cascade.db"));
const cascadeTarget: ResolvedTarget = {
group: "default",
http: { headers: {}, maxBodyBytes: 104857600, method: "GET", url: "http://cascade.test" },
http: {
headers: {},
ignoreSSL: false,
maxBodyBytes: 104857600,
maxRedirects: 0,
method: "GET",
url: "http://cascade.test",
},
intervalMs: 30000,
name: "cascade-test",
timeoutMs: 10000,
@@ -338,7 +351,14 @@ describe("ProbeStore", () => {
freshStore.syncTargets([
{
group: "default",
http: { headers: {}, maxBodyBytes: 104857600, method: "GET", url: "http://no.records" },
http: {
headers: {},
ignoreSSL: false,
maxBodyBytes: 104857600,
maxRedirects: 0,
method: "GET",
url: "http://no.records",
},
intervalMs: 30000,
name: "no-records",
timeoutMs: 10000,
@@ -377,7 +397,14 @@ describe("ProbeStore", () => {
freshStore.syncTargets([
{
group: "default",
http: { headers: {}, maxBodyBytes: 104857600, method: "GET", url: "http://no.stats" },
http: {
headers: {},
ignoreSSL: false,
maxBodyBytes: 104857600,
maxRedirects: 0,
method: "GET",
url: "http://no.stats",
},
intervalMs: 30000,
name: "no-stats",
timeoutMs: 10000,