Skip to content

Commit a44a34e

Browse files
authored
Merge pull request #74 from ndw/iss-73
Fix #73 by reusing the HttpClient
2 parents 189e004 + 98b30fd commit a44a34e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

XmlResolver/ResourceAccess.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace XmlResolver;
1111
public static class ResourceAccess
1212
{
1313
public const int FollowRedirectLimit = 64;
14+
private static HttpClient _httpClient = new HttpClient();
1415

1516
public static ResourceResponse GetResource(ResourceRequest request)
1617
{
@@ -143,9 +144,9 @@ private static ResourceResponse _getHttpResource(ResourceRequest request, Uri re
143144
count--;
144145
done = count <= 0;
145146

146-
HttpClient httpClient = new HttpClient();
147-
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, resolvedUri);
148-
HttpResponseMessage resp = httpClient.Send(req);
147+
var httpClient = _httpClient;
148+
var req = new HttpRequestMessage(HttpMethod.Get, resolvedUri);
149+
var resp = httpClient.Send(req);
149150

150151
status = resp.StatusCode;
151152
if (seen.Contains(resolvedUri))

0 commit comments

Comments
 (0)