HttpTransporter::buildGuzzleOptions( WordPressAiClientProvidersHttpDTORequestOptions $options ): WordPressAiClientProvidersHttparray<string,

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Converts request options to a Guzzle-compatible options array.

Parameters

$optionsWordPressAiClientProvidersHttpDTORequestOptionsrequired
The request options.

Return

WordPressAiClientProvidersHttparray<string, mixed> Guzzle-compatible options.

Source

private function buildGuzzleOptions(RequestOptions $options): array
{
    $guzzleOptions = [];
    $timeout = $options->getTimeout();
    if ($timeout !== null) {
        $guzzleOptions['timeout'] = $timeout;
    }
    $connectTimeout = $options->getConnectTimeout();
    if ($connectTimeout !== null) {
        $guzzleOptions['connect_timeout'] = $connectTimeout;
    }
    $allowRedirects = $options->allowsRedirects();
    if ($allowRedirects !== null) {
        if ($allowRedirects) {
            $redirectOptions = [];
            $maxRedirects = $options->getMaxRedirects();
            if ($maxRedirects !== null) {
                $redirectOptions['max'] = $maxRedirects;
            }
            $guzzleOptions['allow_redirects'] = !empty($redirectOptions) ? $redirectOptions : \true;
        } else {
            $guzzleOptions['allow_redirects'] = \false;
        }
    }
    return $guzzleOptions;
}

Changelog

VersionDescription
0.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.