Content-type fix (#659)
* charset fixes * make linter happy (#661) --------- Co-authored-by: grulex <god@vk.com> Co-authored-by: Alexander Baranov <677093+sashabaranov@users.noreply.github.com>
This commit is contained in:
@@ -107,13 +107,13 @@ func (c *Client) newRequest(ctx context.Context, method, url string, setters ...
|
||||
}
|
||||
|
||||
func (c *Client) sendRequest(req *http.Request, v Response) error {
|
||||
req.Header.Set("Accept", "application/json; charset=utf-8")
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// Check whether Content-Type is already set, Upload Files API requires
|
||||
// Content-Type == multipart/form-data
|
||||
contentType := req.Header.Get("Content-Type")
|
||||
if contentType == "" {
|
||||
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
res, err := c.config.HTTPClient.Do(req)
|
||||
|
||||
@@ -76,7 +76,7 @@ func (c *Client) CreateSpeech(ctx context.Context, request CreateSpeechRequest)
|
||||
}
|
||||
req, err := c.newRequest(ctx, http.MethodPost, c.fullURL("/audio/speech", string(request.Model)),
|
||||
withBody(request),
|
||||
withContentType("application/json; charset=utf-8"),
|
||||
withContentType("application/json"),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user