From 6339e3cdf20be535da138915d9e40a6ea647e8cc Mon Sep 17 00:00:00 2001 From: 兔子 Date: Sat, 7 Sep 2019 11:47:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhttp=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=95=B0=E6=8D=AE=E4=B8=A2=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/net.go b/net.go index 843c83f..ef8cb53 100644 --- a/net.go +++ b/net.go @@ -85,10 +85,14 @@ func (this *StarCurl) CurlWithFile(url string, postdata map[string]string, formn fpdst.Write([]byte(header)) go func() { for { - bufs := make([]byte, 1048576) + bufs := make([]byte, 393213) n, err = fpsrc.Read(bufs) if err != nil { if err == io.EOF { + if n != 0 { + fpdst.Write(bufs[0:n]) + go shell(float64(sum+n) / filebig * 100) + } break } return @@ -99,7 +103,6 @@ func (this *StarCurl) CurlWithFile(url string, postdata map[string]string, formn } fpdst.Write(endbytes) fpdst.Write(nil) - }() this.CircleBuffer = fpdst this.ReqHeader.Set("Content-Type", "multipart/form-data;boundary="+boundary) @@ -134,10 +137,14 @@ func (this *StarCurl) CurlWithFileByMemory(url string, postdata map[string]strin filebig := float64(fpstat.Size()) sum, n := 0, 0 for { - bufs := make([]byte, 1048576) + bufs := make([]byte, 393213) n, err = fpsrc.Read(bufs) if err != nil { if err == io.EOF { + if n != 0 { + fpdst.Write(bufs[0:n]) + go shell(float64(sum+n) / filebig * 100) + } break } return @@ -231,11 +238,14 @@ func (this *StarCurl) CurlDataToFile(url string, postdata []byte, method, fpath } var n, sum int = 0, 0 for { - buf := make([]byte, 1048576) + buf := make([]byte, 393213) n, err = resp.Body.Read(buf) if err != nil { if err == io.EOF { err = nil + if n != 0 { + fpsrc.Write(buf[0:n]) + } go shell(100.00) break }