Browse Source

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

master
yggverse 5 days ago
parent
commit
69142fa60f
  1. 6
      README.md
  2. 17
      src/app/browser/window/tab/item/page.rs

6
README.md

@ -59,10 +59,10 @@ GTK 4 / Libadwaita client written in Rust @@ -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

17
src/app/browser/window/tab/item/page.rs

@ -859,7 +859,11 @@ impl Page { @@ -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 { @@ -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 { @@ -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)

Loading…
Cancel
Save