WC_Helper_API_Backoff::get_retry_after_from_headers │ private static │ WC 1.0

Extract the wait, in seconds, from a rate-limited response's Retry-After header. Non-positive or missing values are treated as absent.

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

Хуков нет.

Возвращает

int|null. Seconds to wait, or null when the header is absent/invalid.

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

$result = WC_Helper_API_Backoff::get_retry_after_from_headers( $response ): ?int;
$response(массив) (обязательный)
The rate-limited (HTTP 429) response from the Helper API call.

Код WC_Helper_API_Backoff::get_retry_after_from_headers() WC 11.2.2

private static function get_retry_after_from_headers( array $response ): ?int {
	$retry_after = wp_remote_retrieve_header( $response, 'retry-after' );
	if ( is_numeric( $retry_after ) && (int) $retry_after > 0 ) {
		return (int) $retry_after;
	}

	return null;
}