From 9d690d31370a32f781b2ac641dd46de4c0bb40ff Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 18 Jan 2025 04:19:15 +0200 Subject: [PATCH] handle unexpected mime type errors --- .../window/tab/item/page/client/driver/gemini.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app/browser/window/tab/item/page/client/driver/gemini.rs b/src/app/browser/window/tab/item/page/client/driver/gemini.rs index b9a7d087..61b6ae86 100644 --- a/src/app/browser/window/tab/item/page/client/driver/gemini.rs +++ b/src/app/browser/window/tab/item/page/client/driver/gemini.rs @@ -62,9 +62,8 @@ pub fn handle( }, })), // https://geminiprotocol.net/docs/protocol-specification.gmi#status-20 - Status::Success => { - let mime = response.meta.mime.unwrap(); // @TODO handle - match mime.as_str() { + Status::Success => match response.meta.mime { + Some(mime) => match mime.as_str() { "text/gemini" => Text::from_stream_async( response.connection.stream(), Priority::DEFAULT, @@ -91,8 +90,11 @@ pub fn handle( mime: mime.to_string(), message: format!("Content type `{mime}` yet not supported"), })), - } // @TODO handle `None` - } + }, + None => callback(Response::Failure(Failure::Error { + message: "MIME type not found".to_string(), + })), + }, // https://geminiprotocol.net/docs/protocol-specification.gmi#status-30-temporary-redirection Status::Redirect => callback(match response.meta.data { Some(data) => match Uri::parse_relative(&base, data.as_str(), UriFlags::NONE) {