Skip to content

Commit

Permalink
fix minor comments and adjust logic improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrstnAnsl committed Jun 23, 2024
1 parent 4d42101 commit 4240536
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,22 +414,19 @@ public DiagnosticsHttpHandler(HttpMessageHandler messageHandler)
/// <returns>The http response message content.</returns>
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Content != null)
{
var requestContent = await request.Content.ReadAsStringAsync().ConfigureAwait(false);
_logger.Trace($">> Body: {requestContent}");
}

var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);

if (!response.IsSuccessStatusCode)
if (!response.IsSuccessStatusCode && response.Content != null && request.Content != null)
{
var requestContent = await request.Content.ReadAsStringAsync().ConfigureAwait(false);
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
_logger.Trace($"<< Body: {responseContent}");

_logger.Trace($">> Request Body: {requestContent}\n\n<< Response Body: {responseContent}");
}

return response;
}

}
}
}

0 comments on commit 4240536

Please sign in to comment.