Fix a bug sending empty POST bodies

This commit is contained in:
Alessio 2024-05-11 10:58:33 -07:00
parent f927507089
commit 42bf8ec06a

View File

@ -164,7 +164,7 @@ func (api *API) do_http_POST(remote_url string, body string, result interface{})
return fmt.Errorf("Error initializing HTTP POST request:\n %w", err)
}
if body[0] == '{' {
if len(body) == 0 || body[0] == '{' { // TODO: unclear what the content-type should be if body is empty; might not matter
req.Header.Set("content-type", "application/json")
} else {
req.Header.Set("content-type", "application/x-www-form-urlencoded")