resend the http request if connection is stale

This commit is contained in:
Chris Lu 2021-04-17 14:32:24 -07:00
parent 6cbd786db9
commit 2acf6be24e

View file

@ -11,7 +11,6 @@ import (
"net/http" "net/http"
"net/textproto" "net/textproto"
"path/filepath" "path/filepath"
"runtime/debug"
"strings" "strings"
"time" "time"
@ -235,10 +234,12 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
// print("+") // print("+")
resp, post_err := HttpClient.Do(req) resp, post_err := HttpClient.Do(req)
if post_err != nil { if post_err != nil {
if !strings.Contains(post_err.Error(), "connection reset by peer") { if strings.Contains(post_err.Error(), "connection reset by peer") ||
glog.Errorf("upload %s %d bytes to %v: %v", filename, originalDataSize, uploadUrl, post_err) strings.Contains(post_err.Error(), "use of closed network connection") {
debug.PrintStack() resp, post_err = HttpClient.Do(req)
} }
}
if post_err != nil {
return nil, fmt.Errorf("upload %s %d bytes to %v: %v", filename, originalDataSize, uploadUrl, post_err) return nil, fmt.Errorf("upload %s %d bytes to %v: %v", filename, originalDataSize, uploadUrl, post_err)
} }
// print("-") // print("-")