Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adressed PR comments
  • Loading branch information
ManickaP committed Jul 18, 2020
commit b2ca94ca278b4b9046b30ea1b2d87d321746548f
Original file line number Diff line number Diff line change
Expand Up @@ -2128,17 +2128,15 @@ public async Task SendAsync_Expect100Continue_RequestBodyFails_ThrowsContentExce
}

var clientFinished = new TaskCompletionSource<bool>();
const string ExpectedMessage = "ThrowingContentException";

await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
{
using (HttpClient client = CreateHttpClient())
{
HttpRequestMessage initialMessage = new HttpRequestMessage(HttpMethod.Post, uri) { Version = UseVersion };
initialMessage.Content = new ThrowingContent(() => new Exception(ExpectedMessage));
initialMessage.Content = new ThrowingContent(() => new ThrowingContentException());
initialMessage.Headers.ExpectContinue = true;
Exception exception = await Assert.ThrowsAsync<Exception>(() => client.SendAsync(TestAsync, initialMessage));
Assert.Equal(ExpectedMessage, exception.Message);
Exception exception = await Assert.ThrowsAsync<ThrowingContentException>(() => client.SendAsync(TestAsync, initialMessage));

clientFinished.SetResult(true);
}
Expand All @@ -2151,7 +2149,7 @@ await server.AcceptConnectionAsync(async connection =>
await connection.ReadRequestDataAsync(readBody: true);
}
catch { } // Eat errors from client disconnect.
await clientFinished.Task;
await clientFinished.Task.TimeoutAfter(TimeSpan.FromMinutes(2));
});
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Common/tests/System/Net/Http/ThrowingContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ protected override bool TryComputeLength(out long length)
return true;
}
}

public class ThrowingContentException : Exception
{ }
}