Skip to content

Commit

Permalink
refactor(go-resty#432): Remove If-Else
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdiiilham committed Sep 7, 2021
1 parent f16905b commit a22f51a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
10 changes: 1 addition & 9 deletions request.go
Expand Up @@ -128,15 +128,7 @@ func (r *Request) SetHeaders(headers map[string]string) *Request {
// Also you can override header value, which was set at client instance level.
func (r *Request) SetMultiValueHeaders(headers map[string][]string) *Request {
for key, values := range headers {
var headerValue string

if len(values) > 1 {
headerValue = strings.Join(values, ", ")
} else {
headerValue = values[0]
}

r.SetHeader(key, headerValue)
r.SetHeader(key, strings.Join(values, ", "))
}
return r
}
Expand Down
1 change: 1 addition & 0 deletions request_test.go
Expand Up @@ -1381,6 +1381,7 @@ func TestSetHeaderMultipleValue(t *testing.T) {
"Authorization": []string{"Bearer xyz"},
})
assertEqual(t, "text/*, text/html, *", r.Header.Get("content"))
assertEqual(t, "Bearer xyz", r.Header.Get("authorization"))
}

func TestOutputFileWithBaseDirAndRelativePath(t *testing.T) {
Expand Down

0 comments on commit a22f51a

Please sign in to comment.