From 66bae3ee7329619b27ba8bcb185e0d333e9b3e26 Mon Sep 17 00:00:00 2001 From: grulex Date: Thu, 15 Feb 2024 16:11:58 +0000 Subject: [PATCH] Content-type fix (#659) * charset fixes * make linter happy (#661) --------- Co-authored-by: grulex Co-authored-by: Alexander Baranov <677093+sashabaranov@users.noreply.github.com> --- client.go | 4 ++-- speech.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 8bbbb875a..55c48bd47 100644 --- a/client.go +++ b/client.go @@ -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) diff --git a/speech.go b/speech.go index b9344ac66..be8950218 100644 --- a/speech.go +++ b/speech.go @@ -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