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 @@ -2173,6 +2173,7 @@ public async Task SendAsync_InvalidRequestUri_Throws()
public async Task SendAsync_RequestWithDangerousControlHeaderValue_ThrowsHttpRequestException(char dangerousChar, HeaderType headerType)
{
TaskCompletionSource<bool> acceptConnection = new TaskCompletionSource<bool>();
SemaphoreSlim clientFinished = new SemaphoreSlim(0);

await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
{
Expand Down Expand Up @@ -2216,6 +2217,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
// WinHTTP validates the input before opening connection whereas SocketsHttpHandler opens connection first and validates only when writing to the wire.
acceptConnection.SetResult(!IsWinHttpHandler);
var ex = await Assert.ThrowsAnyAsync<Exception>(() => client.SendAsync(request));
clientFinished.Release();
var hrex = Assert.IsType<HttpRequestException>(ex);
if (IsWinHttpHandler)
{
Expand All @@ -2231,7 +2233,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
{
if (await acceptConnection.Task)
{
await IgnoreExceptions(server.AcceptConnectionAsync(c => Task.CompletedTask));
await IgnoreExceptions(() => server.AcceptConnectionAsync(_ => clientFinished.WaitAsync(TestHelper.PassingTestTimeout)));
}
});
}
Expand Down
Loading