Skip to content

Commit 78bfe67

Browse files
authored
CMD-1245 - Improves proxy URI handling (#220)
* Improves proxy URI handling Refines the creation of WebProxy addresses by using `UriKind.RelativeOrAbsolute` for more robust URI parsing, which can better accommodate various proxy URI formats. Adds logging to provide visibility into the proxy URI received from environment variables and the final address assigned to the WebProxy, aiding in troubleshooting proxy configuration. Relates to CDMS-1245 * Organizes using directives Reorders `System` namespaces to the top of the file, improving code readability and adhering to common C# style guidelines. Relates to CDMS-1245 * updates
1 parent b08c25e commit 78bfe67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

BtmsGateway/Utils/Http/Proxy.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Polly.Extensions.Http;
66
using Polly.Retry;
77
using Polly.Timeout;
8-
using Environment = System.Environment;
8+
using Serilog;
99

1010
namespace BtmsGateway.Utils.Http;
1111

@@ -91,11 +91,13 @@ public static HttpClientHandler CreateHttpClientHandler(string? proxyUri)
9191

9292
public static WebProxy CreateProxy(string? proxyUri)
9393
{
94+
Log.Logger.Information("Proxy Uri from ENV: {ProxyUri}", proxyUri);
9495
var proxy = new WebProxy { BypassProxyOnLocal = false };
9596
if (proxyUri != null)
9697
{
97-
proxy.Address = new UriBuilder(proxyUri).Uri;
98+
proxy.Address = new Uri(proxyUri, UriKind.RelativeOrAbsolute);
9899
}
100+
Log.Logger.Information("WebProxy.Address: {ProxyUri}", proxy.Address);
99101
return proxy;
100102
}
101103
}

0 commit comments

Comments
 (0)