diff --git a/common/http_agent/delete.go b/common/http_agent/delete.go index fe8948d6..bfa73544 100644 --- a/common/http_agent/delete.go +++ b/common/http_agent/delete.go @@ -18,19 +18,22 @@ package http_agent import ( "net/http" + "net/url" "strings" "time" ) func delete(client *http.Client, path string, header http.Header, timeoutMs uint64, params map[string]string) (response *http.Response, err error) { - if !strings.HasSuffix(path, "?") { - path = path + "?" - } - for key, value := range params { - path = path + key + "=" + value + "&" - } - if strings.HasSuffix(path, "&") { - path = path[:len(path)-1] + if len(params) > 0 { + if !strings.HasSuffix(path, "?") { + path = path + "?" + } + for key, value := range params { + path = path + key + "=" + url.QueryEscape(value) + "&" + } + if strings.HasSuffix(path, "&") { + path = path[:len(path)-1] + } } client.Timeout = time.Millisecond * time.Duration(timeoutMs) request, errNew := http.NewRequest(http.MethodDelete, path, nil) diff --git a/common/http_agent/get.go b/common/http_agent/get.go index 6de4d448..62185d4f 100644 --- a/common/http_agent/get.go +++ b/common/http_agent/get.go @@ -18,6 +18,7 @@ package http_agent import ( "net/http" + "net/url" "strings" "time" ) @@ -31,7 +32,7 @@ func get(client *http.Client, path string, header http.Header, timeoutMs uint64, if !strings.HasSuffix(path, "&") { path = path + "&" } - path = path + key + "=" + value + "&" + path = path + key + "=" + url.QueryEscape(value) + "&" } if strings.HasSuffix(path, "&") { path = path[:len(path)-1]