You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
644 B

2 years ago
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jaeger <JaegerCode@gmail.com>
  5. * Date: 18/12/10
  6. * Time: 下午4:04
  7. */
  8. require __DIR__.'/../vendor/autoload.php';
  9. use Jaeger\GHttp;
  10. $urls = [
  11. 'http://httpbin.org/get?name=php',
  12. 'http://httpbin.org/get?name=go',
  13. 'http://httpbin.org/get?name=c#',
  14. 'http://httpbin.org/get?name=java'
  15. ];
  16. GHttp::multiRequest($urls)->withHeaders([
  17. 'X-Powered-By' => 'Jaeger'
  18. ])->withOptions([
  19. 'timeout' => 10
  20. ])->concurrency(2)->success(function($response,$index){
  21. print_r((String)$response->getBody());
  22. print_r($index);
  23. })->error(function($reason,$index){
  24. print_r($reason);
  25. })->get();