fix limit not working on HttpMessage::limit

This commit is contained in:
fakeshadow 2021-01-27 01:57:33 -08:00
parent c201c15f8c
commit 8a155fa5ef
1 changed files with 6 additions and 4 deletions

View File

@ -196,7 +196,7 @@ fn bytes_to_string(body: Bytes, encoding: &'static Encoding) -> Result<String, E
/// `.app_data()` methods. /// `.app_data()` methods.
#[derive(Clone)] #[derive(Clone)]
pub struct PayloadConfig { pub struct PayloadConfig {
limit: usize, pub limit: usize,
mimetype: Option<Mime>, mimetype: Option<Mime>,
} }
@ -316,9 +316,11 @@ impl HttpMessageBody {
/// Change max size of payload. By default max size is 256kB /// Change max size of payload. By default max size is 256kB
pub fn limit(mut self, limit: usize) -> Self { pub fn limit(mut self, limit: usize) -> Self {
if let Some(l) = self.length { if let Some(l) = self.length {
if l > limit { self.err = if l > limit {
self.err = Some(PayloadError::Overflow); Some(PayloadError::Overflow)
} } else {
None
};
} }
self.limit = limit; self.limit = limit;
self self