Skip to content

Commit b513acb

Browse files
committed
Modify the client to only set non-empty Content-Type headers.
Previously, we sent an empty Content-Type header if the request body is also empty. RFC 7231 does not dictate what to do in those cases and does not say anything about empty Content-Type headers. We'll therefore opt for simply not providing one if it isn't applicable. See also: https://tools.ietf.org/html/rfc7231#section-3.1.1.5
1 parent 46696cc commit b513acb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ func (c *Client) Request(v interface{}, method, path string, data interface{}) e
8585
return err
8686
}
8787

88-
request.Header.Set("Content-Type", string(contentType))
8988
request.Header.Set("Accept", "application/json")
9089
request.Header.Set("Authorization", "AccessKey "+c.AccessKey)
9190
request.Header.Set("User-Agent", "MessageBird/ApiClient/"+ClientVersion+" Go/"+runtime.Version())
91+
if contentType != contentTypeEmpty {
92+
request.Header.Set("Content-Type", string(contentType))
93+
}
9294

9395
if c.DebugLog != nil {
9496
if data != nil {

0 commit comments

Comments
 (0)