Skip to content

Commit 5c1acb7

Browse files
committed
Resolving conflict
1 parent 17e9e00 commit 5c1acb7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/Containers/Microsoft.NET.Build.Containers/Registry/DefaultRegistryAPI.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ internal class DefaultRegistryAPI : IRegistryAPI
1414
private readonly HttpClient _client;
1515
private readonly ILogger _logger;
1616

17+
// Empirical value - Unoptimized .NET application layers can be ~200MB
18+
// * .NET Runtime (~80MB)
19+
// * ASP.NET Runtime (~25MB)
20+
// * application and dependencies - variable, but _probably_ not more than the BCL?
21+
// Given a 200MB target and a 1Mb/s upload speed, we'd expect an upload speed of 27m:57s.
22+
// Making this a round 30 for convenience.
23+
private static TimeSpan LongRequestTimeout = TimeSpan.FromMinutes(30);
24+
1725
internal DefaultRegistryAPI(string registryName, Uri baseUri, ILogger logger, RegistryMode mode)
1826
{
1927
bool isAmazonECRRegistry = baseUri.IsAmazonECRRegistry();
@@ -30,7 +38,12 @@ internal DefaultRegistryAPI(string registryName, Uri baseUri, ILogger logger, Re
3038

3139
private static HttpClient CreateClient(string registryName, Uri baseUri, ILogger logger, bool isAmazonECRRegistry, RegistryMode mode)
3240
{
33-
var innerHandler = new SocketsHttpHandler();
41+
var innerHandler = new SocketsHttpHandler()
42+
{
43+
UseCookies = false,
44+
// the rest of the HTTP stack has an very long timeout (see below) but we should still have a reasonable timeout for the initial connection
45+
ConnectTimeout = TimeSpan.FromSeconds(30)
46+
};
3447

3548
// Ignore certificate for https localhost repository.
3649
if (baseUri.Host == "localhost" && baseUri.Scheme == "https")
@@ -49,7 +62,10 @@ private static HttpClient CreateClient(string registryName, Uri baseUri, ILogger
4962
clientHandler = new AmazonECRMessageHandler(clientHandler);
5063
}
5164

52-
HttpClient client = new(clientHandler);
65+
HttpClient client = new(clientHandler)
66+
{
67+
Timeout = LongRequestTimeout
68+
};
5369

5470
client.DefaultRequestHeaders.Add("User-Agent", $".NET Container Library v{Constants.Version}");
5571

0 commit comments

Comments
 (0)