diff --git a/src/Microsoft.AspNetCore.Http/Features/FormOptions.cs b/src/Microsoft.AspNetCore.Http/Features/FormOptions.cs index 2e6e8c57..dc249781 100644 --- a/src/Microsoft.AspNetCore.Http/Features/FormOptions.cs +++ b/src/Microsoft.AspNetCore.Http/Features/FormOptions.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.IO; using Microsoft.AspNetCore.WebUtilities; namespace Microsoft.AspNetCore.Http.Features @@ -12,15 +13,66 @@ public class FormOptions public const int DefaultMultipartBoundaryLengthLimit = 128; public const long DefaultMultipartBodyLengthLimit = 1024 * 1024 * 128; + /// + /// Enables full request body buffering. Use this if multiple components need to read the raw stream. + /// The default value is false. + /// public bool BufferBody { get; set; } = false; + + /// + /// If is enabled, this many bytes of the body will be buffered in memory. + /// If this threshold is exceeded then the buffer will be moved to a temp file on disk instead. + /// This also applies when buffering individual multipart section bodies. + /// public int MemoryBufferThreshold { get; set; } = DefaultMemoryBufferThreshold; + + /// + /// If is enabled, this is the limit for the total number of bytes that will + /// be buffered. Forms that exceed this limit will throw an when parsed. + /// public long BufferBodyLengthLimit { get; set; } = DefaultBufferBodyLengthLimit; + + /// + /// A limit for the number of form entries to allow. Entries with the same key will be combined. + /// Forms that exceed this limit will throw an when parsed. + /// public int KeyCountLimit { get; set; } = FormReader.DefaultKeyCountLimit; + + /// + /// A limit on the length of individual keys. Forms containing keys that exceed this limit will + /// throw an when parsed. + /// public int KeyLengthLimit { get; set; } = FormReader.DefaultKeyLengthLimit; + + /// + /// A limit on the length of individual form values. Forms containing values that exceed this + /// limit will throw an when parsed. + /// public int ValueLengthLimit { get; set; } = FormReader.DefaultValueLengthLimit; + + /// + /// A limit for the length of the boundary identifier. Forms with boundaries that exceed this + /// limit will throw an when parsed. + /// public int MultipartBoundaryLengthLimit { get; set; } = DefaultMultipartBoundaryLengthLimit; + + /// + /// A limit for the number of headers to allow in each multipart section. Headers with the same name will + /// be combined. Form sections that exceed this limit will throw an + /// when parsed. + /// public int MultipartHeadersCountLimit { get; set; } = MultipartReader.DefaultHeadersCountLimit; + + /// + /// A limit for the total length of the header keys and values in each multipart section. + /// Form sections that exceed this limit will throw an when parsed. + /// public int MultipartHeadersLengthLimit { get; set; } = MultipartReader.DefaultHeadersLengthLimit; + + /// + /// A limit for the length of each multipart body. Forms sections that exceed this limit will throw an + /// when parsed. + /// public long MultipartBodyLengthLimit { get; set; } = DefaultMultipartBodyLengthLimit; } }