Skip to content

Commit 6167032

Browse files
Refactored gxhttpclient implementation to utilize a singleton instance for reusing the connection pool of httpclient instances. Avoided using CookieContainer of handlers, as they are shared across the pooled connections. Instead, managed sending and receiving cookies as headers.
1 parent 96e2a97 commit 6167032

File tree

4 files changed

+309
-81
lines changed

4 files changed

+309
-81
lines changed

dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ public class Preferences
848848
const string DEFAULT_DS = "Default";
849849
static int httpclient_max_per_route = -1;
850850
static int sessionTimeout = -1;
851+
static int singletonHttpClient = -1;
851852
internal static string AppMainNamespace
852853
{
853854
get
@@ -1443,7 +1444,18 @@ internal static bool WrapSingleApiOutput
14431444
return DefaultWrapSingleApiOutput;
14441445
}
14451446
}
1446-
internal static string CorsAllowedOrigins()
1447+
1448+
public static bool SingletonHttpClient()
1449+
{
1450+
if (singletonHttpClient == -1)
1451+
{
1452+
if (Config.GetValueOf("SingletonHttpClient", out string sValue) && int.TryParse(sValue, out int value))
1453+
singletonHttpClient = value;
1454+
}
1455+
return singletonHttpClient==1;
1456+
}
1457+
1458+
internal static string CorsAllowedOrigins()
14471459
{
14481460
if (Config.GetValueOf("CORS_ALLOW_ORIGIN", out string corsOrigin))
14491461
return corsOrigin;

0 commit comments

Comments
 (0)