WC_Helper_API_Backoff::record_from_response │ public static │ WC 1.0

Record a backoff window for a request type from a rate-limited response.

The wait is taken from the response's rate-limit headers and honored as-is, capped only at the request type's max. This respects both a global rate limit's short Retry-After and a per-endpoint limit's longer window. When no usable header is present (a malformed 429), the per-type default is used so there is always a sensible backoff.

Method of the class: WC_Helper_API_Backoff{}

No Hooks.

Returns

void. Nothing (null).

Usage

$result = WC_Helper_API_Backoff::record_from_response( $request_type, $response ): void;
$request_type(string) (required)
The Helper API request type (e.g. 'update-check').
$response(array) (required)
The rate-limited (HTTP 429) response from the Helper API call.

WC_Helper_API_Backoff::record_from_response() code WC 11.3.0

public static function record_from_response( string $request_type, array $response ): void {
	$bounds = self::get_bounds( $request_type );

	$retry_after = self::get_retry_after_from_headers( $response );

	if ( null === $retry_after ) {
		// No Retry-After header — apply the per-type default window.
		$retry_after = $bounds['default'];
	} else {
		// Honor the server's directive, but never longer than the per-type
		// maximum (a safety net against an erroneous far value).
		$retry_after = min( $retry_after, $bounds['max'] );
	}

	self::record( $request_type, $retry_after );
}