From 48621156bf353162212a5e56f2d90c7c768ee99f Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 8 Jul 2024 00:53:21 +0300 Subject: [PATCH] update API for status code 10 --- src/Entity/Browser/Container/Tab/Page/Content.php | 9 ++++++--- .../Browser/Container/Tab/Page/Response.php | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Entity/Browser/Container/Tab/Page/Content.php b/src/Entity/Browser/Container/Tab/Page/Content.php index 66f9ffb0..828f3976 100644 --- a/src/Entity/Browser/Container/Tab/Page/Content.php +++ b/src/Entity/Browser/Container/Tab/Page/Content.php @@ -185,14 +185,15 @@ class Content $request->getResponse() ); - // Process codes + // Route status codes + // https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes switch ($response->getCode()) { case 10: // response expected $this->page->title->setValue( $address->getHost(), - sprintf( + $response->getMeta() ? $response->getMeta() : sprintf( 'response expected (code %d)', intval( $response->getCode() @@ -200,7 +201,9 @@ class Content ) ); - $this->page->response->show(); + $this->page->response->show( + $response->getMeta() // pass to placeholder + ); break; diff --git a/src/Entity/Browser/Container/Tab/Page/Response.php b/src/Entity/Browser/Container/Tab/Page/Response.php index 1a607309..3fca2b88 100644 --- a/src/Entity/Browser/Container/Tab/Page/Response.php +++ b/src/Entity/Browser/Container/Tab/Page/Response.php @@ -79,13 +79,26 @@ class Response $this->hide(); } - public function show(): void + public function show( + ?string $placeholder = null + ): void { + if ($placeholder) + { + $this->query->setPlaceholder( + $placeholder + ); + } + $this->gtk->show(); } public function hide(): void { + $this->query->setPlaceholder( + null + ); + $this->gtk->hide(); }