@@ -224,7 +224,7 @@ private async Task<string> GetStringAsyncCore(HttpRequestMessage request, Cancel
224
224
}
225
225
finally
226
226
{
227
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
227
+ FinishSend ( response , cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
228
228
}
229
229
}
230
230
@@ -303,7 +303,7 @@ private async Task<byte[]> GetByteArrayAsyncCore(HttpRequestMessage request, Can
303
303
}
304
304
finally
305
305
{
306
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
306
+ FinishSend ( response , cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
307
307
}
308
308
}
309
309
@@ -349,7 +349,7 @@ private async Task<Stream> GetStreamAsyncCore(HttpRequestMessage request, Cancel
349
349
}
350
350
finally
351
351
{
352
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted : false ) ;
352
+ FinishSend ( response , cts , disposeCts , telemetryStarted , responseContentTelemetryStarted : false ) ;
353
353
}
354
354
}
355
355
@@ -493,7 +493,7 @@ public HttpResponseMessage Send(HttpRequestMessage request, HttpCompletionOption
493
493
}
494
494
finally
495
495
{
496
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
496
+ FinishSend ( response , cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
497
497
}
498
498
}
499
499
@@ -548,7 +548,7 @@ async Task<HttpResponseMessage> Core(
548
548
}
549
549
finally
550
550
{
551
- FinishSend ( cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
551
+ FinishSend ( response , cts , disposeCts , telemetryStarted , responseContentTelemetryStarted ) ;
552
552
}
553
553
}
554
554
}
@@ -583,8 +583,6 @@ private static bool ShouldBufferResponse(HttpCompletionOption completionOption,
583
583
584
584
private void HandleFailure ( Exception e , bool telemetryStarted , HttpResponseMessage ? response , CancellationTokenSource cts , CancellationToken cancellationToken , CancellationTokenSource pendingRequestsCts )
585
585
{
586
- LogRequestFailed ( telemetryStarted ) ;
587
-
588
586
response ? . Dispose ( ) ;
589
587
590
588
Exception ? toThrow = null ;
@@ -616,6 +614,8 @@ private void HandleFailure(Exception e, bool telemetryStarted, HttpResponseMessa
616
614
e = toThrow = new OperationCanceledException ( cancellationToken . IsCancellationRequested ? cancellationToken : cts . Token ) ;
617
615
}
618
616
617
+ LogRequestFailed ( e , telemetryStarted ) ;
618
+
619
619
if ( NetEventSource . Log . IsEnabled ( ) ) NetEventSource . Error ( this , e ) ;
620
620
621
621
if ( toThrow != null )
@@ -635,7 +635,7 @@ private static bool StartSend(HttpRequestMessage request)
635
635
return false ;
636
636
}
637
637
638
- private static void FinishSend ( CancellationTokenSource cts , bool disposeCts , bool telemetryStarted , bool responseContentTelemetryStarted )
638
+ private static void FinishSend ( HttpResponseMessage ? response , CancellationTokenSource cts , bool disposeCts , bool telemetryStarted , bool responseContentTelemetryStarted )
639
639
{
640
640
// Log completion.
641
641
if ( HttpTelemetry . Log . IsEnabled ( ) && telemetryStarted )
@@ -645,7 +645,7 @@ private static void FinishSend(CancellationTokenSource cts, bool disposeCts, boo
645
645
HttpTelemetry . Log . ResponseContentStop ( ) ;
646
646
}
647
647
648
- HttpTelemetry . Log . RequestStop ( ) ;
648
+ HttpTelemetry . Log . RequestStop ( response ) ;
649
649
}
650
650
651
651
// Dispose of the CancellationTokenSource if it was created specially for this request
0 commit comments