From a67c2428145e61a49305337b62738a215e6ecfd1 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Wed, 28 Jun 2017 16:49:33 +1000 Subject: [PATCH] http RAW can take optional data body. --- upload.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upload.go b/upload.go index 4b73026..f410d2f 100644 --- a/upload.go +++ b/upload.go @@ -70,7 +70,11 @@ func putRAW(data []byte, targetURL string, headers map[string]string) (resp stri } func httpRaw(httpMethod, targetURL string, data []byte, headers map[string]string) (resp string, err error) { - req, err := http.NewRequest(httpMethod, targetURL, bytes.NewBuffer(data)) + requestBody := io.Reader(nil) + if data != nil { + requestBody = bytes.NewBuffer(data) + } + req, err := http.NewRequest(httpMethod, targetURL, requestBody) if err != nil { return }