@@ -507,9 +507,7 @@ impl<R: Runtime> WindowManager<R> {
507507 use crate :: api:: file:: SafePathBuf ;
508508 use tokio:: io:: { AsyncReadExt , AsyncSeekExt } ;
509509 use url:: Position ;
510- let state = self . state ( ) ;
511- let asset_scope = state. get :: < crate :: Scopes > ( ) . asset_protocol . clone ( ) ;
512- let mime_type_cache = MimeTypeCache :: default ( ) ;
510+ let asset_scope = self . state ( ) . get :: < crate :: Scopes > ( ) . asset_protocol . clone ( ) ;
513511 pending. register_uri_scheme_protocol ( "asset" , move |request| {
514512 let parsed_path = Url :: parse ( request. uri ( ) ) ?;
515513 let filtered_path = & parsed_path[ ..Position :: AfterPath ] ;
@@ -624,7 +622,7 @@ impl<R: Runtime> WindowManager<R> {
624622 response = response. header ( k, v) ;
625623 }
626624
627- let mime_type = mime_type_cache . get_or_insert ( & data, & path) ;
625+ let mime_type = MimeType :: parse ( & data, & path) ;
628626 response. mimetype ( & mime_type) . status ( status_code) . body ( data)
629627 } else {
630628 match crate :: async_runtime:: safe_block_on ( async move { tokio:: fs:: read ( path_) . await } ) {
@@ -1429,26 +1427,6 @@ fn request_to_path(request: &tauri_runtime::http::Request, base_url: &str) -> St
14291427 }
14301428}
14311429
1432- // key is uri/path, value is the store mime type
1433- #[ cfg( protocol_asset) ]
1434- #[ derive( Debug , Clone , Default ) ]
1435- struct MimeTypeCache ( Arc < Mutex < HashMap < String , String > > > ) ;
1436-
1437- #[ cfg( protocol_asset) ]
1438- impl MimeTypeCache {
1439- pub fn get_or_insert ( & self , content : & [ u8 ] , uri : & str ) -> String {
1440- let mut cache = self . 0 . lock ( ) . unwrap ( ) ;
1441- let uri = uri. to_string ( ) ;
1442- if let Some ( mime_type) = cache. get ( & uri) {
1443- mime_type. clone ( )
1444- } else {
1445- let mime_type = MimeType :: parse ( content, & uri) ;
1446- cache. insert ( uri, mime_type. clone ( ) ) ;
1447- mime_type
1448- }
1449- }
1450- }
1451-
14521430#[ cfg( test) ]
14531431mod tests {
14541432 use super :: replace_with_callback;
0 commit comments