Skip to content

Commit 7ffbde3

Browse files
committed
Allow setting multiple values for a request header
1 parent 90fa193 commit 7ffbde3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/cmd/api/http.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func httpRequest(client *http.Client, method string, p string, params interface{
4343
return nil, err
4444
}
4545

46-
if bodyIsJSON {
47-
req.Header.Set("Content-Type", "application/json; charset=utf-8")
48-
}
4946
for _, h := range headers {
5047
idx := strings.IndexRune(h, ':')
5148
if idx == -1 {
5249
return nil, fmt.Errorf("header %q requires a value separated by ':'", h)
5350
}
54-
req.Header.Set(h[0:idx], strings.TrimSpace(h[idx+1:]))
51+
req.Header.Add(h[0:idx], strings.TrimSpace(h[idx+1:]))
52+
}
53+
if bodyIsJSON && req.Header.Get("Content-Type") == "" {
54+
req.Header.Set("Content-Type", "application/json; charset=utf-8")
5555
}
5656

5757
return client.Do(req)

0 commit comments

Comments
 (0)