From f3f854b3fd56c5ec6488b6790ce16051a3235103 Mon Sep 17 00:00:00 2001 From: bpassaro95 <38334329+bpassaro95@users.noreply.github.com> Date: Wed, 2 Mar 2022 11:34:59 -0300 Subject: [PATCH 1/5] Turn on by default new HttpClient implementation for .Net and .Net Framework --- dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 7758acb7a..e6628173f 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -719,7 +719,7 @@ void ReadReponseContent(HttpResponseMessage response) } public void Execute(string method, string name) { - if (!Config.GetValueOf("useoldhttpclient", out string useOld) || useOld.StartsWith("y", StringComparison.OrdinalIgnoreCase)) + if (Config.GetValueOf("useoldhttpclient", out string useOld) && useOld.StartsWith("y", StringComparison.OrdinalIgnoreCase)) { WebExecute(method, name); } From 71e033aaeaed89ef120eb7da4179b2fc1e6b026b Mon Sep 17 00:00:00 2001 From: bpassaro95 <38334329+bpassaro95@users.noreply.github.com> Date: Thu, 21 Apr 2022 12:46:03 -0300 Subject: [PATCH 2/5] Improved condition that enables the usage of old HTTPClient implementation Improved condition that enables the usage of old HTTPClient implementation and removed max conn per route limitation due to causing issues on execution --- dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index e6628173f..63de73729 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -64,7 +64,6 @@ public class GxHttpClient : IGxHttpClient Stream _receiveStream; int _timeout = 30000; short _statusCode = 0; - static int _maxConnPerRoute = Preferences.GetHttpClientMaxConnectionPerRoute(); string _proxyHost; int _proxyPort; short _errCode = 0; @@ -130,25 +129,26 @@ public Stream ReceiveStream } } + #if NETCORE + [SecurityCritical] private HttpClientHandler GetHandler() { lock (syncRoot) { if (handlerInstance == null) handlerInstance = new HttpClientHandler(); - handlerInstance.MaxConnectionsPerServer = _maxConnPerRoute; } return handlerInstance; } #else + [SecurityCritical] private WinHttpHandler GetHandler() { lock (syncRoot) { if (handlerInstance == null) handlerInstance = new WinHttpHandler(); - handlerInstance.MaxConnectionsPerServer = _maxConnPerRoute; } return handlerInstance; } From 4749b873fcf5cdadfb6470aa584035eb25c7c64b Mon Sep 17 00:00:00 2001 From: bpassaro95 <38334329+bpassaro95@users.noreply.github.com> Date: Thu, 21 Apr 2022 14:22:05 -0300 Subject: [PATCH 3/5] Fixed HttpHandler error Fixed HttpHandler error where failed because of missing definitions, defined the handler instances --- .../GxClasses/Domain/GxHttpClient.cs | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 81c834599..0242decb7 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -1,26 +1,26 @@ namespace GeneXus.Http.Client { using System; - using System.Text; + using System.Collections; + using System.Collections.Generic; using System.Collections.Specialized; + using System.Globalization; using System.IO; - using log4net; - using GeneXus.Application; using System.Net; - using GeneXus.Configuration; - using GeneXus.Utils; - using System.Text.RegularExpressions; - using Mime; - using System.Collections; + using System.Net.Http; + using System.Net.Http.Headers; + using System.Security; using System.Security.Cryptography.X509Certificates; - using System.Collections.Generic; - using System.Globalization; + using System.Text; + using System.Text.RegularExpressions; using System.Threading.Tasks; - using System.Web.Services.Protocols; using System.Web; - using System.Net.Http.Headers; - using System.Net.Http; - using System.Security; + using System.Web.Services.Protocols; + using GeneXus.Application; + using GeneXus.Configuration; + using GeneXus.Utils; + using log4net; + using Mime; public interface IGxHttpClient @@ -82,8 +82,10 @@ public class GxHttpClient : IGxHttpClient string _statusDescription = string.Empty; IGxContext _context; #if NETCORE + IWebProxy _proxyObject; #else + WebProxy _proxyObject; #endif ArrayList _authCollection; @@ -128,25 +130,17 @@ public Stream ReceiveStream #if NETCORE - [SecurityCritical] + [SecuritySafeCritical] private HttpClientHandler GetHandler() { - lock (syncRoot) - { - if (handlerInstance == null) - handlerInstance = new HttpClientHandler(); - } + HttpClientHandler handlerInstance = new HttpClientHandler(); return handlerInstance; } #else - [SecurityCritical] + [SecuritySafeCritical] private WinHttpHandler GetHandler() { - lock (syncRoot) - { - if (handlerInstance == null) - handlerInstance = new WinHttpHandler(); - } + WinHttpClientHandler handlerInstance = new WinHttpHandler(); return handlerInstance; } #endif From f57edb838f09d7b01cded73468aa0f9a0d9fbd8b Mon Sep 17 00:00:00 2001 From: bpassaro95 <38334329+bpassaro95@users.noreply.github.com> Date: Thu, 21 Apr 2022 14:28:36 -0300 Subject: [PATCH 4/5] Update GxHttpClient.cs --- dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 0242decb7..dee1b4b8b 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -140,7 +140,7 @@ private HttpClientHandler GetHandler() [SecuritySafeCritical] private WinHttpHandler GetHandler() { - WinHttpClientHandler handlerInstance = new WinHttpHandler(); + WinHttpHandler handlerInstance = new WinHttpHandler(); return handlerInstance; } #endif From abe53efa52b0bdcbab37c2be2f0b95223ffc7812 Mon Sep 17 00:00:00 2001 From: bpassaro95 <38334329+bpassaro95@users.noreply.github.com> Date: Thu, 12 May 2022 09:44:01 -0300 Subject: [PATCH 5/5] Update GxHttpClient.cs --- dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index 1c4763ef5..3f33872f5 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs @@ -622,7 +622,6 @@ HttpResponseMessage ExecuteRequest(string method, string requestUrl, CookieConta handler.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => ServicePointManager.ServerCertificateValidationCallback(sender, certificate, chain, sslPolicyErrors)); } #endif - handler.MaxConnectionsPerServer = _maxConnPerRoute; if (GXUtil.CompressResponse()) { handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;