|
|
@ -145,13 +145,14 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|
|
|
// req = req.Clone(req.Context())
|
|
|
|
// req = req.Clone(req.Context())
|
|
|
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
|
|
|
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
|
|
|
resp, err := ldc.client.Do(req)
|
|
|
|
resp, err := ldc.client.Do(req)
|
|
|
|
|
|
|
|
req.Close = true
|
|
|
|
if err != nil || resp == nil {
|
|
|
|
if err != nil || resp == nil {
|
|
|
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
|
|
|
if strings.Contains(err.Error(), "connection reset by peer") {
|
|
|
|
resp.Body.Close()
|
|
|
|
resp.Body.Close()
|
|
|
|
for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
|
|
|
for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
|
|
|
time.Sleep(5 *time.Second)
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
resp, err = ldc.client.Do(req)
|
|
|
|
resp, err = ldc.client.Do(req)
|
|
|
|
if strings.Contains(err.Error(),"connection reset by peer") {
|
|
|
|
if strings.Contains(err.Error(), "connection reset by peer") {
|
|
|
|
resp.Body.Close()
|
|
|
|
resp.Body.Close()
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
} else if err == nil {
|
|
|
|
} else if err == nil {
|
|
|
@ -171,6 +172,7 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
|
|
|
respBytes, _ := io.ReadAll(resp.Body)
|
|
|
|
respBytes, _ := io.ReadAll(resp.Body)
|
|
|
|
err = fmt.Errorf("%s", respBytes)
|
|
|
|
err = fmt.Errorf("%s", respBytes)
|
|
|
|
resp.Body.Close()
|
|
|
|
resp.Body.Close()
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
|
|
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|