Skip to content

Commit

Permalink
订阅读取增加超时时间避免卡住
Browse files Browse the repository at this point in the history
  • Loading branch information
aiqinxuancai committed Jul 25, 2024
1 parent ee8143e commit 4d39f20
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Aria2Fast/Service/SubscriptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public SubscriptionInfoModel GetSubscriptionInfo(string url)
var handler = new HttpClientHandler() { Proxy = proxy };
var client = new HttpClient(handler);

// 注意这里的GET请求的地址需要替换为你需要请求的地址
client.Timeout = TimeSpan.FromSeconds(20);
var response = client.GetAsync(url).Result;


Expand All @@ -309,9 +309,16 @@ public SubscriptionInfoModel GetSubscriptionInfo(string url)
}
else
{
reader = XmlReader.Create(url);
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(20);
var response = client.GetAsync(url).Result;
reader = XmlReader.Create(response.Content.ReadAsStreamAsync().Result);
feed = SyndicationFeed.Load(reader);
reader.Close();

//reader = XmlReader.Create(url);
//feed = SyndicationFeed.Load(reader);
//reader.Close();
}
EasyLogManager.Logger.Info($"获取订阅标题:{feed.Title.Text}");

Expand Down

0 comments on commit 4d39f20

Please sign in to comment.