update
This commit is contained in:
@@ -39,7 +39,8 @@ func (c *HTTPClient) Get(url string, headers map[string]string) ([]byte, error)
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return nil, fmt.Errorf("GET请求失败,状态码: %d", resp.StatusCode)
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return nil, fmt.Errorf("GET请求失败,状态码: %d, 响应体: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
@@ -62,7 +63,6 @@ func (c *HTTPClient) PostJSON(url string, data interface{}, headers map[string]s
|
||||
|
||||
// Post 发送POST请求
|
||||
func (c *HTTPClient) Post(url string, data []byte, contentType string, headers map[string]string) ([]byte, error) {
|
||||
fmt.Println(string(data))
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("创建POST请求失败: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user