From fbbd4bace217bafe66eb56e0717298ce0a84f399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 27 Feb 2019 13:02:34 +0800 Subject: [PATCH] http post large file bug --- server/proxy/http.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/server/proxy/http.go b/server/proxy/http.go index 6b0cf8f7..76b52f0b 100644 --- a/server/proxy/http.go +++ b/server/proxy/http.go @@ -174,12 +174,23 @@ func (s *httpServer) process(c *conn.Conn, r *http.Request) { if err != nil { break } - host.Flow.Add(len(b), 0) - if _, err := tunnel.SendMsg(b, lk); err != nil { - c.Close() - break + l := len(b) + var start int + host.Flow.Add(l, 0) + for { + if l-start > 32*1024 { + _, err = tunnel.SendMsg(b[start:start+32*1024], lk) + start += 32 * 1024 + <-lk.StatusCh + } else { + _, err = tunnel.SendMsg(b[start:l], lk) + <-lk.StatusCh + break + } + if err != nil { + break + } } - <-lk.StatusCh } end: if isConn {