Skip to content

Commit

Permalink
Avoid computing the AbsoluteUri if logging is disabled (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Feb 8, 2021
1 parent d10c0ff commit bb7ab95
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ReverseProxy/Service/Proxy/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public async Task ProxyAsync(
var request = context.Request;
destinationRequest.RequestUri ??= RequestUtilities.MakeDestinationAddress(destinationPrefix, request.Path, request.QueryString);

Log.Proxying(_logger, destinationRequest.RequestUri.AbsoluteUri);
Log.Proxying(_logger, destinationRequest.RequestUri);

// TODO: What if they replace the HttpContent object? That would mess with our tracking and error handling.
return (destinationRequest, requestContent);
Expand Down Expand Up @@ -652,9 +652,13 @@ public static void HttpDowngradeDetected(ILogger logger)
_httpDowngradeDetected(logger, null);
}

public static void Proxying(ILogger logger, string targetUrl)
public static void Proxying(ILogger logger, Uri targetUrl)
{
_proxying(logger, targetUrl, null);
// Avoid computing the AbsoluteUri unless logging is enabled
if (logger.IsEnabled(LogLevel.Information))
{
_proxying(logger, targetUrl.AbsoluteUri, null);
}
}

public static void ErrorProxying(ILogger logger, ProxyError error, Exception ex)
Expand Down

0 comments on commit bb7ab95

Please sign in to comment.