From 73c680d56f0acae20ebeb0e7f07755f006b8a0fa Mon Sep 17 00:00:00 2001 From: Cutsin Date: Tue, 18 Mar 2025 20:04:15 +0800 Subject: [PATCH] feat: avoid using body in GET requests for AirwallexClient payment provider (#3669) --- pp/airwallex.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pp/airwallex.go b/pp/airwallex.go index 45ea3f6c..2329377f 100644 --- a/pp/airwallex.go +++ b/pp/airwallex.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "io" "net/http" "net/url" "strings" @@ -180,7 +181,11 @@ func (c *AirwallexClient) authRequest(method, url string, body interface{}) (map return nil, err } b, _ := json.Marshal(body) - req, _ := http.NewRequest(method, url, bytes.NewBuffer(b)) + var reqBody io.Reader + if method != "GET" { + reqBody = bytes.NewBuffer(b) + } + req, _ := http.NewRequest(method, url, reqBody) req.Header.Set("Authorization", "Bearer "+token) req.Header.Set("Content-Type", "application/json") resp, err := c.client.Do(req)