update request api

This commit is contained in:
yggverse 2025-01-22 15:14:59 +02:00
parent 52141f3dca
commit 5e52e74870
6 changed files with 37 additions and 78 deletions

View file

@ -7,10 +7,10 @@ use ggemini::client::connection::Request;
fn client_connection_request_gemini() {
const REQUEST: &str = "gemini://geminiprotocol.net/";
assert_eq!(
std::str::from_utf8(
&Request::gemini(Uri::parse(REQUEST, UriFlags::NONE).unwrap()).to_bytes()
)
.unwrap(),
Request::Gemini(ggemini::client::connection::Gemini {
uri: Uri::parse(REQUEST, UriFlags::NONE).unwrap()
})
.header(),
format!("{REQUEST}\r\n")
);
}
@ -20,23 +20,21 @@ fn client_connection_request_titan() {
const DATA: &[u8] = &[1, 2, 3];
const MIME: &str = "plain/text";
const TOKEN: &str = "token";
const ARGUMENT: &str = "argument";
const REQUEST: &str = "titan://geminiprotocol.net/raw/Test";
assert_eq!(
std::str::from_utf8(
&Request::titan(
Uri::parse(&format!("{REQUEST}?argument={ARGUMENT}"), UriFlags::NONE).unwrap(),
DATA.to_vec(),
Some(MIME.to_string()),
Some(TOKEN.to_string()),
Request::Titan(ggemini::client::connection::Titan {
uri: Uri::parse(
"titan://geminiprotocol.net/raw/Test?key=value",
UriFlags::NONE
)
.to_bytes()
)
.unwrap(),
.unwrap(),
data: Bytes::from(DATA),
mime: Some(MIME.to_string()),
token: Some(TOKEN.to_string())
})
.header(),
format!(
"{REQUEST};size={};mime={MIME};token={TOKEN}?argument={ARGUMENT}\r\n{}",
"titan://geminiprotocol.net/raw/Test;size={};mime={MIME};token={TOKEN}?key=value\r\n",
DATA.len(),
std::str::from_utf8(DATA).unwrap(),
)
);
}