按概率生成可控的 HTTP 失败响应

GET/flaky
公开访问

rate 是失败概率,范围为 0 至 1。失败时可用 status 指定 429、500 或 503,省略时在三个状态码中等概率选择。rate=0 始终成功,rate=1 始终失败。失败响应 429 与 503 包含 Retry-After: 1。 访问类别:匿名 API,可携带 Token 使用独立额度

请求参数

ratequery
number · 默认值:0.5 · 最小值:0 · 最大值:1
statusquery
string · 可选:429、500、503

响应

application/json

{
  "type": "object",
  "properties": {
    "status": {
      "anyOf": [
        {
          "type": "number",
          "enum": [
            200
          ]
        },
        {
          "type": "number",
          "enum": [
            429
          ]
        },
        {
          "type": "number",
          "enum": [
            500
          ]
        },
        {
          "type": "number",
          "enum": [
            503
          ]
        }
      ]
    },
    "failed": {
      "type": "boolean"
    }
  },
  "required": [
    "status",
    "failed"
  ]
}

响应示例

成功响应

curl -sS 'https://oit.sh/flaky?rate=0'
HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "status": 200,
  "failed": false
}

错误示例

curl -sS 'https://oit.sh/flaky?rate=-1&status=429'
HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store

{
  "error": {
    "code": "INVALID_INPUT",
    "message": "参数无效",
    "issues": [
      {
        "location": "query",
        "field": "rate",
        "code": "invalid_format",
        "message": "格式要求:/^(?:0(?:\\.\\d+)?|1(?:\\.0+)?|\\.\\d+)$/"
      }
    ]
  }
}

在线调试

Ctrl / ⌘ + Enter
curl -X GET 'https://oit.sh/flaky'

响应

等待请求

等待发送请求