From 7ffbde3e12beeb091fd49315f9cbffbbc63806f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 14 May 2020 15:34:18 +0200 Subject: [PATCH] Allow setting multiple values for a request header --- pkg/cmd/api/http.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/api/http.go b/pkg/cmd/api/http.go index 112f6ab1b..4f9064f18 100644 --- a/pkg/cmd/api/http.go +++ b/pkg/cmd/api/http.go @@ -43,15 +43,15 @@ func httpRequest(client *http.Client, method string, p string, params interface{ return nil, err } - if bodyIsJSON { - req.Header.Set("Content-Type", "application/json; charset=utf-8") - } for _, h := range headers { idx := strings.IndexRune(h, ':') if idx == -1 { return nil, fmt.Errorf("header %q requires a value separated by ':'", h) } - req.Header.Set(h[0:idx], strings.TrimSpace(h[idx+1:])) + req.Header.Add(h[0:idx], strings.TrimSpace(h[idx+1:])) + } + if bodyIsJSON && req.Header.Get("Content-Type") == "" { + req.Header.Set("Content-Type", "application/json; charset=utf-8") } return client.Do(req)