Ensure an `ObjectPoolProvider` is registered
- e.g. take advantage of aspnet/HttpAbstractions#561 fix wherever cookies are used
This commit is contained in:
parent
6c1247b30c
commit
b06a84457d
|
|
@ -17,6 +17,7 @@ using Microsoft.Extensions.Configuration;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
|
|
@ -135,7 +136,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configure the provided <see cref="ILoggerFactory"/> which will be available as a hosting service.
|
||||
/// Configure the provided <see cref="ILoggerFactory"/> which will be available as a hosting service.
|
||||
/// </summary>
|
||||
/// <param name="configureLogging">The delegate that configures the <see cref="ILoggerFactory"/>.</param>
|
||||
/// <returns>The <see cref="IWebHostBuilder"/>.</returns>
|
||||
|
|
@ -155,7 +156,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
var appEnvironment = hostingContainer.GetRequiredService<IApplicationEnvironment>();
|
||||
var startupLoader = hostingContainer.GetRequiredService<IStartupLoader>();
|
||||
|
||||
|
||||
var contentRootPath = ResolveContentRootPath(_options.ContentRootPath, appEnvironment.ApplicationBasePath);
|
||||
var applicationName = ResolveApplicationName() ?? appEnvironment.ApplicationName;
|
||||
|
||||
|
|
@ -201,6 +202,9 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
// Conjure up a RequestServices
|
||||
services.AddTransient<IStartupFilter, AutoRequestServicesStartupFilter>();
|
||||
|
||||
// Ensure object pooling is available everywhere.
|
||||
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
|
||||
|
||||
var defaultPlatformServices = PlatformServices.Default;
|
||||
if (defaultPlatformServices.Application != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ using Microsoft.AspNetCore.Http.Features;
|
|||
using Microsoft.AspNetCore.Http.Internal;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting
|
||||
|
|
@ -92,12 +92,29 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
using (host)
|
||||
{
|
||||
host.Start();
|
||||
var service = host.Services.GetServices<IApplicationLifetime>();
|
||||
Assert.NotNull(service);
|
||||
var services = host.Services.GetServices<IApplicationLifetime>();
|
||||
Assert.NotNull(services);
|
||||
Assert.NotEmpty(services);
|
||||
|
||||
await AssertResponseContains(server.RequestDelegate, "Exception from constructor");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultObjectPoolProvider_IsRegistered()
|
||||
{
|
||||
var server = new TestServer();
|
||||
var host = CreateWebHostBuilder()
|
||||
.UseServer(server)
|
||||
.Configure(app => { })
|
||||
.Build();
|
||||
using (host)
|
||||
{
|
||||
host.Start();
|
||||
Assert.IsType<DefaultObjectPoolProvider>(host.Services.GetService<ObjectPoolProvider>());
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartupConfigureServicesThrows_Fallback()
|
||||
{
|
||||
|
|
@ -333,7 +350,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
[Fact]
|
||||
public void RelativeContentRootIsResolved()
|
||||
{
|
||||
var contentRootNet451 = PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows ?
|
||||
var contentRootNet451 = PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows ?
|
||||
"testroot" : "../../../../test/Microsoft.AspNetCore.Hosting.Tests/testroot";
|
||||
|
||||
var host = new WebHostBuilder()
|
||||
|
|
|
|||
Loading…
Reference in New Issue