mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
use high-level implementation method, handle error case
This commit is contained in:
parent
02dfa3cb3c
commit
48aa19d1e4
1 changed files with 171 additions and 163 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use super::{Feature, Page};
|
||||
use ggemini::client::connection::response::{Input, Redirect, Success};
|
||||
use ggemini::client::connection::response::{Input, Redirect};
|
||||
use ggemini::{
|
||||
client::{Client, Request, Response},
|
||||
gio::{file_output_stream, memory_input_stream},
|
||||
|
|
@ -307,8 +307,7 @@ fn handle(
|
|||
}
|
||||
redirects.replace(0); // reset
|
||||
},
|
||||
_ => match success {
|
||||
Success::Default(default) => match default.header.mime() {
|
||||
_ => match success.mime() {
|
||||
Ok(mime) => match mime.as_str() {
|
||||
"text/gemini" | "text/plain" => memory_input_stream::from_stream_async(
|
||||
connection.stream(),
|
||||
|
|
@ -334,7 +333,7 @@ fn handle(
|
|||
i
|
||||
.add_event("Parsing".to_string())
|
||||
.set_mime(Some(mime))
|
||||
.set_size(Some(default.header.len()), Some(data.len()));
|
||||
.set_size(Some(success.as_header_bytes().len()), Some(data.len()));
|
||||
let w = if matches!(*feature, Feature::Source) {
|
||||
page.content.to_text_source(data)
|
||||
} else {
|
||||
|
|
@ -494,7 +493,16 @@ fn handle(
|
|||
page.navigation.request.update_secondary_icon(&i)
|
||||
},
|
||||
},
|
||||
Err(_) => todo!()
|
||||
Err(e) => {
|
||||
let s = page.content.to_status_failure();
|
||||
s.set_description(Some(&e.to_string()));
|
||||
page.set_progress(0.0);
|
||||
page.set_title(&s.title());
|
||||
if is_snap_history {
|
||||
page.snap_history();
|
||||
}
|
||||
redirects.replace(0); // reset
|
||||
update_page_info(&page, EVENT_COMPLETED);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue