diff --git a/src/Abstract/Model/Connection.php b/src/Abstract/Model/Connection.php index 176d75b6..c5ab19e0 100644 --- a/src/Abstract/Model/Connection.php +++ b/src/Abstract/Model/Connection.php @@ -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')) diff --git a/src/Interface/Model/Connection.php b/src/Interface/Model/Connection.php index 08a01313..f5e9907d 100644 --- a/src/Interface/Model/Connection.php +++ b/src/Interface/Model/Connection.php @@ -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( diff --git a/src/Model/Connection/Gemini.php b/src/Model/Connection/Gemini.php index bf4a5c8c..1f48e044 100644 --- a/src/Model/Connection/Gemini.php +++ b/src/Model/Connection/Gemini.php @@ -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