Преглед изворни кода

Merge pull request #717 from ewohltman/develop

Fix for Discord's API returning a 400 Bad Request from empty request body
Carson Hoffman пре 5 година
родитељ
комит
2d5c08be04
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      restapi.go

+ 6 - 1
restapi.go

@@ -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)