mirror of https://github.com/2dust/v2rayN
commit
f747416d3b
|
@ -16,9 +16,6 @@ namespace v2rayN.Base
|
|||
return null;
|
||||
}
|
||||
|
||||
var cancellationToken = new CancellationTokenSource();
|
||||
cancellationToken.CancelAfter(timeout * 1000);
|
||||
|
||||
Uri uri = new(url);
|
||||
//Authorization Header
|
||||
var headers = new WebHeaderCollection();
|
||||
|
@ -48,7 +45,9 @@ namespace v2rayN.Base
|
|||
throw value.Error;
|
||||
}
|
||||
};
|
||||
using var stream = await downloader.DownloadFileTaskAsync(address: url, cancellationToken: cancellationToken.Token);
|
||||
|
||||
using var cts = new CancellationTokenSource();
|
||||
using var stream = await downloader.DownloadFileTaskAsync(address: url, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
|
||||
using StreamReader reader = new(stream);
|
||||
|
||||
downloadOpt = null;
|
||||
|
@ -63,9 +62,6 @@ namespace v2rayN.Base
|
|||
throw new ArgumentNullException(nameof(url));
|
||||
}
|
||||
|
||||
var cancellationToken = new CancellationTokenSource();
|
||||
cancellationToken.CancelAfter(timeout * 1000);
|
||||
|
||||
var downloadOpt = new DownloadConfiguration()
|
||||
{
|
||||
Timeout = timeout * 1000,
|
||||
|
@ -115,8 +111,8 @@ namespace v2rayN.Base
|
|||
}
|
||||
};
|
||||
//progress.Report("......");
|
||||
|
||||
using var stream = await downloader.DownloadFileTaskAsync(address: url, cancellationToken: cancellationToken.Token);
|
||||
using var cts = new CancellationTokenSource();
|
||||
using var stream = await downloader.DownloadFileTaskAsync(address: url, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
|
||||
|
||||
downloadOpt = null;
|
||||
}
|
||||
|
@ -136,9 +132,6 @@ namespace v2rayN.Base
|
|||
File.Delete(fileName);
|
||||
}
|
||||
|
||||
var cancellationToken = new CancellationTokenSource();
|
||||
cancellationToken.CancelAfter(timeout * 1000);
|
||||
|
||||
var downloadOpt = new DownloadConfiguration()
|
||||
{
|
||||
Timeout = timeout * 1000,
|
||||
|
@ -178,7 +171,8 @@ namespace v2rayN.Base
|
|||
}
|
||||
};
|
||||
|
||||
await downloader.DownloadFileTaskAsync(url, fileName, cancellationToken: cancellationToken.Token);
|
||||
using var cts = new CancellationTokenSource();
|
||||
await downloader.DownloadFileTaskAsync(url, fileName, cts.Token).WaitAsync(TimeSpan.FromSeconds(timeout), cts.Token);
|
||||
|
||||
downloadOpt = null;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Resx;
|
||||
|
||||
|
@ -206,10 +207,8 @@ namespace v2rayN.Handler
|
|||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo));
|
||||
}
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.CancelAfter(1000 * 30);
|
||||
|
||||
var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token);
|
||||
using var cts = new CancellationTokenSource();
|
||||
var result = await HttpClientHelper.Instance.GetAsync(client, url, cts.Token).WaitAsync(TimeSpan.FromSeconds(30), cts.Token);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Reference in New Issue