Skip to content

Commit

Permalink
[dotnet] Don't include http headers in internal logs (#14546)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
nvborisenko and codiumai-pr-agent-pro[bot] authored Sep 28, 2024
1 parent 7d1d0e0 commit 0cd8bbc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -417,7 +418,11 @@ protected override async Task<HttpResponseMessage> 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)
{
Expand All @@ -430,7 +435,7 @@ protected override async Task<HttpResponseMessage> 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)
{
Expand Down

0 comments on commit 0cd8bbc

Please sign in to comment.