Replace deprecated methods

This commit is contained in:
Yuki Okushi 2019-08-11 13:44:20 +09:00
parent 450270476e
commit 3154bc52c4
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,7 @@ use bytes::Bytes;
use futures::future::{ok, Either, FutureResult}; use futures::future::{ok, Either, FutureResult};
use futures::{Async, Future, Poll, Stream}; use futures::{Async, Future, Poll, Stream};
use mime; use mime;
use mime_guess::get_mime_type; use mime_guess::from_ext;
use percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; use percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};
use v_htmlescape::escape as escape_html_entity; use v_htmlescape::escape as escape_html_entity;
@ -42,7 +42,7 @@ type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error
/// the type `application/octet-stream`. /// the type `application/octet-stream`.
#[inline] #[inline]
pub fn file_extension_to_mime(ext: &str) -> mime::Mime { pub fn file_extension_to_mime(ext: &str) -> mime::Mime {
get_mime_type(ext) from_ext(ext).first_or_octet_stream()
} }
#[doc(hidden)] #[doc(hidden)]

View File

@ -9,7 +9,7 @@ use std::os::unix::fs::MetadataExt;
use bitflags::bitflags; use bitflags::bitflags;
use mime; use mime;
use mime_guess::guess_mime_type; use mime_guess::from_path;
use actix_http::body::SizedStream; use actix_http::body::SizedStream;
use actix_web::http::header::{ use actix_web::http::header::{
@ -88,7 +88,7 @@ impl NamedFile {
} }
}; };
let ct = guess_mime_type(&path); let ct = from_path(&path).first_or_octet_stream();
let disposition_type = match ct.type_() { let disposition_type = match ct.type_() {
mime::IMAGE | mime::TEXT | mime::VIDEO => DispositionType::Inline, mime::IMAGE | mime::TEXT | mime::VIDEO => DispositionType::Inline,
_ => DispositionType::Attachment, _ => DispositionType::Attachment,