/**
  * {@inheritdoc}
  */
 protected function doSendInternalRequest(InternalRequestInterface $internalRequest)
 {
     try {
         $this->eventDispatcher->dispatch(Events::REQUEST_CREATED, $requestCreatedEvent = new RequestCreatedEvent($this, $internalRequest));
         $response = parent::doSendInternalRequest($requestCreatedEvent->getRequest());
         $this->eventDispatcher->dispatch(Events::REQUEST_SENT, $requestSentEvent = new RequestSentEvent($this, $requestCreatedEvent->getRequest(), $response));
         if ($requestSentEvent->hasException()) {
             throw $requestSentEvent->getException();
         }
         $response = $requestSentEvent->getResponse();
     } catch (HttpAdapterException $e) {
         $e->setRequest($internalRequest);
         $e->setResponse(isset($response) ? $response : null);
         $this->eventDispatcher->dispatch(Events::REQUEST_ERRORED, $exceptionEvent = new RequestErroredEvent($this, $e));
         if ($exceptionEvent->hasResponse()) {
             return $exceptionEvent->getResponse();
         }
         throw $exceptionEvent->getException();
     }
     return $response;
 }