init gemini authorization codes 60-62 support

This commit is contained in:
yggverse 2024-08-03 02:54:25 +03:00
parent 3949c9ee27
commit 49b21b38d0
3 changed files with 146 additions and 0 deletions

View file

@ -63,6 +63,11 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
'request',
// 1 Mb default
);
$this->_pool->init(
'auth',
1
);
}
public function isCompleted(): bool
@ -223,6 +228,27 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
);
}
public function getAuth(): bool
{
return boolval(
$this->_pool->get(
'auth'
)
);
}
public function setAuth(
bool $auth
): void
{
$this->_pool->set(
'auth',
strval(
$auth
)
);
}
public function getLength(): ?int
{
if ($data = $this->_pool->get('data'))

View file

@ -74,6 +74,12 @@ interface Connection
public function unsetRequest(): void;
public function getAuth(): bool;
public function setAuth(
bool $auth
): void;
public function getLength(): ?int;
public function getCache(

View file

@ -148,6 +148,120 @@ class Gemini
break;
case 60: // authorization certificate required
$this->_connection->setAuth(
true
);
$this->_connection->setTitle(
_('Authorization')
);
$this->_connection->setSubtitle(
$address->getHost()
);
$this->_connection->setTooltip(
sprintf(
'Authorization required (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setData(
sprintf(
'Authorization required (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setMime(
Filesystem::MIME_TEXT_GEMINI
);
break;
case 61: // certificate not authorized
$this->_connection->setAuth(
true
);
$this->_connection->setTitle(
_('Oops!')
);
$this->_connection->setSubtitle(
$address->getHost()
);
$this->_connection->setTooltip(
sprintf(
'Authorization certificate not authorized (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setData(
sprintf(
'Authorization certificate not authorized (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setMime(
Filesystem::MIME_TEXT_GEMINI
);
break;
case 62: // certificate not valid
$this->_connection->setAuth(
true
);
$this->_connection->setTitle(
_('Oops!')
);
$this->_connection->setSubtitle(
$address->getHost()
);
$this->_connection->setTooltip(
sprintf(
'Authorization certificate not valid (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setData(
sprintf(
'Authorization certificate not valid (code: %d)',
intval(
$response->getCode()
)
)
);
$this->_connection->setMime(
Filesystem::MIME_TEXT_GEMINI
);
break;
default:
// Try cache