2021-09-08 13:41:46 +02:00
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
namespace Umbraco.Cms.Web.Common.Security;
|
|
|
|
|
|
|
|
|
|
public class ConfigureKestrelServerOptions : IConfigureOptions<KestrelServerOptions>
|
2021-09-08 13:41:46 +02:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
private readonly IOptions<RuntimeSettings> _runtimeSettings;
|
|
|
|
|
|
|
|
|
|
public ConfigureKestrelServerOptions(IOptions<RuntimeSettings> runtimeSettings) =>
|
|
|
|
|
_runtimeSettings = runtimeSettings;
|
|
|
|
|
|
|
|
|
|
public void Configure(KestrelServerOptions options) =>
|
2021-09-08 13:41:46 +02:00
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
// convert from KB to bytes, 52428800 bytes (50 MB) is the same as in the IIS settings
|
|
|
|
|
options.Limits.MaxRequestBodySize = _runtimeSettings.Value.MaxRequestLength.HasValue
|
|
|
|
|
? _runtimeSettings.Value.MaxRequestLength.Value * 1024
|
|
|
|
|
: 52428800;
|
2021-09-08 13:41:46 +02:00
|
|
|
}
|