/**
  * Sends the given HTTP request
  *
  * @param Http\Request $httpRequest
  * @return Http\Response
  * @throws Http\Exception
  * @api
  */
 public function sendRequest(Http\Request $httpRequest)
 {
     $requestHandler = $this->bootstrap->getActiveRequestHandler();
     if (!$requestHandler instanceof FunctionalTestRequestHandler) {
         throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
     }
     $this->securityContext->clearContext();
     $this->validatorResolver->reset();
     $response = new Http\Response();
     $requestHandler->setHttpRequest($httpRequest);
     $requestHandler->setHttpResponse($response);
     $objectManager = $this->bootstrap->getObjectManager();
     $baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
     $componentContext = new ComponentContext($httpRequest, $response);
     if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Throwable $throwable) {
             $this->prepareErrorResponse($throwable, $response);
         }
     } else {
         try {
             $baseComponentChain->handle($componentContext);
         } catch (\Exception $exception) {
             $this->prepareErrorResponse($exception, $response);
         }
     }
     $session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
     if ($session->isStarted()) {
         $session->close();
     }
     $this->persistenceManager->clearState();
     return $response;
 }
 /**
  * This method is used internal as a callback method to clear doctrine states
  *
  * @param integer $iteration
  * @return void
  */
 protected function clearState($iteration)
 {
     if ($iteration % 1000 === 0) {
         $this->persistenceManager->clearState();
     }
 }