Make Protocols internal
This commit is contained in:
parent
ca44b4adfc
commit
c6fa9793eb
|
|
@ -13,8 +13,6 @@ namespace Http2SampleApp
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
AppContext.SetSwitch("Switch.Microsoft.AspNetCore.Server.Kestrel.Experimental.Http2", isEnabled: true);
|
||||
|
||||
var hostBuilder = new WebHostBuilder()
|
||||
.ConfigureLogging((_, factory) =>
|
||||
{
|
||||
|
|
@ -31,6 +29,7 @@ namespace Http2SampleApp
|
|||
|
||||
options.Listen(IPAddress.Any, basePort, listenOptions =>
|
||||
{
|
||||
// This only works becuase InternalsVisibleTo is enabled for this sample.
|
||||
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
|
||||
listenOptions.UseHttps("testCert.pfx", "testPassword");
|
||||
listenOptions.UseConnectionLogging();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace SampleApp
|
|||
|
||||
options.ConfigureEndpointDefaults(opt =>
|
||||
{
|
||||
opt.Protocols = HttpProtocols.Http1;
|
||||
opt.NoDelay = true;
|
||||
});
|
||||
|
||||
options.ConfigureHttpsDefaults(httpsOptions =>
|
||||
|
|
@ -129,7 +129,7 @@ namespace SampleApp
|
|||
.Configure(context.Configuration.GetSection("Kestrel"))
|
||||
.Endpoint("NamedEndpoint", opt =>
|
||||
{
|
||||
opt.ListenOptions.Protocols = HttpProtocols.Http1;
|
||||
opt.ListenOptions.NoDelay = true;
|
||||
})
|
||||
.Endpoint("NamedHttpsEndpoint", opt =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,18 +19,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
|
|||
/// </summary>
|
||||
public class ListenOptions : IEndPointInformation, IConnectionBuilder
|
||||
{
|
||||
internal const string Http2ExperimentSwitch = "Switch.Microsoft.AspNetCore.Server.Kestrel.Experimental.Http2";
|
||||
|
||||
private FileHandleType _handleType;
|
||||
private HttpProtocols _protocols = HttpProtocols.Http1;
|
||||
internal bool _isHttp2Supported;
|
||||
internal readonly List<Func<ConnectionDelegate, ConnectionDelegate>> _middleware = new List<Func<ConnectionDelegate, ConnectionDelegate>>();
|
||||
|
||||
internal ListenOptions(IPEndPoint endPoint)
|
||||
{
|
||||
Type = ListenType.IPEndPoint;
|
||||
IPEndPoint = endPoint;
|
||||
AppContext.TryGetSwitch(Http2ExperimentSwitch, out _isHttp2Supported);
|
||||
}
|
||||
|
||||
internal ListenOptions(string socketPath)
|
||||
|
|
@ -127,20 +122,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
|
|||
/// <summary>
|
||||
/// The protocols enabled on this endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>Defaults to HTTP/1.x only. HTTP/2 support is experimental, see
|
||||
/// https://go.microsoft.com/fwlink/?linkid=866785 to enable it.</remarks>
|
||||
public HttpProtocols Protocols
|
||||
{
|
||||
get => _protocols;
|
||||
set
|
||||
{
|
||||
if (!_isHttp2Supported && (value == HttpProtocols.Http1AndHttp2 || value == HttpProtocols.Http2))
|
||||
{
|
||||
throw new NotSupportedException(CoreStrings.Http2NotSupported);
|
||||
}
|
||||
_protocols = value;
|
||||
}
|
||||
}
|
||||
/// <remarks>Defaults to HTTP/1.x only.</remarks>
|
||||
internal HttpProtocols Protocols { get; set; } = HttpProtocols.Http1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="List{IConnectionAdapter}"/> that allows each connection <see cref="System.IO.Stream"/>
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Server.Kestrel.Core.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Kestrel.Performance, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
[assembly: InternalsVisibleTo("Http2SampleApp, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
|
|
|||
|
|
@ -20,16 +20,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Equal(HttpProtocols.Http1, listenOptions.Protocols);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Http2DisabledByDefault()
|
||||
{
|
||||
var listenOptions = new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0));
|
||||
var ex = Assert.Throws<NotSupportedException>(() => listenOptions.Protocols = HttpProtocols.Http1AndHttp2);
|
||||
Assert.Equal(CoreStrings.Http2NotSupported, ex.Message);
|
||||
ex = Assert.Throws<NotSupportedException>(() => listenOptions.Protocols = HttpProtocols.Http2);
|
||||
Assert.Equal(CoreStrings.Http2NotSupported, ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LocalHostListenOptionsClonesConnectionMiddleware()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
options.Listen(IPAddress.Loopback, 0, listenOptions =>
|
||||
{
|
||||
listenOptions._isHttp2Supported = true;
|
||||
listenOptions.Protocols = serverProtocols;
|
||||
});
|
||||
})
|
||||
|
|
@ -81,7 +80,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
.ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(loggerProvider.Object))
|
||||
.UseKestrel(options => options.Listen(IPAddress.Loopback, 0, listenOptions =>
|
||||
{
|
||||
listenOptions._isHttp2Supported = true;
|
||||
listenOptions.Protocols = serverProtocols;
|
||||
}))
|
||||
.Configure(app => app.Run(context => Task.CompletedTask));
|
||||
|
|
|
|||
Loading…
Reference in New Issue