public function onResponse(ResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getOption('anonymous', false)) {
         return;
     }
     foreach ($this->authenticators as $authenticator) {
         if ($authenticator->supports($event->getResponse())) {
             $naRequest = $authenticator->handle($event->getRequest(), $event->getResponse());
             if ($naRequest !== $request) {
                 $event->setNextAttemptRequest($naRequest);
                 break;
             }
         }
     }
 }
 private function getNextRequest(ResponseEvent $event, array &$options)
 {
     $req = $event->getNextAttemptRequest();
     if ($options['retries'] >= $options['max_retries']) {
         return null;
     }
     if ($event->getRequest() !== $req) {
         $options['retries'] = 0;
     }
     return $req;
 }