mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
add max redirects config
This commit is contained in:
parent
742b441fb6
commit
26b4095eb8
3 changed files with 46 additions and 14 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
"follow":
|
"follow":
|
||||||
{
|
{
|
||||||
"enabled":true,
|
"enabled":true,
|
||||||
|
"max":5,
|
||||||
"code":
|
"code":
|
||||||
[
|
[
|
||||||
30,
|
30,
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,8 @@ class Page
|
||||||
|
|
||||||
private function _gemini(
|
private function _gemini(
|
||||||
string $url,
|
string $url,
|
||||||
int $code = 0
|
int $code = 0,
|
||||||
|
int $redirects = 0
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// Track response time
|
// Track response time
|
||||||
|
|
@ -423,23 +424,45 @@ class Page
|
||||||
);
|
);
|
||||||
|
|
||||||
// Process redirect
|
// Process redirect
|
||||||
if ($this->config->redirect->follow->enabled && in_array($response->getCode(), $this->config->redirect->follow->code))
|
if (in_array($response->getCode(), $this->config->redirect->follow->code))
|
||||||
{
|
{
|
||||||
$redirect = new \Yggverse\Net\Address(
|
if ($this->config->redirect->follow->enabled)
|
||||||
$url
|
{
|
||||||
);
|
if ($redirects > $this->config->redirect->follow->max)
|
||||||
|
{
|
||||||
|
$this->_yoda(
|
||||||
|
'yoda://redirect'
|
||||||
|
);
|
||||||
|
|
||||||
$redirect->setPath(
|
return;
|
||||||
$response->getMeta()
|
}
|
||||||
);
|
|
||||||
|
|
||||||
$this->open(
|
$redirect = new \Yggverse\Net\Address(
|
||||||
$redirect->get(),
|
$url
|
||||||
false,
|
);
|
||||||
$response->getCode()
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
$redirect->setPath(
|
||||||
|
$response->getMeta()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->open(
|
||||||
|
$redirect->get(),
|
||||||
|
false,
|
||||||
|
$response->getCode(),
|
||||||
|
$redirects + 1
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_yoda(
|
||||||
|
'yoda://redirect'
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->content->set_markup(
|
$this->content->set_markup(
|
||||||
|
|
|
||||||
8
src/Page/Redirect.gmi
Normal file
8
src/Page/Redirect.gmi
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Redirect issue
|
||||||
|
|
||||||
|
You see this message because page redirect could not be processed properly
|
||||||
|
|
||||||
|
## Possible reasons
|
||||||
|
|
||||||
|
* Max redirects reached
|
||||||
|
* Redirects disabled by settings
|
||||||
Loading…
Add table
Add a link
Reference in a new issue