fix some issu

This commit is contained in:
2026-08-26 21:47:09 +03:30
parent 74cc50149f
commit 40b185187c
14 changed files with 179 additions and 72 deletions
+24 -5
View File
@@ -76,12 +76,14 @@ class Controller extends BaseController
}
/**
* گزینه‌های Guzzle/cURL — فقط وقتی افزونه curl و ثابت‌ها موجود باشند.
* Direct connect (no local VPN/proxy) + IPv4 + HTTP/1.1:
* dead 127.0.0.1 proxies, broken AAAA, and flaky HTTP/2 cause
* "Connection refused" / stream errors while browsers still work.
*
* @param array<int, mixed> $curlOptions
* @return array<string, array<int, mixed>>
* @param array<int, mixed> $curlOptions
* @return array<string, mixed>
*/
public static function httpClientOptions(array $curlOptions = []): array
public static function httpClientOptions(array $curlOptions = [], ?float $timeout = null): array
{
$curl = $curlOptions;
@@ -92,7 +94,24 @@ class Controller extends BaseController
}
}
return $curl === [] ? [] : ['curl' => $curl];
if (defined('CURLOPT_HTTP_VERSION') && defined('CURL_HTTP_VERSION_1_1')) {
$verOpt = (int) constant('CURLOPT_HTTP_VERSION');
if (! array_key_exists($verOpt, $curl)) {
$curl[$verOpt] = (int) constant('CURL_HTTP_VERSION_1_1');
}
}
$options = ['proxy' => false];
if ($timeout !== null) {
$options['connect_timeout'] = min(5.0, max(2.0, (float) $timeout));
}
if ($curl !== []) {
$options['curl'] = $curl;
}
return $options;
}
public static function Send($to , $msg, $is_customer = true)