connect --follow argument to limit redirections count; set 5 by default (protocol specification)

This commit is contained in:
yggverse 2025-11-11 13:14:36 +02:00
parent 3395d4fa17
commit d9db0ad7e9
2 changed files with 4 additions and 3 deletions

View file

@ -181,7 +181,7 @@ class Cli
// Crawl next address... // Crawl next address...
if ($this->option->crawl) if ($this->option->crawl)
{ {
if ($this->redirects <= 5) // @TODO optional (currently protocol spec) if ($this->redirects <= $this->option->follow)
{ {
// Validate redirection target location // Validate redirection target location
if (filter_var($response->getMeta(), FILTER_VALIDATE_URL)) // @TODO resolve relative locations if (filter_var($response->getMeta(), FILTER_VALIDATE_URL)) // @TODO resolve relative locations
@ -216,7 +216,8 @@ class Cli
print( print(
Message::red( Message::red(
sprintf( sprintf(
_("\tredirection count reached, continue next address in queue"), _("\tredirection limit (%d) reached, continue next address in queue"),
$this->option->follow
) )
) )
); );

View file

@ -10,7 +10,7 @@ class Option
public bool $crawl = false; public bool $crawl = false;
public int $delay = 1; public int $delay = 1;
public bool $external = false; public bool $external = false;
public int $follow = 0; public int $follow = 5;
public bool $help = false; public bool $help = false;
public string $index = 'index.gmi'; public string $index = 'index.gmi';
public bool $keep = false; public bool $keep = false;