diff --git a/internal/server/adapter/http/handler/metric_operation_handler.go b/internal/server/adapter/http/handler/metric_operation_handler.go index dd08cf6..6d1f61b 100644 --- a/internal/server/adapter/http/handler/metric_operation_handler.go +++ b/internal/server/adapter/http/handler/metric_operation_handler.go @@ -175,6 +175,7 @@ func (h *metricOperationAdapter) PostGauge(w http.ResponseWriter, req *http.Requ opName := "PostGauge" _, _ = io.ReadAll(req.Body) + defer req.Body.Close() if !h.isContentTypeExpected(TextPlain, w, req) { return @@ -209,6 +210,7 @@ func (h *metricOperationAdapter) PostCounter(w http.ResponseWriter, req *http.Re opName := "PostCounter" _, _ = io.ReadAll(req.Body) + defer req.Body.Close() if !h.isContentTypeExpected(TextPlain, w, req) { return diff --git a/internal/server/adapter/http/middleware/compress/uncompress_gzip_request_mw_test.go b/internal/server/adapter/http/middleware/compress/uncompress_gzip_request_mw_test.go index d3d10ef..76f0c8d 100644 --- a/internal/server/adapter/http/middleware/compress/uncompress_gzip_request_mw_test.go +++ b/internal/server/adapter/http/middleware/compress/uncompress_gzip_request_mw_test.go @@ -36,6 +36,7 @@ func TestUncompressGZIPRequestMW(t *testing.T) { mockHandler.EXPECT().ServeHTTP(gomock.Any(), gomock.Any()).DoAndReturn( func(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) + defer r.Body.Close() if err != nil && err != io.EOF { http.Error(w, "read body err", http.StatusInternalServerError)