From 1c01f9270f822d78228be7644a52737fcebd019e Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Wed, 23 May 2018 10:37:42 +0800 Subject: [PATCH] close request/response body --- handler.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/handler.go b/handler.go index e141aea..ebbdc8a 100644 --- a/handler.go +++ b/handler.go @@ -169,6 +169,10 @@ func httpForward(r, b net.Conn) { //log.Printf("%+v\n", req.Header) req.Write(b) + if req.Body != nil { + req.Body.Close() + } + res, err := http.ReadResponse(bb, req) if err != nil { if err != io.EOF { @@ -176,6 +180,11 @@ func httpForward(r, b net.Conn) { } return } + res.Write(r) + + if res.Body != nil { + res.Body.Close() + } } }