Skip to content

Commit

Permalink
martian: manually handle closing req and res body
Browse files Browse the repository at this point in the history
  • Loading branch information
Choraden committed Nov 16, 2023
1 parent bc745c4 commit 9934b88
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/martian/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,15 @@ func (p *Proxy) handle(ctx *Context, conn net.Conn, brw *bufio.ReadWriter) error
log.Errorf(req.Context(), "got error while flushing response back to client: %v", err)
}

if err := req.Body.Close(); err != nil {
log.Errorf(req.Context(), "failed to close request body: %v", err)
closing = errClose
}
if err := res.Body.Close(); err != nil {
log.Errorf(req.Context(), "failed to close response body: %v", err)
closing = errClose
}

if p.CloseAfterReply {
closing = errClose
}
Expand Down

0 comments on commit 9934b88

Please sign in to comment.