|
static | execute ($ch, $retries=5, $closeAfterDone=true) |
| Executes a CURL request with optional retries and exception on failure. More...
|
|
Definition at line 14 of file Util.php.
◆ execute()
static Monolog\Handler\Curl\Util::execute |
( |
|
$ch, |
|
|
|
$retries = 5 , |
|
|
|
$closeAfterDone = true |
|
) |
| |
|
static |
Executes a CURL request with optional retries and exception on failure.
- Parameters
-
- Exceptions
-
RuntimeException
Definition at line 32 of file Util.php.
33 {
34 while ($retries--) {
35 if (curl_exec($ch) === false) {
36
37 if (false === in_array(curl_errno($ch), self::$retriableErrorCodes, true) || !$retries) {
38 if ($closeAfterDone) {
39 curl_close($ch);
40 }
41
42 throw new \RuntimeException(sprintf('Curl error (code %s): %s', curl_errno($ch), curl_error($ch)));
43 }
44
45 continue;
46 }
47
48 if ($closeAfterDone) {
49 curl_close($ch);
50 }
51 break;
52 }
53 }
Referenced by Monolog\Handler\MandrillHandler\send(), Monolog\Handler\LogglyHandler\send(), and Monolog\Handler\CubeHandler\writeHttp().
◆ $retriableErrorCodes
Monolog\Handler\Curl\Util::$retriableErrorCodes |
|
staticprivate |
Initial value:= array(
CURLE_COULDNT_RESOLVE_HOST,
CURLE_COULDNT_CONNECT,
CURLE_HTTP_NOT_FOUND,
CURLE_READ_ERROR,
CURLE_OPERATION_TIMEOUTED,
CURLE_HTTP_POST_ERROR,
CURLE_SSL_CONNECT_ERROR,
)
Definition at line 16 of file Util.php.
The documentation for this class was generated from the following file:
- Services/Logging/lib/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php