From 9cc0311164ccbac26e1b639a5ace7407a88ffbce Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 30 Jan 2024 20:44:53 -0600 Subject: [PATCH] Fix content length parsing, use header only --- helpers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helpers.go b/helpers.go index e2fb6fb..bf5e086 100644 --- a/helpers.go +++ b/helpers.go @@ -118,9 +118,10 @@ func DoRequest(req *http.Request) (*http.Response, error) { log.Err(err).Str("method", req.Method).Msg("Request Failed") } else { // Get the content length - contentLength := res.ContentLength - if contentLength == -1 { - contentLength, _ = strconv.ParseInt(res.Header.Get("Content-Length"), 10, 64) + contentLength, err := strconv.ParseInt(res.Header.Get("Content-Length"), 10, 64) + if err != nil { + log.Err(err).Msg("Failed to parse content length") + contentLength = -1 } log.Debug().Int("status", res.StatusCode).Int64("content-length", contentLength).Strs("content-type", res.Header["Content-Type"]).Msg("Response")