Skip to content

Commit e0ceb46

Browse files
Proxy config to ChromeForTestingClient added (#259)
1 parent 0db1785 commit e0ceb46

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

WebDriverManager/Clients/ChromeForTestingClient.cs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Net;
23
using System.Net.Http;
34
using System.Text.Json;
45
using System.Threading.Tasks;
@@ -14,27 +15,40 @@ public static class ChromeForTestingClient
1415
PropertyNameCaseInsensitive = true
1516
};
1617

17-
private static readonly HttpClient _httpClient;
18+
private static HttpClient _httpClient;
1819

19-
static ChromeForTestingClient()
20+
private static HttpClient HttpClient
2021
{
21-
_httpClient = new HttpClient
22+
get
2223
{
23-
BaseAddress = new Uri(BaseUrl)
24-
};
24+
var handler = new HttpClientHandler
25+
{
26+
UseProxy = Proxy != null,
27+
Proxy = Proxy
28+
};
29+
30+
_httpClient = new HttpClient(handler)
31+
{
32+
BaseAddress = new Uri(BaseUrl)
33+
};
34+
35+
return _httpClient;
36+
}
2537
}
2638

39+
public static IWebProxy Proxy { get; set; }
40+
2741
public static ChromeVersions GetKnownGoodVersionsWithDownloads()
2842
{
2943
return GetResultFromHttpTask<ChromeVersions>(
30-
_httpClient.GetAsync("known-good-versions-with-downloads.json")
44+
HttpClient.GetAsync("known-good-versions-with-downloads.json")
3145
);
3246
}
3347

3448
public static ChromeVersions GetLastKnownGoodVersions()
3549
{
3650
return GetResultFromHttpTask<ChromeVersions>(
37-
_httpClient.GetAsync("last-known-good-versions-with-downloads.json")
51+
HttpClient.GetAsync("last-known-good-versions-with-downloads.json")
3852
);
3953
}
4054

WebDriverManager/DriverManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Net;
4+
using WebDriverManager.Clients;
45
using WebDriverManager.DriverConfigs;
56
using WebDriverManager.Helpers;
67
using WebDriverManager.Services;
@@ -36,6 +37,7 @@ public DriverManager(IBinaryService binaryService, IVariableService variableServ
3637
public DriverManager WithProxy(IWebProxy proxy)
3738
{
3839
_binaryService = new BinaryService {Proxy = proxy};
40+
ChromeForTestingClient.Proxy = proxy;
3941
WebRequest.DefaultWebProxy = proxy;
4042
return this;
4143
}

0 commit comments

Comments
 (0)