Skip to content

Commit 5ab8c4f

Browse files
committed
Update Proxy every time calling a http request method since the proxy setting won't update automatically without action
1 parent 96609f7 commit 5ab8c4f

File tree

1 file changed

+10
-1
lines changed
  • Flow.Launcher.Infrastructure/Http

1 file changed

+10
-1
lines changed

Flow.Launcher.Infrastructure/Http/Http.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ private get
4747
}
4848
}
4949

50-
public static WebProxy WebProxy { get; private set; } = new WebProxy();
50+
private static WebProxy _proxy = new WebProxy();
51+
public static WebProxy WebProxy {
52+
get
53+
{
54+
UpdateProxy();
55+
return _proxy;
56+
}
57+
}
5158

5259
/// <summary>
5360
/// Update the Address of the Proxy to modify the client Proxy
@@ -77,6 +84,7 @@ public static void UpdateProxy()
7784

7885
public static async Task Download([NotNull] string url, [NotNull] string filePath)
7986
{
87+
UpdateProxy();
8088
using var response = await client.GetAsync(url);
8189
if (response.StatusCode == HttpStatusCode.OK)
8290
{
@@ -91,6 +99,7 @@ public static async Task Download([NotNull] string url, [NotNull] string filePat
9199

92100
public static async Task<string> Get([NotNull] string url, string encoding = "UTF-8")
93101
{
102+
UpdateProxy();
94103
Log.Debug($"|Http.Get|Url <{url}>");
95104
var response = await client.GetAsync(url);
96105
await using var stream = await response.Content.ReadAsStreamAsync();

0 commit comments

Comments
 (0)