Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change SendAsync_SlowServerRespondsAfterDefaultReceiveTimeout_ThrowsHttpRequestException server to Loopback #93025

Merged
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 @@ -80,7 +80,6 @@ public async Task GetAsync_RedirectResponseHasCookie_CookieSentToFinalUri(

[OuterLoop]
[Fact]
[OuterLoop]
liveans marked this conversation as resolved.
Show resolved Hide resolved
public async Task SendAsync_SlowServerAndCancel_ThrowsTaskCanceledException()
{
var handler = new WinHttpHandler();
Expand All @@ -97,19 +96,38 @@ public async Task SendAsync_SlowServerAndCancel_ThrowsTaskCanceledException()
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/20675")]
[OuterLoop]
[Fact]
[OuterLoop]
public void SendAsync_SlowServerRespondsAfterDefaultReceiveTimeout_ThrowsHttpRequestException()
public async void SendAsync_SlowServerRespondsAfterDefaultReceiveTimeout_ThrowsHttpRequestException()
{
var handler = new WinHttpHandler();
using (var client = new HttpClient(handler))
{
Task<HttpResponseMessage> t = client.GetAsync(SlowServer);
var triggerResponseWrite = new TaskCompletionSource<bool>();
var triggerRequestWait = new TaskCompletionSource<bool>();

AggregateException ag = Assert.Throws<AggregateException>(() => t.Wait());
Assert.IsType<HttpRequestException>(ag.InnerException);
await LoopbackServer.CreateServerAsync(async (server, url) =>
{
Task serverTask = server.AcceptConnectionAsync(async connection =>
{
await connection.SendResponseAsync($"HTTP/1.1 200 OK\r\nContent-Length: 16000\r\n\r\n");

triggerRequestWait.SetResult(true);
await triggerResponseWrite.Task;
});

HttpRequestException ex = await Assert.ThrowsAsync<HttpRequestException>(async () =>
{
Task<HttpResponseMessage> t = client.GetAsync(url);
await triggerRequestWait.Task;
var _ = await t;
});
Assert.IsType<IOException>(ex.InnerException);
Assert.NotNull(ex.InnerException.InnerException);
Assert.Contains("The operation timed out", ex.InnerException.InnerException.Message);

triggerResponseWrite.SetResult(true);
});
}
}

Expand Down
Loading