From 346d3222d7f66a4e0315cfba148c6b5b4fe24e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Mei=C3=9Fner?= <22190992+fnmeissner@users.noreply.github.com> Date: Fri, 14 Jun 2019 14:19:38 +0200 Subject: [PATCH] Prevent sending empty body in OTC DNS Provider (#903) --- providers/dns/otc/client.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/providers/dns/otc/client.go b/providers/dns/otc/client.go index 1cd71f55..fa4c5edc 100644 --- a/providers/dns/otc/client.go +++ b/providers/dns/otc/client.go @@ -230,12 +230,16 @@ func (d *DNSProvider) deleteRecordSet(zoneID, recordID string) error { func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) (io.Reader, error) { url := fmt.Sprintf("%s/%s", d.baseURL, resource) - body, err := json.Marshal(payload) - if err != nil { - return nil, err + var body io.Reader + if payload != nil { + content, err := json.Marshal(payload) + if err != nil { + return nil, err + } + body = bytes.NewReader(content) } - req, err := http.NewRequest(method, url, bytes.NewReader(body)) + req, err := http.NewRequest(method, url, body) if err != nil { return nil, err }