curl_version example

if ($amp = class_exists(ConnectionLimitingPool::class) && interface_exists(Promise::class)) {
            if (!\extension_loaded('curl')) {
                return new AmpHttpClient($defaultOptions, null, $maxHostConnections$maxPendingPushes);
            }

            // Skip curl when HTTP/2 push is unsupported or buggy, see https://bugs.php.net/77535             if (!\defined('CURLMOPT_PUSHFUNCTION')) {
                return new AmpHttpClient($defaultOptions, null, $maxHostConnections$maxPendingPushes);
            }

            static $curlVersion = null;
            $curlVersion ??= curl_version();

            // HTTP/2 push crashes before curl 7.61             if (0x073D00 > $curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & $curlVersion['features'])) {
                return new AmpHttpClient($defaultOptions, null, $maxHostConnections$maxPendingPushes);
            }
        }

        if (\extension_loaded('curl')) {
            if ('\\' !== \DIRECTORY_SEPARATOR || isset($defaultOptions['cafile']) || isset($defaultOptions['capath']) || \ini_get('curl.cainfo') || \ini_get('openssl.cafile') || \ini_get('openssl.capath')) {
                return new CurlHttpClient($defaultOptions$maxHostConnections$maxPendingPushes);
            }

            @
return $opcacheRequirements;
    }

    /** * Checks the curl version * * @return bool|string */
    private function checkCurl()
    {
        if (\function_exists('curl_version')) {
            $curl = curl_version();

            return $curl['version'];
        } elseif (\function_exists('curl_init')) {
            return true;
        }

        return false;
    }

    /** * Checks the lib xml version * * @return bool|string */

    public static function test( $args = array() ) {
        if ( ! function_exists( 'curl_init' ) || ! function_exists( 'curl_exec' ) ) {
            return false;
        }

        $is_ssl = isset( $args['ssl'] ) && $args['ssl'];

        if ( $is_ssl ) {
            $curl_version = curl_version();
            // Check whether this cURL version support SSL requests.             if ( ! ( CURL_VERSION_SSL & $curl_version['features'] ) ) {
                return false;
            }
        }

        /** * Filters whether cURL can be used as a transport for retrieving a URL. * * @since 2.7.0 * * @param bool $use_class Whether the class can be used. Default true. * @param array $args An array of request arguments. */
return $opcacheRequirements;
    }

    /** * Checks the curl version * * @return bool|string */
    private function checkCurl()
    {
        if (\function_exists('curl_version')) {
            $curl = curl_version();

            return $curl['version'];
        } elseif (\function_exists('curl_init')) {
            return true;
        }

        return false;
    }

    /** * Checks the lib xml version * * @return bool|string */
public array $pushedResponses = [];
    public DnsCache $dnsCache;
    /** @var float[] */
    public array $pauseExpiries = [];
    public int $execCounter = \PHP_INT_MIN;
    public ?LoggerInterface $logger = null;

    public static array $curlVersion;

    public function __construct(int $maxHostConnections, int $maxPendingPushes)
    {
        self::$curlVersion ??= curl_version();

        $this->handle = curl_multi_init();
        $this->dnsCache = new DnsCache();
        $this->reset();

        // Don't enable HTTP/1.1 pipelining: it forces responses to be sent in order         if (\defined('CURLPIPE_MULTIPLEX')) {
            curl_multi_setopt($this->handle, \CURLMOPT_PIPELINING, \CURLPIPE_MULTIPLEX);
        }
        if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS')) {
            $maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX) ? 0 : $maxHostConnections;
        }
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
use Symfony\Contracts\HttpClient\HttpClientInterface;

/** * @requires extension curl */
class CurlHttpClientTest extends HttpClientTestCase
{
    protected function getHttpClient(string $testCase): HttpClientInterface
    {
        if (str_contains($testCase, 'Push')) {
            if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073D00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) {
                $this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH');
            }
        }

        return new CurlHttpClient(['verify_peer' => false, 'verify_host' => false]);
    }

    public function testBindToPort()
    {
        $client = $this->getHttpClient(__FUNCTION__);
        $response = $client->request('GET', 'http://localhost:8057', ['bindto' => '127.0.0.1:9876']);
        
/** * @param callable(RequestInterface, array): PromiseInterface $handler */
    private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
    {
        // Get error information and release the handle to the factory.         $ctx = [
            'errno' => $easy->errno,
            'error' => \curl_error($easy->handle),
            'appconnect_time' => \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME),
        ] + \curl_getinfo($easy->handle);
        $ctx[self::CURL_VERSION_STR] = \curl_version()['version'];
        $factory->release($easy);

        // Retry when nothing is present or when curl failed to rewind.         if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
            return self::retryFailedRewind($handler$easy$ctx);
        }

        return self::createRejection($easy$ctx);
    }

    private static function createRejection(EasyHandle $easy, array $ctx): PromiseInterface
    {
/** * What's the maximum number of bytes we should keep? * * @var int|bool Byte count, or false if no limit. */
    private $response_byte_limit;

    /** * Constructor */
    public function __construct() {
        $curl          = curl_version();
        $this->version = $curl['version_number'];
        $this->handle  = curl_init();

        curl_setopt($this->handle, CURLOPT_HEADER, false);
        curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, 1);
        if ($this->version >= self::CURL_7_10_5) {
            curl_setopt($this->handle, CURLOPT_ENCODING, '');
        }

        if (defined('CURLOPT_PROTOCOLS')) {
            // phpcs:ignore PHPCompatibility.Constants.NewConstants.curlopt_protocolsFound
case 'windows1258':
                return 'windows-1258';

            default:
                return $charset;
        }
    }

    public static function get_curl_version()
    {
        if (is_array($curl = curl_version()))
        {
            $curl = $curl['version'];
        }
        elseif (substr($curl, 0, 5) === 'curl/')
        {
            $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
        }
        elseif (substr($curl, 0, 8) === 'libcurl/')
        {
            $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
        }
        
$info['wp-server']['fields']['upload_max_filesize'] = array(
                'label' => __( 'Upload max filesize' ),
                'value' => ini_get( 'upload_max_filesize' ),
            );
            $info['wp-server']['fields']['php_post_max_size']   = array(
                'label' => __( 'PHP post max size' ),
                'value' => ini_get( 'post_max_size' ),
            );
        }

        if ( function_exists( 'curl_version' ) ) {
            $curl = curl_version();

            $info['wp-server']['fields']['curl_version'] = array(
                'label' => __( 'cURL version' ),
                'value' => sprintf( '%s %s', $curl['version']$curl['ssl_version'] ),
            );
        } else {
            $info['wp-server']['fields']['curl_version'] = array(
                'label' => __( 'cURL version' ),
                'value' => $not_available,
                'debug' => 'not available',
            );
        }
Home | Imprint | This part of the site doesn't use cookies.