Centralize HTTP limits
This commit is contained in:
24
http-limits.php
Normal file
24
http-limits.php
Normal 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'
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user