You are here

protected static function PubSubHubbub::retry in Feeds 8.3

Retries a POST request.

Parameters

\Drupal\feeds\SubscriptionInterface $subscription: The subscription.

array $body: The POST body.

int $retries: (optional) The number of retries. Defaults to 3.

Return value

\GuzzleHttp\Message\Response The Guzzle response.

1 call to PubSubHubbub::retry()
PubSubHubbub::runSubscribeBatch in src/EventSubscriber/PubSubHubbub.php
Subscribes to or unsubscribes from a hub.

File

src/EventSubscriber/PubSubHubbub.php, line 259

Class

PubSubHubbub
Event listener for PubSubHubbub subscriptions.

Namespace

Drupal\feeds\EventSubscriber

Code

protected static function retry(SubscriptionInterface $subscription, array $body, $retries = 3) {
  $tries = 0;
  do {
    $tries++;
    try {
      return \Drupal::httpClient()
        ->post($subscription
        ->getHub(), [
        'body' => $body,
      ]);
    } catch (RequestException $e) {
      \Drupal::logger('feeds')
        ->warning('Subscription error: %error', [
        '%error' => $e
          ->getMessage(),
      ]);
    }
  } while ($tries <= $retries);
}