Ensure we have reachable hosts
This commit is contained in:
@@ -203,6 +203,9 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
|
|||||||
// ensureReachableDownloadServer ensures that the request is sent to a reachable host
|
// ensureReachableDownloadServer ensures that the request is sent to a reachable host
|
||||||
// if not, it will replace the host with a reachable one
|
// if not, it will replace the host with a reachable one
|
||||||
func (r *HTTPClient) ensureReachableDownloadServer(req *http.Request) {
|
func (r *HTTPClient) ensureReachableDownloadServer(req *http.Request) {
|
||||||
|
if len(r.hosts) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
// skip if not a download server
|
// skip if not a download server
|
||||||
if !strings.Contains(req.Host, ".download.real-debrid.") {
|
if !strings.Contains(req.Host, ".download.real-debrid.") {
|
||||||
return
|
return
|
||||||
@@ -264,7 +267,7 @@ func (r *HTTPClient) shouldRetry(req *http.Request, resp *http.Response, err err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// retry on timeout errors for download requests
|
// retry on timeout errors for download requests
|
||||||
if err != nil && strings.Contains(err.Error(), "timeout") && strings.Contains(req.Host, ".download.real-debrid.") {
|
if err != nil && strings.Contains(err.Error(), "timeout") && strings.Contains(req.Host, ".download.real-debrid.") && len(r.hosts) > 1 {
|
||||||
oldHost := req.Host
|
oldHost := req.Host
|
||||||
// remove old host from the list of reachable hosts
|
// remove old host from the list of reachable hosts
|
||||||
for i, host := range r.hosts {
|
for i, host := range r.hosts {
|
||||||
|
|||||||
Reference in New Issue
Block a user