Skip to content

Commit

Permalink
закрыл Body
Browse files Browse the repository at this point in the history
  • Loading branch information
StasMerzlyakov committed Mar 18, 2024
1 parent f64a107 commit 0232d86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0232d86

Please sign in to comment.