From 42bf8ec06af87cdc785c9d5ef836795cb8cd6a35 Mon Sep 17 00:00:00 2001 From: Alessio Date: Sat, 11 May 2024 10:58:33 -0700 Subject: [PATCH] Fix a bug sending empty POST bodies --- pkg/scraper/api_request_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scraper/api_request_utils.go b/pkg/scraper/api_request_utils.go index eff25a7..2f716cb 100644 --- a/pkg/scraper/api_request_utils.go +++ b/pkg/scraper/api_request_utils.go @@ -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")