feat: 调试开关打开时记录全部接口响应

This commit is contained in:
Nixevol
2026-10-16 15:41:30 +08:00
parent d5dcd7086d
commit 5d18da470d
4 changed files with 83 additions and 19 deletions
+3
View File
@@ -168,13 +168,16 @@ func fetchPublic(ctx context.Context, rawURL string) ([]byte, error) {
req.Header.Set("Accept", "*/*")
resp, err := publicHTTP.Do(req)
if err != nil {
debugHTTP(req, nil, nil, err)
return nil, err
}
defer resp.Body.Close()
buf, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
debugHTTP(req, resp, nil, err)
return nil, err
}
debugHTTP(req, resp, buf, nil)
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("网站返回 %d", resp.StatusCode)
}