shouldBuffer example

/** * @param array $defaultOptions Default requests' options * @param callable|null $clientConfigurator A callable that builds a {@see DelegateHttpClient} from a {@see PooledHttpClient}; * passing null builds an {@see InterceptedHttpClient} with 2 retries on failures * @param int $maxHostConnections The maximum number of connections to a single host * @param int $maxPendingPushes The maximum number of pushed responses to accept in the queue * * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */
    public function __construct(array $defaultOptions = [], callable $clientConfigurator = null, int $maxHostConnections = 6, int $maxPendingPushes = 50)
    {
        $this->defaultOptions['buffer'] ??= self::shouldBuffer(...);

        if ($defaultOptions) {
            [$this->defaultOptions] = self::prepareRequest(null, null, $defaultOptions$this->defaultOptions);
        }

        $this->multi = new AmpClientState($clientConfigurator$maxHostConnections$maxPendingPushes$this->logger);
    }

    /** * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */
    
private NativeClientState $multi;

    /** * @param array $defaultOptions Default request's options * @param int $maxHostConnections The maximum number of connections to open * * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */
    public function __construct(array $defaultOptions = [], int $maxHostConnections = 6)
    {
        $this->defaultOptions['buffer'] ??= self::shouldBuffer(...);

        if ($defaultOptions) {
            [$this->defaultOptions] = self::prepareRequest(null, null, $defaultOptions$this->defaultOptions);
        }

        $this->multi = new NativeClientState();
        $this->multi->maxHostConnections = 0 < $maxHostConnections ? $maxHostConnections : \PHP_INT_MAX;
    }

    /** * @see HttpClientInterface::OPTIONS_DEFAULTS for available options */

    public function __construct(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50)
    {
        if (!\extension_loaded('curl')) {
            throw new \LogicException('You cannot use the "Symfony\Component\HttpClient\CurlHttpClient" as the "curl" extension is not installed.');
        }

        $this->defaultOptions['buffer'] ??= self::shouldBuffer(...);

        if ($defaultOptions) {
            [$this->defaultOptions] = self::prepareRequest(null, null, $defaultOptions$this->defaultOptions);
        }

        $this->multi = new CurlClientState($maxHostConnections$maxPendingPushes);
    }

    public function setLogger(LoggerInterface $logger): void
    {
        $this->logger = $this->multi->logger = $logger;
    }
Home | Imprint | This part of the site doesn't use cookies.