pub struct SizeLimit { /* private fields */ }Expand description
Represents size limit of the stream to prevent DoS attacks.
Please refer Constraints for more info.
Implementations§
Source§impl SizeLimit
impl SizeLimit
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates the default size limits.
The whole stream and each field are unbounded, while the preamble is limited to 32 KiB, each field’s header block to 64 KiB, and each boundary’s transport padding to 8 KiB.
Sourcepub const fn whole_stream(self, limit: u64) -> Self
pub const fn whole_stream(self, limit: u64) -> Self
Sets size limit for the whole stream.
A finite limit includes the MIME epilogue after the closing boundary.
Completing iteration therefore waits for the source to reach EOF, and
source errors in the epilogue are propagated. With the default
unbounded limit (u64::MAX), parsing stops at the closing boundary.
Sourcepub const fn preamble(self, limit: u64) -> Self
pub const fn preamble(self, limit: u64) -> Self
Sets the size limit for data before the first multipart boundary.
The default is 32 KiB. Multipart form submissions normally have no preamble, but MIME permits one before the first boundary.
Sourcepub const fn headers(self, limit: u64) -> Self
pub const fn headers(self, limit: u64) -> Self
Sets size limit for a field’s full header block.
Sourcepub const fn boundary_padding(self, limit: u64) -> Self
pub const fn boundary_padding(self, limit: u64) -> Self
Sets the maximum number of spaces and tabs after each boundary.
The default is 8 KiB. This applies independently of field and stream limits, to opening, intermediate, and closing boundaries. The boundary marker and terminating CRLF are not included in this limit.
Sourcepub fn for_field<N: Into<String>>(self, field_name: N, limit: u64) -> Self
pub fn for_field<N: Into<String>>(self, field_name: N, limit: u64) -> Self
Sets size limit for a specific field, it overrides the
per_field value for this field.
It is useful when you want to set a size limit on a textual field which
will be stored in memory to avoid potential DoS attacks from
attackers running the server out of memory.