Skip to content

Commit

Permalink
Better support for HTTP/2 in SignalR .NET client (#42817)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanConroy authored Aug 22, 2022
1 parent aad9c23 commit 9c8ad73
Show file tree
Hide file tree
Showing 20 changed files with 481 additions and 81 deletions.
5 changes: 3 additions & 2 deletions src/Shared/SignalR/FunctionalTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Logging.Testing;

namespace Microsoft.AspNetCore.SignalR.Tests;
Expand Down Expand Up @@ -36,9 +37,9 @@ private Func<WriteContext, bool> ResolveExpectedErrorsFilter(Func<WriteContext,
};
}

public Task<InProcessTestServer<T>> StartServer<T>(Func<WriteContext, bool> expectedErrorsFilter = null) where T : class
public Task<InProcessTestServer<T>> StartServer<T>(Func<WriteContext, bool> expectedErrorsFilter = null, Action<KestrelServerOptions> configureKestrelServerOptions = null) where T : class
{
var disposable = base.StartVerifiableLog(ResolveExpectedErrorsFilter(expectedErrorsFilter));
return InProcessTestServer<T>.StartServer(LoggerFactory, disposable);
return InProcessTestServer<T>.StartServer(LoggerFactory, configureKestrelServerOptions, disposable);
}
}
13 changes: 8 additions & 5 deletions src/Shared/SignalR/InProcessTestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -38,6 +39,7 @@ public class InProcessTestServer<TStartup> : InProcessTestServer
private IHostApplicationLifetime _lifetime;
private readonly IDisposable _logToken;
private readonly IDisposable _extraDisposable;
private readonly Action<KestrelServerOptions> _configureKestrelServerOptions;

private readonly LogSinkProvider _logSinkProvider;
private string _url;
Expand All @@ -52,19 +54,20 @@ internal override event Action<LogRecord> ServerLogged

public override string Url => _url;

public static async Task<InProcessTestServer<TStartup>> StartServer(ILoggerFactory loggerFactory, IDisposable disposable = null)
public static async Task<InProcessTestServer<TStartup>> StartServer(ILoggerFactory loggerFactory, Action<KestrelServerOptions> configureKestrelServerOptions = null, IDisposable disposable = null)
{
var server = new InProcessTestServer<TStartup>(loggerFactory, disposable);
var server = new InProcessTestServer<TStartup>(loggerFactory, configureKestrelServerOptions, disposable);
await server.StartServerInner();
return server;
}

private InProcessTestServer() : this(loggerFactory: null, null)
private InProcessTestServer() : this(loggerFactory: null, null, null)
{
}

private InProcessTestServer(ILoggerFactory loggerFactory, IDisposable disposable)
private InProcessTestServer(ILoggerFactory loggerFactory, Action<KestrelServerOptions> configureKestrelServerOptions, IDisposable disposable)
{
_configureKestrelServerOptions = configureKestrelServerOptions;
_extraDisposable = disposable;
_logSinkProvider = new LogSinkProvider();

Expand Down Expand Up @@ -99,7 +102,7 @@ private async Task StartServerInner()
.SetMinimumLevel(LogLevel.Trace)
.AddProvider(new ForwardingLoggerProvider(_loggerFactory)))
.UseStartup(typeof(TStartup))
.UseKestrel()
.UseKestrel(o => _configureKestrelServerOptions?.Invoke(o))
.UseUrls(url)
.UseContentRoot(Directory.GetCurrentDirectory());
}).Build();
Expand Down
Loading

0 comments on commit 9c8ad73

Please sign in to comment.