make MIME type argument optional

This commit is contained in:
yggverse 2025-01-13 23:41:12 +02:00
parent ce5d3ac4d2
commit f4c9b73925
2 changed files with 8 additions and 5 deletions

View file

@ -24,12 +24,12 @@ impl Request {
}
/// Create new `Self` for [Titan protocol](gemini://transjovian.org/titan/page/The%20Titan%20Specification)
pub fn titan(uri: Uri, mime: String, token: Option<String>, data: Vec<u8>) -> Self {
pub fn titan(uri: Uri, data: Vec<u8>, mime: Option<String>, token: Option<String>) -> Self {
Self::Titan(Titan {
uri,
data,
mime,
token,
data,
})
}

View file

@ -3,9 +3,9 @@ use glib::{Bytes, Uri};
/// [Titan](gemini://transjovian.org/titan/page/The%20Titan%20Specification) protocol enum object for `Request`
pub struct Titan {
pub uri: Uri,
pub mime: String,
pub token: Option<String>,
pub data: Vec<u8>,
pub mime: Option<String>,
pub token: Option<String>,
}
impl Titan {
@ -17,7 +17,10 @@ impl Titan {
let size = self.data.len();
// Build header
let mut header = format!("{};size={size};mime={}", self.uri, self.mime);
let mut header = format!("{};size={size}", self.uri);
if let Some(ref mime) = self.mime {
header.push_str(&format!(";mime={mime}"));
}
if let Some(ref token) = self.token {
header.push_str(&format!(";token={token}"));
}