Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 1a16211

Browse files
authored
Merge pull request #11 from DevKurka/yagpdb
Do not include Content-Type if body is null
2 parents ee8e284 + 03599ec commit 1a16211

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

restapi.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ func (s *Session) doRequestLockedBucket(method, urlStr, contentType string, b []
141141
req.Header.Set("authorization", s.Token)
142142
}
143143

144-
req.Header.Set("Content-Type", contentType)
144+
// Discord's API returns a 400 Bad Request is Content-Type is set, but the
145+
// request body is empty.
146+
if b != nil {
147+
req.Header.Set("Content-Type", contentType)
148+
}
149+
145150
// TODO: Make a configurable static variable.
146151
req.Header.Set("User-Agent", fmt.Sprintf("DiscordBot (https://github.com/jonas747/discordgo, v%s)", VERSION))
147152
req.Header.Set("X-RateLimit-Precision", "millisecond")

0 commit comments

Comments
 (0)