Fix for Discord's API returning a 400 Bad Request if Content-Type is set, but the request body is empty.

This commit is contained in:
Eric Wohltman 2019-12-19 12:46:45 -05:00 committed by Carson Hoffman
parent dd99dea7ad
commit 5452a224bf
No known key found for this signature in database
GPG key ID: 05B660CB452C657F

View file

@ -88,7 +88,12 @@ func (s *Session) RequestWithLockedBucket(method, urlStr, contentType string, b
req.Header.Set("authorization", s.Token)
}
req.Header.Set("Content-Type", contentType)
// Discord's API returns a 400 Bad Request is Content-Type is set, but the
// request body is empty.
if b != nil {
req.Header.Set("Content-Type", contentType)
}
// TODO: Make a configurable static variable.
req.Header.Set("User-Agent", s.UserAgent)