Repository: laravel/framework
File: src/Illuminate/Http/Client/PendingRequest.php (PHP)

Code before:

    /**
     * Send the request to the given URL.
     *
     * @param  string  $method
     * @param  string  $url
     * @param  array  $options
     * @return \Illuminate\Http\Client\Response
     *
     * @throws \Exception
     * @throws \Illuminate\Http\Client\ConnectionException
     */
    public function send(string $method, string $url, array $options = [])
    {
        if (! Str::startsWith($url, ['http://', 'https://'])) {
            $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
        }

        $url = $this->expandUrlParameters($url);

        $options = $this->parseHttpOptions($options);

        [$this->pendingBody, $this->pendingFiles] = [null, []];

        if ($this->async) {
            return $this->promise = new FluentPromise(fn () => $this->makePromise($method, $url, $options));
        }

        $shouldRetry = null;

        return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
            try {
                return tap($this->newResponse($this->sendRequest($method, $url, $options)), function ($response) use ($attempt, &$shouldRetry) {
                    $this->populateResponse($response);

                    $this->dispatchResponseReceivedEvent($response);

                    if ($response->successful()) {
                        return;
                    }

                    try {
                        $shouldRetry = $this->retryWhenCallback ? call_user_func($this->retryWhenCallback, $response->toException(), $this, $this->request->toPsrRequest()->getMethod()) : true;
                    } catch (Exception $exception) {
                        $shouldRetry = false;

                        throw $exception;
                    }

                    if ($this->throwCallback &&
                        ($this->throwIfCallback === null ||

Review comment (bug):
I fought long and hard with Codex about this. I mean, I was trying to get this damned LLM to admit it was wrong, but alas, I had to eat crow.

So, when we call `Client@requestAsync()` it is telling the underlying curl multihandler about the request we're going to make. All of the requests always get fired off by the handler as soon as we run the first promise, making the `$concurrent` parameter all but meaningless inside of `PendingRequest@pool()` since they'll the curl multihandler initiates everything in its queue when we first the first request.

Code after:
        ]))->promise()->wait();

        return $results;
    }

    /**
     * Send a pool of asynchronous requests concurrently, with callbacks for introspection.
     *
     * @param  callable  $callback
     * @return \Illuminate\Http\Client\Batch
     */
    public function batch(callable $callback): Batch
    {
        return tap(new Batch($this->factory), $callback);
    }

    /**
     * Send the request to the given URL.
     *
     * @param  string  $method
     * @param  string  $url
     * @param  array  $options
     * @return \Illuminate\Http\Client\Response|\Illuminate\Http\Client\Promises\LazyPromise
     *
     * @throws \Exception
     * @throws \Illuminate\Http\Client\ConnectionException
     */
    public function send(string $method, string $url, array $options = [])
    {
        if (! Str::startsWith($url, ['http://', 'https://'])) {
            $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
        }

        $url = $this->expandUrlParameters($url);

        $options = $this->parseHttpOptions($options);

        [$this->pendingBody, $this->pendingFiles] = [null, []];

        if ($this->async) {
            return $this->promise = new LazyPromise(
                fn () => $this->makePromise($method, $url, $options)
            );
        }

        $shouldRetry = null;

        return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
            try {
                return tap($this->newResponse($this->sendRequest($method, $url, $options)), function ($response) use ($attempt, &$shouldRetry) {
                    $this->populateResponse($response);