Skip to content

Commit

Permalink
Content-type fix (#659)
Browse files Browse the repository at this point in the history
* charset fixes

* make linter happy (#661)

---------

Co-authored-by: grulex <[email protected]>
Co-authored-by: Alexander Baranov <[email protected]>
  • Loading branch information
3 people authored Feb 15, 2024
1 parent 11ad4b6 commit 66bae3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion speech.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66bae3e

Please sign in to comment.