From 99e82f994314ef315f36d59849b7b85f5ba3c2f5 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Tue, 14 Aug 2018 18:04:56 +0800 Subject: [PATCH] fix close before write issue --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 5859e9b..0b43322 100644 --- a/client.go +++ b/client.go @@ -418,9 +418,9 @@ func (cc *Client) handleConnect(req *http.Request, c net.Conn) { c1, err := cc.client.Dial("tcp", req.RequestURI) if err != nil { - c.Close() fmt.Fprintf(c, "HTTP/1.0 503 connection failed\r\n\r\n") log.Errorf("dial error %s", err) + c.Close() return } @@ -439,9 +439,9 @@ func (cc *Client) handleHTTPReq(req *http.Request, c net.Conn) { log.Debugf("request to %s", host) c1, err := cc.client.Dial("tcp", host) if err != nil { - c.Close() fmt.Fprintf(c, "HTTP/1.1 503 connection failed\r\nConnection: close\r\n\r\n") log.Errorf("connection failed %s", err) + c.Close() return } //defer c1.Close()