浏览代码

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)