Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -955,19 +955,20 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
{
using HttpMessageInvoker client = CreateHttpMessageInvoker();
using InstrumentRecorder<double> recorder = SetupInstrumentRecorder<double>(InstrumentNames.RequestDuration);
using HttpRequestMessage request = new(HttpMethod.Get, uri) { Version = UseVersion };
using HttpRequestMessage request = new(HttpMethod.Post, uri) { Version = UseVersion };
request.Content = new StringContent("{}");

Exception ex = await Assert.ThrowsAnyAsync<Exception>(async () =>
{
// Getting a cancellation is also good if we are unable to detect the peer shutdown.
using CancellationTokenSource cts = new CancellationTokenSource(10_000);
// To avoid unlimited blocking, lets bound it to 20 seconds.
using CancellationTokenSource cts = new CancellationTokenSource(20_000);
using HttpResponseMessage response = await SendAsync(client, request, cts.Token);
});
cancelServerCts.Cancel();
Assert.True(ex is HttpRequestException or TaskCanceledException);

Measurement<double> m = Assert.Single(recorder.GetMeasurements());
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"]);
VerifyRequestDuration(m, uri, acceptedErrorTypes: [typeof(TaskCanceledException).FullName, "response_ended"], method: "POST");
}, async server =>
{
await IgnoreExceptions(async () =>
Expand Down