@@ -21,7 +21,7 @@ import (
2121 "github.com/go-json-experiment/json"
2222 "golang.org/x/net/proxy"
2323
24- "github.com/WJQSERVER-STUDIO/go-utils/copyb "
24+ "github.com/WJQSERVER-STUDIO/go-utils/iox "
2525)
2626
2727// 错误定义
@@ -795,7 +795,7 @@ func (c *Client) retryRoundTripper(next http.RoundTripper) http.RoundTripper {
795795
796796 // 在重试前,确保关闭当前失败的响应体以复用连接
797797 if resp != nil && resp .Body != nil {
798- copyb .Copy (io .Discard , resp .Body )
798+ iox .Copy (io .Discard , resp .Body )
799799 resp .Body .Close ()
800800 }
801801
@@ -1092,9 +1092,9 @@ func (c *Client) decodeTextResponse(resp *http.Response) (string, error) {
10921092 return "" , c .errorResponse (resp )
10931093 }
10941094
1095- bodyBytes , err := copyb .ReadAll (resp .Body )
1095+ bodyBytes , err := iox .ReadAll (resp .Body )
10961096 if err != nil {
1097- return "" , fmt .Errorf ("%w: %v " , ErrDecodeResponse , err )
1097+ return "" , fmt .Errorf ("%w: %s " , err , ErrDecodeResponse )
10981098 }
10991099 return string (bodyBytes ), nil
11001100}
@@ -1103,9 +1103,9 @@ func (c *Client) decodeBytesResponse(resp *http.Response) ([]byte, error) {
11031103 if resp .StatusCode >= 400 {
11041104 return nil , c .errorResponse (resp )
11051105 }
1106- bodyBytes , err := copyb .ReadAll (resp .Body )
1106+ bodyBytes , err := iox .ReadAll (resp .Body )
11071107 if err != nil {
1108- return nil , fmt .Errorf ("%w: %v " , ErrDecodeResponse , err )
1108+ return nil , fmt .Errorf ("%w: %s " , err , ErrDecodeResponse )
11091109 }
11101110 return bodyBytes , nil
11111111}
@@ -1146,14 +1146,14 @@ func (c *Client) errorResponse(resp *http.Response) error {
11461146
11471147 limitedReader := io .LimitReader (resp .Body , maxErrorBodyRead )
11481148 readErr := func () error { // 使用匿名函数捕获读取错误
1149- _ , err := copyb .Copy (buf , limitedReader )
1149+ _ , err := iox .Copy (buf , limitedReader )
11501150 return err
11511151 }() // 立即执行
11521152
11531153 // *** 关键: 丢弃剩余的响应体 ***
11541154 const maxDiscardSize = 64 * 1024
11551155 discardErr := func () error { // 使用匿名函数捕获丢弃错误
1156- _ , err := copyb .CopyN (io .Discard , resp .Body , maxDiscardSize )
1156+ _ , err := iox .CopyN (io .Discard , resp .Body , maxDiscardSize )
11571157 // 如果错误是 EOF,说明我们已经读完了或者超出了 maxDiscardSize,这不是一个需要报告的错误
11581158 if errors .Is (err , io .EOF ) {
11591159 return nil
0 commit comments