I have a HTTP API and its client written in Go. The client side code is: func upload(link, dir, name string, r io.Reader) { var buf bytes.Buffer mw := multipart.NewWriter(&buf) mw.WriteField("dir", dir) mw.WriteField("name", name) ff, _ := mw.CreateFormFile("file", name) io.Copy(ff, r) mw.Close() hc := http.Client{Timeout: time.Minute} req, _ := http.NewRequest("POST", link, &buf) req.Header.Set("X-Key", "api-key") req.Header.Set("Content-Type", mw.FormDataContentType()) start := time.Now() resp, _ := hc.Do(req) diff := time.Since(start) defer resp.Body.Close() if resp.StatusCode == http.StatusOK { fmt.Printf("Upload OK, elapsed=%v\n", diff) } else { data, _ := ioutil.ReadAll(resp.Body) fmt.Printf("Upload failed, elapsed=%v, http_code=%d, data=%s", diff, resp.StatusCode, data) } }
if compiled using Go 1.10.1, the client program uploads a test file about 4K in 250 milliseconds, while compiled using Go1.11, it costs 10 seconds to upload! and the server is in local network. Originally the client code uses io.Pipe to avoid memory consumption, in order to eliminate any improper use of pipe, I re-write it into the above version, no difference observed. Also, after we spotted the problem, the server side code is also re-compiled using Go1.10, but still no difference. It seems only related to the client side. Another important symptom is that the same compiled code, if running on another server (in the same LAN), the problem disappeared, yet another server will cost about 2 seconds. That is to say, the problem has something to do with conditions of the server, probably some network issues we don't know yet. But the problem only occur with Go 1.11. Is there anything changed in the http client library of 1.11 which may cause this problem? Thank you! Xiangrong -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.