Skip to content

fix(whois): 修复 SSE 流式响应解析,解决所有域名查询失败#237

Open
Hamster-Prime wants to merge 1 commit into
TeleBoxOrg:mainfrom
Hamster-Prime:fix/whois-sse-parsing
Open

fix(whois): 修复 SSE 流式响应解析,解决所有域名查询失败#237
Hamster-Prime wants to merge 1 commit into
TeleBoxOrg:mainfrom
Hamster-Prime:fix/whois-sse-parsing

Conversation

@Hamster-Prime
Copy link
Copy Markdown

问题

namebeta.com API 返回的是 Server-Sent Events (SSE) 流式格式(每行以 data: 开头接 JSON),但原代码直接用 axios GET 将整个响应当作普通 JSON 对象处理。这导致 response.data 是原始字符串,访问 .whois?.whois 永远返回 undefined,所有域名查询都会走到"查询失败"分支。

修复内容

  • 新增 parseSSEResponse() — 逐行解析 data: 前缀的 SSE 事件,提取 JSON 对象
  • 新增 extractWhoisFromSSE() — 从解析后的事件列表中找到 type === "check" 的事件,返回 data.whois.whois
  • 所有 axios 请求添加 responseType: "text" 确保获取原始文本
  • 修正数据路径:WHOIS 数据实际在 check 事件的 data.whois.whois 中,而非 response.data.whois?.whois
  • 单查和批量查两个入口同步修复

测试

实测 voidtools.com 等域名查询均能正常返回完整 WHOIS 信息。


Note: 此修复由 AI (Ava / OpenClaw) 编写、测试并提交。

namebeta.com API 返回的是 Server-Sent Events 格式(每行以 data: 开头),
原代码直接用 axios GET 将响应当作普通 JSON 处理,导致 response.data 是原始
字符串而非 JSON 对象,访问 .whois?.whois 永远返回 undefined。

修复内容:
- 新增 parseSSEResponse() 解析 SSE 流式响应
- 新增 extractWhoisFromSSE() 从事件列表中提取 whois 数据
- 所有 axios 请求加 responseType: "text" 获取原始文本
- 修正数据路径:WHOIS 数据实际在 check 事件的 data.whois.whois 中
- 单查和批量查两个入口同步修复

此修复由 AI (Ava / OpenClaw) 编写、测试并提交。

Fixes #issue (if applicable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant