This repository was archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathFormOptions.cs
More file actions
78 lines (66 loc) · 3.87 KB
/
Copy pathFormOptions.cs
File metadata and controls
78 lines (66 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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
{
public class FormOptions
{
public const int DefaultMemoryBufferThreshold = 1024 * 64;
public const int DefaultBufferBodyLengthLimit = 1024 * 1024 * 128;
public const int DefaultMultipartBoundaryLengthLimit = 128;
public const long DefaultMultipartBodyLengthLimit = 1024 * 1024 * 128;
/// <summary>
/// Enables full request body buffering. Use this if multiple components need to read the raw stream.
/// The default value is false.
/// </summary>
public bool BufferBody { get; set; } = false;
/// <summary>
/// If <see cref="BufferBody"/> 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.
/// </summary>
public int MemoryBufferThreshold { get; set; } = DefaultMemoryBufferThreshold;
/// <summary>
/// If <see cref="BufferBody"/> is enabled, this is the limit for the total number of bytes that will
/// be buffered. Forms that exceed this limit will throw an <see cref="InvalidDataException"/> when parsed.
/// </summary>
public long BufferBodyLengthLimit { get; set; } = DefaultBufferBodyLengthLimit;
/// <summary>
/// A limit for the number of form entries to allow.
/// Forms that exceed this limit will throw an <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int ValueCountLimit { get; set; } = FormReader.DefaultValueCountLimit;
/// <summary>
/// A limit on the length of individual keys. Forms containing keys that exceed this limit will
/// throw an <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int KeyLengthLimit { get; set; } = FormReader.DefaultKeyLengthLimit;
/// <summary>
/// A limit on the length of individual form values. Forms containing values that exceed this
/// limit will throw an <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int ValueLengthLimit { get; set; } = FormReader.DefaultValueLengthLimit;
/// <summary>
/// A limit for the length of the boundary identifier. Forms with boundaries that exceed this
/// limit will throw an <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int MultipartBoundaryLengthLimit { get; set; } = DefaultMultipartBoundaryLengthLimit;
/// <summary>
/// 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 <see cref="InvalidDataException"/>
/// when parsed.
/// </summary>
public int MultipartHeadersCountLimit { get; set; } = MultipartReader.DefaultHeadersCountLimit;
/// <summary>
/// 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 <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int MultipartHeadersLengthLimit { get; set; } = MultipartReader.DefaultHeadersLengthLimit;
/// <summary>
/// A limit for the length of each multipart body. Forms sections that exceed this limit will throw an
/// <see cref="InvalidDataException"/> when parsed.
/// </summary>
public long MultipartBodyLengthLimit { get; set; } = DefaultMultipartBodyLengthLimit;
}
}