Yoast\WP\SEO\MyYoast_Client\Infrastructure\Http
HTTP_Client::request
Sends an HTTP request with optional DPoP proof.
Метод класса: HTTP_Client{}
Хуков нет.
Возвращает
HTTP_Response. The parsed response.
Использование
$HTTP_Client = new HTTP_Client(); $HTTP_Client->request( $method, $url, $options ): HTTP_Response;
- $method(строка) (обязательный)
- The HTTP method.
- $url(строка) (обязательный)
- The request URL.
- $options(array<string, string|int|true|false|string[]|null>)
- Request options:
'headers','body','timeout','dpop'(bool),'access_token'.
По умолчанию:[]
Код HTTP_Client::request() HTTP Client::request Yoast 28.9
public function request( string $method, string $url, array $options = [] ): HTTP_Response {
$cached_response = $this->get_cached_rate_limit_response( $url );
if ( $cached_response !== null ) {
return $cached_response;
}
$result = $this->do_request( $method, $url, $options );
// Handle DPoP nonce lifecycle when DPoP is active.
if ( ! empty( $options['dpop'] ) ) {
$this->dpop_handler->handle_nonce_response( $result->get_headers() );
// Retry once on use_dpop_nonce error with the fresh nonce.
if ( $this->is_dpop_nonce_error( $result ) ) {
$this->logger->debug(
'Retrying request with fresh DPoP nonce for {method} {url}.',
[
'method' => $method,
'url' => $url,
],
);
$result = $this->do_request( $method, $url, $options );
$this->dpop_handler->handle_nonce_response( $result->get_headers() );
}
}
return $result;
}