From ae0b3c8b39231a7ba72746c77bf594e50016bed8 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 5 Mar 2025 09:33:05 -0800 Subject: [PATCH] make sure resp body close on round trip even in error --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 5c808d1..05465f4 100644 --- a/main.go +++ b/main.go @@ -215,13 +215,13 @@ func pass(res http.ResponseWriter, req *http.Request, listenPort, proxyPort int) var transport http.Transport resp, err := transport.RoundTrip(req) + defer resp.Body.Close() if err != nil { log.Errorf("Error fetching: %v\n", err.Error()) http.Error(res, err.Error(), http.StatusServiceUnavailable) return } - defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil {