Browse Source

update API for status code 10

PHP-GTK3
yggverse 4 months ago
parent
commit
48621156bf
  1. 9
      src/Entity/Browser/Container/Tab/Page/Content.php
  2. 15
      src/Entity/Browser/Container/Tab/Page/Response.php

9
src/Entity/Browser/Container/Tab/Page/Content.php

@ -185,14 +185,15 @@ class Content @@ -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 @@ -200,7 +201,9 @@ class Content
)
);
$this->page->response->show();
$this->page->response->show(
$response->getMeta() // pass to placeholder
);
break;

15
src/Entity/Browser/Container/Tab/Page/Response.php

@ -79,13 +79,26 @@ class Response @@ -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();
}

Loading…
Cancel
Save