Skip to content
Closed
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
Move test to SocketsHttpHandlerTest file
  • Loading branch information
MihaZupan committed Aug 15, 2022
commit 34817aecbf5ea54507b306bd6497897cccfd8ab8
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,6 @@ public abstract class HttpClientHandler_MaxResponseHeadersLength_Test : HttpClie
{
public HttpClientHandler_MaxResponseHeadersLength_Test(ITestOutputHelper output) : base(output) { }

[Theory]
[InlineData(null)]
[InlineData(1)]
[InlineData(16)]
[InlineData(64)]
[InlineData(256)]
[InlineData(1024)]
[InlineData(10240)]
public async Task Http3Test(int? maxResponseHeadersLength)
{
if (UseVersion.Major != 3) return;

var requestCts = new CancellationTokenSource();
var controlStreamEstablishedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);

await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
{
using HttpClientHandler handler = CreateHttpClientHandler();
using HttpClient client = CreateHttpClient(handler);

if (maxResponseHeadersLength.HasValue)
{
handler.MaxResponseHeadersLength = maxResponseHeadersLength.Value;
}

await Assert.ThrowsAnyAsync<Exception>(() => client.GetAsync(uri, requestCts.Token));

await controlStreamEstablishedTcs.Task.WaitAsync(TestHelper.PassingTestTimeout);
},
async server =>
{
await server.AcceptConnectionAsync(async connection =>
{
requestCts.Cancel();

var http3Connection = (Http3LoopbackConnection)connection;

await http3Connection.EnsureControlStreamAcceptedAsync().WaitAsync(TestHelper.PassingTestTimeout);

controlStreamEstablishedTcs.SetResult();
});
});
}

[Theory]
[InlineData(0)]
[InlineData(-1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,48 @@ public sealed class SocketsHttpHandler_HttpClientHandler_MaxResponseHeadersLengt
{
public SocketsHttpHandler_HttpClientHandler_MaxResponseHeadersLength_Http3(ITestOutputHelper output) : base(output) { }
protected override Version UseVersion => HttpVersion.Version30;

[Theory]
[InlineData(null)]
[InlineData(1)]
[InlineData(16)]
[InlineData(64)]
[InlineData(256)]
[InlineData(1024)]
[InlineData(10240)]
public async Task Http3Test(int? maxResponseHeadersLength)
{
var requestCts = new CancellationTokenSource();
var controlStreamEstablishedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);

await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
{
using HttpClientHandler handler = CreateHttpClientHandler();
using HttpClient client = CreateHttpClient(handler);

if (maxResponseHeadersLength.HasValue)
{
handler.MaxResponseHeadersLength = maxResponseHeadersLength.Value;
}

await Assert.ThrowsAnyAsync<Exception>(() => client.GetAsync(uri, requestCts.Token));

await controlStreamEstablishedTcs.Task.WaitAsync(TestHelper.PassingTestTimeout);
},
async server =>
{
await server.AcceptConnectionAsync(async connection =>
{
requestCts.Cancel();

var http3Connection = (Http3LoopbackConnection)connection;

await http3Connection.EnsureControlStreamAcceptedAsync().WaitAsync(TestHelper.PassingTestTimeout);

controlStreamEstablishedTcs.SetResult();
});
});
}
}

[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
Expand Down