diff --git a/examples/get_with_callable_retry.php b/examples/get_with_callable_retry.php new file mode 100644 index 0000000..4d23eb3 --- /dev/null +++ b/examples/get_with_callable_retry.php @@ -0,0 +1,19 @@ +setRetry(function ($instance) { + return $instance->retries < 3; +}); +$curl->get('https://httpbin.org/status/503'); + +if ($curl->error) { + echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n"; + echo 'attempts: ' . $curl->attempts . "\n"; + echo 'retries: ' . $curl->retries . "\n"; +} else { + echo 'Response:' . "\n"; + var_dump($curl->response); +} diff --git a/examples/get_with_retry.php b/examples/get_with_retry.php new file mode 100644 index 0000000..38f0d54 --- /dev/null +++ b/examples/get_with_retry.php @@ -0,0 +1,19 @@ +setRetry($max_retries); +$curl->get('https://httpbin.org/status/503'); + +if ($curl->error) { + echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n"; + echo 'attempts: ' . $curl->attempts . "\n"; + echo 'retries: ' . $curl->retries . "\n"; +} else { + echo 'Response:' . "\n"; + var_dump($curl->response); +} diff --git a/examples/multi_curl_get_with_callable_retry.php b/examples/multi_curl_get_with_callable_retry.php new file mode 100644 index 0000000..8dc923a --- /dev/null +++ b/examples/multi_curl_get_with_callable_retry.php @@ -0,0 +1,20 @@ +setRetry(function ($instance) { + return $instance->retries < 3; +}); +$multi_curl->complete(function ($instance) { + echo 'call to "' . $instance->url . '" completed.' . "\n"; + echo 'attempts: ' . $instance->attempts . "\n"; + echo 'retries: ' . $instance->retries . "\n"; +}); + +$multi_curl->addGet('https://httpbin.org/status/503?a'); +$multi_curl->addGet('https://httpbin.org/status/503?b'); +$multi_curl->addGet('https://httpbin.org/status/503?c'); + +$multi_curl->start(); diff --git a/examples/multi_curl_get_with_retry.php b/examples/multi_curl_get_with_retry.php new file mode 100644 index 0000000..9b66365 --- /dev/null +++ b/examples/multi_curl_get_with_retry.php @@ -0,0 +1,20 @@ +setRetry($max_retries); +$multi_curl->complete(function ($instance) { + echo 'call to "' . $instance->url . '" completed.' . "\n"; + echo 'attempts: ' . $instance->attempts . "\n"; + echo 'retries: ' . $instance->retries . "\n"; +}); + +$multi_curl->addGet('https://httpbin.org/status/503?a'); +$multi_curl->addGet('https://httpbin.org/status/503?b'); +$multi_curl->addGet('https://httpbin.org/status/503?c'); + +$multi_curl->start();