Happy Eyeballs for HttpClient use.

All HttpClient usages in the engine now use Happy Eyeballs, same implementation as the launcher.

Makes a IHttpClientHolder type so content can profit from this technology too. Didn't make use of this in all HttpClient usages in the engine itself, due to varying circumstances making it annoying to refactor.
This commit is contained in:
Pieter-Jan Briers
2023-07-31 22:51:25 +02:00
parent cb6645aebe
commit 1c7ae13bfa
10 changed files with 158 additions and 16 deletions
+7 -6
View File
@@ -6,6 +6,7 @@ using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -71,12 +72,12 @@ internal sealed class HubManager
_interval = TimeSpan.FromSeconds(interval);
_httpClient?.Dispose();
_httpClient = new HttpClient(new SocketsHttpHandler
{
// Keep-alive connections stay open for longer than the advertise interval.
// This way the same HTTPS connection can be re-used.
PooledConnectionIdleTimeout = _interval + TimeSpan.FromSeconds(10),
});
var socketsHandler = HappyEyeballsHttp.CreateHttpHandler();
// Keep-alive connections stay open for longer than the advertise interval.
// This way the same HTTPS connection can be re-used.
socketsHandler.PooledConnectionIdleTimeout = _interval + TimeSpan.FromSeconds(10);
_httpClient = new HttpClient(socketsHandler);
HttpClientUserAgent.AddUserAgent(_httpClient);
}