From 0cd8bbc268c3735bdbe67f9f738c845514be55ff Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Sat, 28 Sep 2024 23:54:07 +0300 Subject: [PATCH] [dotnet] Don't include http headers in internal logs (#14546) * [dotnet] Don't include http headers in internal logs * Update dotnet/src/webdriver/Remote/HttpCommandExecutor.cs Co-authored-by: codiumai-pr-agent-pro[bot] <151058649+codiumai-pr-agent-pro[bot]@users.noreply.github.com> * Update dotnet/src/webdriver/Remote/HttpCommandExecutor.cs Co-authored-by: codiumai-pr-agent-pro[bot] <151058649+codiumai-pr-agent-pro[bot]@users.noreply.github.com> --------- Co-authored-by: codiumai-pr-agent-pro[bot] <151058649+codiumai-pr-agent-pro[bot]@users.noreply.github.com> --- dotnet/src/webdriver/Remote/HttpCommandExecutor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs index f529b2aa0dbf1..251c6bca78fe1 100644 --- a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs +++ b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -417,7 +418,11 @@ protected override async Task SendAsync(HttpRequestMessage var responseTask = base.SendAsync(request, cancellationToken); StringBuilder requestLogMessageBuilder = new(); - requestLogMessageBuilder.AppendFormat(">> {0}", request); + requestLogMessageBuilder.AppendFormat(">> {0} RequestUri: {1}, Content: {2}, Headers: {3}", + request.Method, + request.RequestUri?.ToString() ?? "null", + request.Content?.ToString() ?? "null", + request.Headers?.Count()); if (request.Content != null) { @@ -430,7 +435,7 @@ protected override async Task SendAsync(HttpRequestMessage var response = await responseTask.ConfigureAwait(false); StringBuilder responseLogMessageBuilder = new(); - responseLogMessageBuilder.AppendFormat("<< {0}", response); + responseLogMessageBuilder.AppendFormat("<< StatusCode: {0}, ReasonPhrase: {1}, Content: {2}, Headers: {3}", (int)response.StatusCode, response.ReasonPhrase, response.Content, response.Headers?.Count()); if (!response.IsSuccessStatusCode && response.Content != null) {