1
0
Files
DiAL/docs/user/checkers/http.md

1.8 KiB
Raw Blame History

HTTP Checker

type: http 用于 HTTP/HTTPS 应用层健康检查。

配置项

字段 说明 必填 默认值
http.url 目标 URL
http.method HTTP 方法 GET
http.headers 请求头
http.body 请求体
http.ignoreSSL 忽略 HTTPS 证书校验 false
http.maxRedirects 最大重定向跟随次数 0

expect 校验项

字段 说明 必填 默认值
status 可接受的状态码列表,支持精确码和范围(如 "2xx" [200]
headers 响应头校验,使用 KeyedExpectations
body 响应体校验,使用 ContentExpectations 数组
durationMs 完整执行耗时校验,使用 ValueMatcher

示例

- id: "json-api"
  name: "JSON API 示例"
  type: http
  http:
    url: "https://httpbin.org/json"
    headers:
      Authorization: "Bearer token"
  expect:
    status: [200]
    headers:
      Content-Type:
        contains: "application/json"
    body:
      - json:
          path: "$.slideshow.title"
          equals: "Sample Slide Show"
    durationMs:
      lte: 10000

HTTP checker 的 durationMs 覆盖完整执行,包括重定向、按需响应体读取、解码和 expect 校验。未配置 body expectation、status 失败或 headers 失败时不会读取 body。