check error on write request/response

master
fangdingjun 7 years ago
parent 1c01f9270f
commit be06ade49b

@ -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)
}
}
}

Loading…
Cancel
Save