Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Add doc comments for FormOptions. #621

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/Microsoft.AspNetCore.Http/Features/FormOptions.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,15 +13,66 @@ public class FormOptions
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious regarding usage of MemoryBufferThreshold vs. BufferBodyLengthLimit: If I want to buffer the data and also be safe from larger payloads, I could set the MemoryBufferThreshold alone...so wondering the use of BufferBodyLengthLimit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MemoryBufferThreshold is not a hard limit, no exceptions will be thrown. It's just the amount of memory to use before switching to disk instead.

/// </summary>
public long BufferBodyLengthLimit { get; set; } = DefaultBufferBodyLengthLimit;

/// <summary>
/// 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 <see cref="InvalidDataException"/> when parsed.
/// </summary>
public int KeyCountLimit { get; set; } = FormReader.DefaultKeyCountLimit;

/// <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;
}
}