diff options
author | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-25 16:41:05 +0000 |
---|---|---|
committer | boastful-squirrel <boastful.squirrel@gmail.com> | 2019-04-25 16:41:05 +0000 |
commit | b223d7dff4f70e85695c5641db932944db4dc774 (patch) | |
tree | a6de481eaf136eb9d5c739e99c14cae349c5c01a /src/file_upload.rs | |
parent | Made code more idiomatic (diff) | |
parent | Merge pull request #82 from svenstaro/dependabot/cargo/pretty_assertions-0.6.1 (diff) | |
download | miniserve-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.rs | 9 |
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 { |