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