| | | 1 | | namespace Kestrun.Forms; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Defines form parsing limits. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class KrFormLimits |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Gets or sets the maximum allowed request body size in bytes. |
| | | 10 | | /// </summary> |
| | 33 | 11 | | public long? MaxRequestBodyBytes { get; set; } = 100 * 1024 * 1024; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets the maximum allowed part body size in bytes. |
| | | 15 | | /// </summary> |
| | 31 | 16 | | public long MaxPartBodyBytes { get; set; } = 20 * 1024 * 1024; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets the maximum number of parts allowed. |
| | | 20 | | /// </summary> |
| | 32 | 21 | | public int MaxParts { get; set; } = 1024; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets or sets the maximum header bytes per part. |
| | | 25 | | /// </summary> |
| | 31 | 26 | | public int MaxHeaderBytesPerPart { get; set; } = 16 * 1024; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets or sets the maximum field value size in bytes. |
| | | 30 | | /// </summary> |
| | 27 | 31 | | public long MaxFieldValueBytes { get; set; } = 64 * 1024; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets or sets the maximum nesting depth for multipart bodies. |
| | | 35 | | /// </summary> |
| | 15 | 36 | | public int MaxNestingDepth { get; set; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Initializes a new instance of the <see cref="KrFormLimits"/> class. |
| | | 40 | | /// </summary> |
| | 34 | 41 | | public KrFormLimits() { } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Initializes a new instance of the <see cref="KrFormLimits"/> class by copying settings from another instance. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="other"> The instance to copy settings from. </param> |
| | 1 | 47 | | public KrFormLimits(KrFormLimits other) |
| | | 48 | | { |
| | 1 | 49 | | MaxRequestBodyBytes = other.MaxRequestBodyBytes; |
| | 1 | 50 | | MaxPartBodyBytes = other.MaxPartBodyBytes; |
| | 1 | 51 | | MaxParts = other.MaxParts; |
| | 1 | 52 | | MaxHeaderBytesPerPart = other.MaxHeaderBytesPerPart; |
| | 1 | 53 | | MaxFieldValueBytes = other.MaxFieldValueBytes; |
| | 1 | 54 | | MaxNestingDepth = other.MaxNestingDepth; |
| | 1 | 55 | | } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Returns a string representation of the form limits. |
| | | 59 | | /// </summary> |
| | | 60 | | /// <returns></returns> |
| | 1 | 61 | | public override string ToString() => $"MaxRequestBodyBytes={MaxRequestBodyBytes}, MaxPartBodyBytes={MaxPartBodyBytes |
| | | 62 | | } |