Files
Umbraco-CMS/src/Umbraco.Web.Common/Security/ConfigureKestrelServerOptions.cs
2021-09-20 07:56:22 +02:00

19 lines
763 B
C#

using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Configuration.Models;
namespace Umbraco.Cms.Web.Common.Security
{
public class ConfigureKestrelServerOptions : IConfigureOptions<KestrelServerOptions>
{
private readonly IOptions<RuntimeSettings> _runtimeSettings;
public ConfigureKestrelServerOptions(IOptions<RuntimeSettings> runtimeSettings) => _runtimeSettings = runtimeSettings;
public void Configure(KestrelServerOptions options)
{
// convert from KB to bytes
options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue ? _runtimeSettings.Value.MaxRequestLength.Value * 1024 : long.MaxValue;
}
}
}