mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-27 11:34:14 +00:00
draft redirection features
This commit is contained in:
parent
c97648539f
commit
380ade924f
@ -302,11 +302,12 @@ impl Page {
|
||||
}
|
||||
},
|
||||
Response::Redirect {
|
||||
referrer,
|
||||
request,
|
||||
is_foreground,
|
||||
} => {
|
||||
// Some protocols may support foreground redirects
|
||||
// for example status code `31` in Gemini
|
||||
// Some clients may support foreground redirects
|
||||
// e.g. status code `31` in Gemini protocol
|
||||
if is_foreground {
|
||||
navigation
|
||||
.request
|
||||
|
@ -4,7 +4,7 @@ use super::{
|
||||
};
|
||||
use gtk::{
|
||||
gio::Cancellable,
|
||||
glib::{Priority, Uri},
|
||||
glib::{Priority, Uri, UriFlags},
|
||||
};
|
||||
use std::rc::Rc;
|
||||
|
||||
@ -94,15 +94,37 @@ pub fn handle(
|
||||
} // @TODO handle `None`
|
||||
}
|
||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-30-temporary-redirection
|
||||
Status::Redirect => callback(Response::Redirect {
|
||||
request: base,
|
||||
is_foreground: false,
|
||||
}),
|
||||
Status::Redirect => callback(match response.meta.data {
|
||||
Some(data) => match Uri::parse_relative(&base, &data.value, UriFlags::NONE) {
|
||||
Ok(request) => Response::Redirect {
|
||||
referrer: base,
|
||||
request,
|
||||
is_foreground: false,
|
||||
},
|
||||
Err(e) => Response::Failure(Failure::Error {
|
||||
message: format!("Could not parse target address: {}", e.message()),
|
||||
}),
|
||||
},
|
||||
None => Response::Failure(Failure::Error {
|
||||
message: "Target address not found".to_string(),
|
||||
}),
|
||||
}), // @TODO validate redirect count
|
||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-31-permanent-redirection
|
||||
Status::PermanentRedirect => callback(Response::Redirect {
|
||||
request: base,
|
||||
is_foreground: true,
|
||||
}),
|
||||
Status::PermanentRedirect => callback(match response.meta.data {
|
||||
Some(data) => match Uri::parse_relative(&base, &data.value, UriFlags::NONE) {
|
||||
Ok(request) => Response::Redirect {
|
||||
referrer: base,
|
||||
request,
|
||||
is_foreground: true,
|
||||
},
|
||||
Err(e) => Response::Failure(Failure::Error {
|
||||
message: format!("Could not parse target address: {}", e.message()),
|
||||
}),
|
||||
},
|
||||
None => Response::Failure(Failure::Error {
|
||||
message: "Target address not found".to_string(),
|
||||
}),
|
||||
}), // @TODO validate redirect count
|
||||
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
|
||||
Status::CertificateRequest => callback(Response::Certificate(Certificate::Request {
|
||||
title: match response.meta.data {
|
||||
|
@ -29,8 +29,9 @@ pub enum Response {
|
||||
},
|
||||
Input(Input),
|
||||
Redirect {
|
||||
request: Uri,
|
||||
is_foreground: bool,
|
||||
referrer: Uri,
|
||||
request: Uri,
|
||||
},
|
||||
Stream {
|
||||
base: Uri,
|
||||
|
Loading…
x
Reference in New Issue
Block a user