LibUrl.php 909 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Qii\Library;
  3. /**
  4. * A parallel HTTP client written in pure PHP
  5. *
  6. * This file just for non-composer user, require this file directly.
  7. *
  8. * @author hightman <hightman@twomice.net>
  9. * @link http://hightman.cn
  10. * @copyright Copyright (c) 2015 Twomice Studio.
  11. */
  12. \Qii\Autoloader\Psr4::getInstance()
  13. ->setUseNamespaces([
  14. ['Curl', true],
  15. ])
  16. ->addNamespaces([
  17. ['Curl', Qii_DIR . DS .'Library'. DS . 'Third'. DS .'Curl'],
  18. ]);
  19. use Curl\Curl;
  20. class LibUrl extends Curl
  21. {
  22. /**
  23. * 设置超时时间, 解决毫秒问题
  24. *
  25. * @param $seconds
  26. */
  27. public function setTimeout($seconds)
  28. {
  29. if($seconds < 1)
  30. {
  31. $this->setOpt(CURLOPT_TIMEOUT_MS, intval($seconds * 1000));
  32. $this->setOpt(CURLOPT_NOSIGNAL, 1);
  33. }
  34. $this->setOpt(CURLOPT_TIMEOUT, $seconds);
  35. }
  36. }