diff --git a/src/main.rs b/src/main.rs index 735d1a7..977696a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -127,14 +127,10 @@ fn gemini( match storage::Item::from_url(gemini.url.as_str(), &argument.directory) { Ok(item) => { let mut read: usize = 0; - // send header - match stream.write_all( - &response::success::Default { - mime: item.mime, - data: &[], // init empty - } - .into_bytes(), - ) { + // create header packet + match stream + .write_all(&response::success::default::Meta { mime: item.mime }.into_bytes()) + { // chunk begin Ok(()) => loop { let mut data = vec![0; argument.chunk]; @@ -184,10 +180,10 @@ fn titan( stream: &mut TlsStream, ) { use titanite::*; - println!("[{}] [info] [{peer}] Request: {}", now(), titan.url); + println!("[{}] [info] [{peer}] Request: {}", now(), titan.meta.url); // require content type for application, // even MIME value is optional by Titan specification - let mime = match titan.mime { + let mime = match titan.meta.mime { Some(mime) => mime, None => { const MESSAGE: &str = "Content type is required"; @@ -240,7 +236,7 @@ fn titan( } // validate client-side limits (from header) - if total > titan.size { + if total > titan.meta.size { if let Err(e) = tmp.delete() { println!("[{}] [error] [{peer}] {e}", now()); } @@ -282,12 +278,12 @@ fn titan( } // just to make sure - if total > titan.size { + if total > titan.meta.size { panic!() } // all data received - if titan.size == total { + if titan.meta.size == total { return match tmp.commit() { Ok(pmt) => send( &response::redirect::Permanent {