aboutsummaryrefslogtreecommitdiffstats
path: root/src/file_upload.rs
diff options
context:
space:
mode:
authorboastful-squirrel <boastful.squirrel@gmail.com>2019-04-25 16:41:05 +0000
committerboastful-squirrel <boastful.squirrel@gmail.com>2019-04-25 16:41:05 +0000
commitb223d7dff4f70e85695c5641db932944db4dc774 (patch)
treea6de481eaf136eb9d5c739e99c14cae349c5c01a /src/file_upload.rs
parentMade code more idiomatic (diff)
parentMerge pull request #82 from svenstaro/dependabot/cargo/pretty_assertions-0.6.1 (diff)
downloadminiserve-b223d7dff4f70e85695c5641db932944db4dc774.tar.gz
miniserve-b223d7dff4f70e85695c5641db932944db4dc774.zip
Merge branch 'master' into no_panics
Diffstat (limited to 'src/file_upload.rs')
-rw-r--r--src/file_upload.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/file_upload.rs b/src/file_upload.rs
index 3b84721..1618617 100644
--- a/src/file_upload.rs
+++ b/src/file_upload.rs
@@ -122,10 +122,11 @@ fn handle_multipart(
/// invalid.
/// This method returns future.
pub fn upload_file(req: &HttpRequest<crate::MiniserveConfig>) -> FutureResponse<HttpResponse> {
- let return_path: String = req.headers()[header::REFERER]
- .to_str()
- .unwrap_or("/")
- .to_owned();
+ let return_path = if let Some(header) = req.headers().get(header::REFERER) {
+ header.to_str().unwrap_or("/").to_owned()
+ } else {
+ "/".to_string()
+ };
let app_root_dir = if let Ok(dir) = req.state().path.canonicalize() {
dir
} else {