WP_AI_Client_HTTP_Client::prepare_wp_args │ private │ WP 7.0.0

Prepares WordPress HTTP API arguments from a PSR-7 request.

Метод класса: WP_AI_Client_HTTP_Client{}

Хуков нет.

Возвращает

array<string, mixed>. WordPress HTTP API arguments.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->prepare_wp_args( $request, ?RequestOptions $options ): array;
$request(RequestInterface) (обязательный)
The PSR-7 request.
?RequestOptions $options
.
По умолчанию: null

Список изменений

С версии 7.0.0 Введена.

Код WP_AI_Client_HTTP_Client::prepare_wp_args() WP 7.1.4

private function prepare_wp_args( RequestInterface $request, ?RequestOptions $options = null ): array {
	$args = array(
		'method'      => $request->getMethod(),
		'headers'     => $this->prepare_headers( $request ),
		'body'        => $this->prepare_body( $request ),
		'httpversion' => $request->getProtocolVersion(),
		'blocking'    => true,
	);

	if ( null !== $options ) {
		if ( null !== $options->getTimeout() ) {
			$args['timeout'] = $options->getTimeout();
		}

		if ( null !== $options->getMaxRedirects() ) {
			$args['redirection'] = $options->getMaxRedirects();
		}
	}

	return $args;
}