add 61, 62 status codes handle, show server-side message on failure

This commit is contained in:
yggverse 2024-11-21 19:48:31 +02:00
parent a0566fba30
commit 69142fa60f
2 changed files with 17 additions and 6 deletions

View File

@ -59,10 +59,10 @@ GTK 4 / Libadwaita client written in Rust
* [ ] `52` Gone
* [ ] `53` Proxy request refused
* [ ] `59` Bad request
* [ ] Client certificates
* [x] Client certificates
* [x] `60` Certificate requested
* [ ] `61` Certificate not authorized
* [ ] `62` Certificate not valid
* [x] `61` Certificate not authorized
* [x] `62` Certificate not valid
* [x] [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) (by [ggemtext](https://github.com/YGGverse/ggemtext))
* [x] Code (inline/multiline)
* [x] Inline

View File

@ -859,7 +859,11 @@ impl Page {
update.activate(Some(&id));
},
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-60
gemini::client::response::meta::Status::CertificateRequest => {
gemini::client::response::meta::Status::CertificateRequest |
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-61
gemini::client::response::meta::Status::CertificateUnauthorized |
// https://geminiprotocol.net/docs/protocol-specification.gmi#status-62
gemini::client::response::meta::Status::CertificateInvalid => {
// Define common data
let status = Status::Success;
let title = "Identity";
@ -867,7 +871,11 @@ impl Page {
// Update widget
content
.to_status_identity()
.set_title(title);
.set_title(title)
.set_description(match response.data() {
Some(data) => Some(data.value().as_str()),
None => None,
});
// Update meta
meta.set_status(status)
@ -885,7 +893,10 @@ impl Page {
content
.to_status_failure()
.set_title(title)
.set_description(Some("Status code yet not supported"));
.set_description(Some(match response.data() {
Some(data) => data.value().as_str(),
None => "Status code yet not supported", // @TODO
}));
// Update meta
meta.set_status(status)