mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
make MIME type argument optional
This commit is contained in:
parent
ce5d3ac4d2
commit
f4c9b73925
2 changed files with 8 additions and 5 deletions
|
|
@ -24,12 +24,12 @@ impl Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new `Self` for [Titan protocol](gemini://transjovian.org/titan/page/The%20Titan%20Specification)
|
/// 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 {
|
Self::Titan(Titan {
|
||||||
uri,
|
uri,
|
||||||
|
data,
|
||||||
mime,
|
mime,
|
||||||
token,
|
token,
|
||||||
data,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ use glib::{Bytes, Uri};
|
||||||
/// [Titan](gemini://transjovian.org/titan/page/The%20Titan%20Specification) protocol enum object for `Request`
|
/// [Titan](gemini://transjovian.org/titan/page/The%20Titan%20Specification) protocol enum object for `Request`
|
||||||
pub struct Titan {
|
pub struct Titan {
|
||||||
pub uri: Uri,
|
pub uri: Uri,
|
||||||
pub mime: String,
|
|
||||||
pub token: Option<String>,
|
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
|
pub mime: Option<String>,
|
||||||
|
pub token: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Titan {
|
impl Titan {
|
||||||
|
|
@ -17,7 +17,10 @@ impl Titan {
|
||||||
let size = self.data.len();
|
let size = self.data.len();
|
||||||
|
|
||||||
// Build header
|
// 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 {
|
if let Some(ref token) = self.token {
|
||||||
header.push_str(&format!(";token={token}"));
|
header.push_str(&format!(";token={token}"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue