From 23a0c84aa9441d646dd60d1f3761411d5ae5c510 Mon Sep 17 00:00:00 2001 From: Nicolai Unrein Date: Tue, 3 Aug 2021 11:54:43 +0200 Subject: [PATCH] Remove unnecessary `unwrap` in multipart handler The call to `unwrap` is not save at this point and will panic on connection errors/disconnects. Instead a `ParseRequestError::InvalidMultipart(multer::Error)` will now get returned instead. --- src/http/multipart.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/multipart.rs b/src/http/multipart.rs index 020a542e..f358a58b 100644 --- a/src/http/multipart.rs +++ b/src/http/multipart.rs @@ -85,7 +85,7 @@ pub(super) async fn receive_batch_multipart( if let Some(filename) = field.file_name().map(ToString::to_string) { let content_type = field.content_type().map(ToString::to_string); let mut file = tempfile::tempfile().map_err(ParseRequestError::Io)?; - while let Some(chunk) = field.chunk().await.unwrap() { + while let Some(chunk) = field.chunk().await? { file.write(&chunk).map_err(ParseRequestError::Io)?; } file.seek(SeekFrom::Start(0))?;