fix(whois): 修复 SSE 流式响应解析,解决所有域名查询失败#237
Open
Hamster-Prime wants to merge 1 commit into
Open
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
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.whoisresponseType: "text"确保获取原始文本check事件的data.whois.whois中,而非response.data.whois?.whois测试
实测
voidtools.com等域名查询均能正常返回完整 WHOIS 信息。