From 1ae43e4d41136d867d101720a575edf3e35be88c Mon Sep 17 00:00:00 2001 From: fatedier Date: Sun, 6 May 2018 22:47:26 +0800 Subject: [PATCH] plugin: update http_proxy --- models/plugin/http_proxy.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/models/plugin/http_proxy.go b/models/plugin/http_proxy.go index 41e6bdcd..8b6f8c98 100644 --- a/models/plugin/http_proxy.go +++ b/models/plugin/http_proxy.go @@ -66,14 +66,21 @@ func (hp *HttpProxy) Handle(conn io.ReadWriteCloser, realConn frpNet.Conn) { wrapConn := frpNet.WrapReadWriteCloserToConn(conn, realConn) sc, rd := frpNet.NewShareConn(wrapConn) - request, err := http.ReadRequest(bufio.NewReader(rd)) + firstBytes := make([]byte, 7) + _, err := rd.Read(firstBytes) if err != nil { wrapConn.Close() return } - if request.Method == http.MethodConnect { - hp.handleConnectReq(request, frpIo.WrapReadWriteCloser(rd, wrapConn, nil)) + if strings.ToUpper(string(firstBytes)) == "CONNECT" { + bufRd := bufio.NewReader(sc) + request, err := http.ReadRequest(bufRd) + if err != nil { + wrapConn.Close() + return + } + hp.handleConnectReq(request, frpIo.WrapReadWriteCloser(bufRd, wrapConn, wrapConn.Close)) return }