Centralize HTTP limits

This commit is contained in:
Troy Grunt
2026-02-15 14:57:05 +01:00
parent 923dafecc9
commit cb115bac40
5 changed files with 75 additions and 18 deletions

24
http-limits.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
if (!defined('LIB_HTTP_TIMEOUT')) {
define('LIB_HTTP_TIMEOUT', 8);
}
if (!defined('LIB_HTTP_MAX_REDIRECTS')) {
define('LIB_HTTP_MAX_REDIRECTS', 4);
}
if (!defined('LIB_HTTP_MAX_BYTES')) {
define('LIB_HTTP_MAX_BYTES', 5 * 1024 * 1024);
}
function httpLimits(): array {
return [
'timeout' => max(1, (int) LIB_HTTP_TIMEOUT),
'max_redirects' => max(0, (int) LIB_HTTP_MAX_REDIRECTS),
'max_bytes' => max(1, (int) LIB_HTTP_MAX_BYTES),
'user_agent' => 'star-citizen.de-linkbot/1.0'
];
}