Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rmandvikar committed Nov 6, 2023
1 parent 0aefb7e commit 2fd5017
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace rm.DelegatingHandlers;
/// Logs <see cref="HttpRequestMessage"/>, and <see cref="HttpResponseMessage"/> with
/// exception, if any, along with its elapsed time.
/// </summary>
public class LoggingRequestResponseHandler : DelegatingHandler
public class LoggingPostHandler : DelegatingHandler
{
private readonly ILogger logger;
private readonly ILoggingFormatter loggingFormatter;

/// <inheritdoc cref="LoggingRequestResponseHandler" />
public LoggingRequestResponseHandler(
/// <inheritdoc cref="LoggingPostHandler" />
public LoggingPostHandler(
ILogger logger,
ILoggingFormatter loggingFormatter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace rm.DelegatingHandlers;
/// <summary>
/// Logs <see cref="HttpRequestMessage"/>.
/// </summary>
public class LoggingRequestHandler : DelegatingHandler
public class LoggingPreHandler : DelegatingHandler
{
private readonly ILogger logger;
private readonly ILoggingFormatter loggingFormatter;

/// <inheritdoc cref="LoggingRequestHandler" />
public LoggingRequestHandler(
/// <inheritdoc cref="LoggingPreHandler" />
public LoggingPreHandler(
ILogger logger,
ILoggingFormatter loggingFormatter)
{
Expand Down
6 changes: 3 additions & 3 deletions tests/rm.DelegatingHandlersTest/Http2HandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public async Task Sends_Http2()
new HttpRequestMessage(method, uri);

var http2Handler = new Http2Handler();
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new LoggingFormatter());
var loggingRequestHandler = new LoggingRequestHandler(logger, new LoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new LoggingFormatter());
var loggingPreHandler = new LoggingPreHandler(logger, new LoggingFormatter());

using var httpclient = HttpClientFactory.Create(
#if NETFRAMEWORK
new WinHttpHandler(),
#endif
loggingRequestResponseHandler, http2Handler, loggingRequestHandler);
loggingPostHandler, http2Handler, loggingPreHandler);

using var _ = await httpclient.SendAsync(request, CancellationToken.None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace rm.DelegatingHandlersTest;

[TestFixture]
public class LoggingRequestResponseHandlerTests
public class LoggingPostHandlerTests
{
private static readonly Random rng = RandomFactory.GetThreadStaticRandom();

Expand Down Expand Up @@ -86,10 +86,10 @@ public async Task Logs_Request_Response()
#pragma warning restore CS0618 // Type or member is obsolete
return Task.FromResult(response);
});
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new LoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new LoggingFormatter());

using var invoker = HttpMessageInvokerFactory.Create(
loggingRequestResponseHandler, delegateHandler, shortCircuitingCannedResponseHandler);
loggingPostHandler, delegateHandler, shortCircuitingCannedResponseHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down Expand Up @@ -174,11 +174,11 @@ public async Task Logs_Request_Exception()
response.Headers.Add(header2, headerValue2);

var swallowingHandler = new SwallowingHandler(ex => ex is TurnDownForWhatException);
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new LoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new LoggingFormatter());
var throwingHandler = new ThrowingHandler(new TurnDownForWhatException());

using var invoker = HttpMessageInvokerFactory.Create(
swallowingHandler, loggingRequestResponseHandler, throwingHandler);
swallowingHandler, loggingPostHandler, throwingHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down Expand Up @@ -255,10 +255,10 @@ public async Task Logs_Request_Response_Compact()
#endif

var shortCircuitingCannedResponseHandler = new ShortCircuitingCannedResponseHandler(response);
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new CompactLoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new CompactLoggingFormatter());

using var invoker = HttpMessageInvokerFactory.Create(
loggingRequestResponseHandler, shortCircuitingCannedResponseHandler);
loggingPostHandler, shortCircuitingCannedResponseHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down Expand Up @@ -343,10 +343,10 @@ public async Task Logs_Request_Exception_Compact()

var swallowingHandler = new SwallowingHandler(ex => ex is TurnDownForWhatException);
var throwingHandler = new ThrowingHandler(new TurnDownForWhatException());
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new CompactLoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new CompactLoggingFormatter());

using var invoker = HttpMessageInvokerFactory.Create(
swallowingHandler, loggingRequestResponseHandler, throwingHandler);
swallowingHandler, loggingPostHandler, throwingHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down Expand Up @@ -428,10 +428,10 @@ public async Task Logs_Request_Response_Sampling()
using var request = new HttpRequestMessage(HttpMethod.Get, $"/{id}");

var shortCircuitingCannedResponseHandler = new ShortCircuitingCannedResponseHandler(new HttpResponseMessage());
var loggingRequestResponseHandler = new LoggingRequestResponseHandler(logger, new CompactLoggingFormatter());
var loggingPostHandler = new LoggingPostHandler(logger, new CompactLoggingFormatter());

using var invoker = HttpMessageInvokerFactory.Create(
loggingRequestResponseHandler, shortCircuitingCannedResponseHandler);
loggingPostHandler, shortCircuitingCannedResponseHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace rm.DelegatingHandlersTest;

[TestFixture]
public class LoggingRequestHandlerTests
public class LoggingPreHandlerTests
{
public class Formatter
{
Expand Down Expand Up @@ -52,10 +52,10 @@ public async Task Logs_Request()
#pragma warning restore CS0618 // Type or member is obsolete

var shortCircuitingCannedResponseHandler = new ShortCircuitingCannedResponseHandler(new HttpResponseMessage());
var loggingRequestHandler = new LoggingRequestHandler(logger, new LoggingFormatter());
var loggingPreHandler = new LoggingPreHandler(logger, new LoggingFormatter());

using var invoker = HttpMessageInvokerFactory.Create(
loggingRequestHandler, shortCircuitingCannedResponseHandler);
loggingPreHandler, shortCircuitingCannedResponseHandler);

using var _ = await invoker.SendAsync(request, CancellationToken.None);

Expand Down

0 comments on commit 2fd5017

Please sign in to comment.