File tree Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Expand file tree Collapse file tree 4 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ require __DIR__ . '/../vendor/autoload.php ' ;
3+
4+ use \Curl \Curl ;
5+
6+ $ curl = new Curl ();
7+ $ curl ->setRetry (function ($ instance ) {
8+ return $ instance ->retries < 3 ;
9+ });
10+ $ curl ->get ('https://httpbin.org/status/503 ' );
11+
12+ if ($ curl ->error ) {
13+ echo 'Error: ' . $ curl ->errorCode . ': ' . $ curl ->errorMessage . "\n" ;
14+ echo 'attempts: ' . $ curl ->attempts . "\n" ;
15+ echo 'retries: ' . $ curl ->retries . "\n" ;
16+ } else {
17+ echo 'Response: ' . "\n" ;
18+ var_dump ($ curl ->response );
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ require __DIR__ . '/../vendor/autoload.php ' ;
3+
4+ use \Curl \Curl ;
5+
6+ $ max_retries = 3 ;
7+
8+ $ curl = new Curl ();
9+ $ curl ->setRetry ($ max_retries );
10+ $ curl ->get ('https://httpbin.org/status/503 ' );
11+
12+ if ($ curl ->error ) {
13+ echo 'Error: ' . $ curl ->errorCode . ': ' . $ curl ->errorMessage . "\n" ;
14+ echo 'attempts: ' . $ curl ->attempts . "\n" ;
15+ echo 'retries: ' . $ curl ->retries . "\n" ;
16+ } else {
17+ echo 'Response: ' . "\n" ;
18+ var_dump ($ curl ->response );
19+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ require __DIR__ . '/../vendor/autoload.php ' ;
3+
4+ use \Curl \MultiCurl ;
5+
6+ $ multi_curl = new MultiCurl ();
7+ $ multi_curl ->setRetry (function ($ instance ) {
8+ return $ instance ->retries < 3 ;
9+ });
10+ $ multi_curl ->complete (function ($ instance ) {
11+ echo 'call to " ' . $ instance ->url . '" completed. ' . "\n" ;
12+ echo 'attempts: ' . $ instance ->attempts . "\n" ;
13+ echo 'retries: ' . $ instance ->retries . "\n" ;
14+ });
15+
16+ $ multi_curl ->addGet ('https://httpbin.org/status/503?a ' );
17+ $ multi_curl ->addGet ('https://httpbin.org/status/503?b ' );
18+ $ multi_curl ->addGet ('https://httpbin.org/status/503?c ' );
19+
20+ $ multi_curl ->start ();
Original file line number Diff line number Diff line change 1+ <?php
2+ require __DIR__ . '/../vendor/autoload.php ' ;
3+
4+ use \Curl \MultiCurl ;
5+
6+ $ max_retries = 3 ;
7+
8+ $ multi_curl = new MultiCurl ();
9+ $ multi_curl ->setRetry ($ max_retries );
10+ $ multi_curl ->complete (function ($ instance ) {
11+ echo 'call to " ' . $ instance ->url . '" completed. ' . "\n" ;
12+ echo 'attempts: ' . $ instance ->attempts . "\n" ;
13+ echo 'retries: ' . $ instance ->retries . "\n" ;
14+ });
15+
16+ $ multi_curl ->addGet ('https://httpbin.org/status/503?a ' );
17+ $ multi_curl ->addGet ('https://httpbin.org/status/503?b ' );
18+ $ multi_curl ->addGet ('https://httpbin.org/status/503?c ' );
19+
20+ $ multi_curl ->start ();
You can’t perform that action at this time.
0 commit comments