diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxHttpClient.cs index b71e1480d..3f33872f5 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 @@ -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; @@ -83,8 +82,10 @@ public class GxHttpClient : IGxHttpClient string _statusDescription = string.Empty; IGxContext _context; #if NETCORE - IWebProxy _proxyObject; + + IWebProxy _proxyObject; #else + WebProxy _proxyObject; #endif ArrayList _authCollection; @@ -127,7 +128,9 @@ public Stream ReceiveStream } } + #if NETCORE + [SecuritySafeCritical] private HttpClientHandler GetHandler() { return new HttpClientHandler(); @@ -619,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; @@ -657,8 +659,8 @@ HttpResponseMessage ExecuteRequest(string method, string requestUrl, CookieConta reqStream.Seek(0, SeekOrigin.Begin); request.Content = new ByteArrayContent(reqStream.ToArray()); setHeaders(request, handler.CookieContainer); - response = client.SendAsync(request).GetAwaiter().GetResult(); - } + response = client.SendAsync(request).GetAwaiter().GetResult(); + } } return response; } @@ -717,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); } @@ -984,9 +986,9 @@ HttpWebRequest buildRequest(string method, string requestUrl, CookieContainer co GXLogging.Debug(log, String.Format("Start HTTPClient buildRequest: requestUrl:{0} method:{1}", requestUrl, method)); int BytesRead; Byte[] Buffer = new Byte[1024]; -#pragma warning disable SYSLIB0014 // WebRequest +#pragma warning disable SYSLIB0014 // WebRequest HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requestUrl); -#pragma warning disable SYSLIB0014 // WebRequest +#pragma warning disable SYSLIB0014 // WebRequest if (GXUtil.CompressResponse()) {