diff --git a/handler.go b/handler.go index ebbdc8a..e2e44d7 100644 --- a/handler.go +++ b/handler.go @@ -167,12 +167,17 @@ func httpForward(r, b net.Conn) { req.Header.Add("X-Real-Ip", addr.IP.String()) //log.Printf("%+v\n", req.Header) - req.Write(b) + err = req.Write(b) if req.Body != nil { req.Body.Close() } + if err != nil { + log.Printf("write request to backend error: %s", err) + return + } + res, err := http.ReadResponse(bb, req) if err != nil { if err != io.EOF { @@ -181,10 +186,14 @@ func httpForward(r, b net.Conn) { return } - res.Write(r) + err = res.Write(r) if res.Body != nil { res.Body.Close() } + + if err != nil { + log.Printf("write response to client error: %s", err) + } } }