HttpLimitEntry Class
System.Net.Http.HeadersRepresents a single entry in the HttpLimits collection, defining a specific HTTP header and its associated limit.
Syntax
public class HttpLimitEntry
Remarks
The HttpLimitEntry class is used to configure limits on specific HTTP headers to prevent potential abuse or resource exhaustion. This class is part of the System.Net.Http.Headers namespace, providing a structured way to manage these limits.
Each entry typically specifies the name of an HTTP header and a corresponding numerical limit (e.g., maximum length, maximum count). These entries are then aggregated within an HttpLimits object, which can be applied to HTTP client or server configurations.
Constructors
| Constructor | Description | ||||
|---|---|---|---|---|---|
| HttpLimitEntry(string headerName, int limit) |
Initializes a new instance of the Parameters
|
Properties
| Property | Type | Description |
|---|---|---|
| HeaderName | string | Gets the name of the HTTP header associated with this limit entry. |
| Limit | int | Gets the numerical limit value for the specified HTTP header. |
Methods
| Method | Description |
|---|---|
| Equals(object obj) |
Determines whether the specified object is equal to the current object. |
| GetHashCode() |
Serves as the default hash function. |
| ToString() |
Returns a string representation of the |
Example
using System.Net.Http.Headers;
// Create a limit entry for the 'Content-Length' header
HttpLimitEntry contentLengthLimit = new HttpLimitEntry("Content-Length", 1024 * 1024); // 1MB limit
// Add this entry to a collection of limits (e.g., HttpLimits)
// HttpLimits limits = new HttpLimits();
// limits.Add(contentLengthLimit);
Console.WriteLine($"Header: {contentLengthLimit.HeaderName}, Limit: {contentLengthLimit.Limit}");
// Output: Header: Content-Length, Limit: 1048576