Fix a bug sending empty POST bodies
This commit is contained in:
parent
f927507089
commit
42bf8ec06a
@ -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)
|
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")
|
req.Header.Set("content-type", "application/json")
|
||||||
} else {
|
} else {
|
||||||
req.Header.Set("content-type", "application/x-www-form-urlencoded")
|
req.Header.Set("content-type", "application/x-www-form-urlencoded")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user