当前路径:vendor/guzzlehttp/guzzle/src/Utils.php <?php namespace GuzzleHttp; use GuzzleHttp\Exception\InvalidArgumentException; use Psr\Http\Message\UriInterface; use Symfony\Polyfill\Intl\Idn\Idn; final class Utils { /** * Wrapper for the hrtime() or microtime() functions * (depending on the PHP version, one of the two is used) * * @return float|mixed UNIX timestamp * * @internal */ public static function currentTime() { return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true); } /** * @param int $options * * @return UriInterface * @throws InvalidArgumentException * * @internal */ public static function idnUriConvert(UriInterface $uri, $options = 0) { if ($uri->getHost()) { $asciiHost = self::idnToAsci($uri->getHost(), $options, $info); if ($asciiHost === false) { $errorBitSet = isset($info['errors']) ? $info['errors'] : 0; $errorConstants = array_filter(array_keys(get_defined_constants()), function ($name) { return substr($name, 0, 11) === 'IDNA_ERROR_'; }); $errors = []; foreach ($errorConstants as $errorConstant) { if ($errorBitSet & constant($errorConstant)) { $errors[] = $errorConstant; } } $errorMessage = 'IDN conversion failed'; if ($errors) { $errorMessage .= ' (errors: ' . implode(', ', $errors) . ')'; } throw new InvalidArgumentException($errorMessage); } else { if ($uri->getHost() !== $asciiHost) { // Replace URI only if the ASCII version is different $uri = $uri->withHost($asciiHost); } } } return $uri; } /** * @param string $domain * @param int $options * @param array $info * * @return string|false */ private static function idnToAsci($domain, $options, &$info = []) { if (\preg_match('%^[ -~]+$%', $domain) === 1) { return $domain; } if (\extension_loaded('intl') && defined('INTL_IDNA_VARIANT_UTS46')) { return \idn_to_ascii($domain, $options, INTL_IDNA_VARIANT_UTS46, $info); } /* * The Idn class is marked as @internal. Verify that class and method exists. */ if (method_exists(Idn::class, 'idn_to_ascii')) { return Idn::idn_to_ascii($domain, $options, Idn::INTL_IDNA_VARIANT_UTS46, $info); } throw new \RuntimeException('ext-intl or symfony/polyfill-intl-idn not loaded or too old'); } }
相关源码
- 可旋转的彩色立方体C#源代码2021-10-29
- 在线考试系统2021-10-15
- EduSoho开源网校系统源码2019-06-27
- 仿拼多多小程序商城源码2019-06-06
- PHP5网站运行监测系统源码2017-04-14
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号