fix: speedTest between peers keep the connection alive (#13120)

for longer durations keep the speedTest alive instead
of timing them out based on ResponseHeaderTimeout.
This commit is contained in:
Harshavardhana
2021-08-31 14:08:23 -07:00
committed by GitHub
parent 556552340a
commit 0f7a51f461
2 changed files with 19 additions and 11 deletions

View File

@@ -1014,9 +1014,18 @@ func (client *peerRESTClient) Speedtest(ctx context.Context, size, concurrent in
return SpeedtestResult{}, err
}
defer http.DrainBody(respBody)
waitReader, err := waitForHTTPResponse(respBody)
if err != nil {
return SpeedtestResult{}, err
}
dec := gob.NewDecoder(respBody)
var result SpeedtestResult
err = dec.Decode(&result)
return result, err
err = gob.NewDecoder(waitReader).Decode(&result)
if err != nil {
return result, err
}
if result.Error != "" {
return result, errors.New(result.Error)
}
return result, nil
}