/**
  * Renders the final response and sends it back to the client.
  * 
  * @param Response $response HTTP Response to be sent.
  * @param Request $request The original HTTP request for context.
  */
 public function sendResponse(Response $response, Request $request)
 {
     // prepare the response for sending (will tweak some headers based on the request)
     $response->prepare($request);
     // trigger WillSendResponse event for any last minute changes
     $this->container->get('event_manager')->trigger(new WillSendResponse($response, $request));
     $timer = $this->container->get('splot.timer');
     $time = $timer->getDuration();
     $memory = $timer->getCurrentMemoryPeak();
     $memoryString = StringUtils::bytesToString($memory);
     $this->logger->debug('Rendering response for {method} {uri} took {time} ms and used {memory} memory.', array('method' => $request->getMethod(), 'uri' => $request->getRequestUri(), 'memory' => $memoryString, 'time' => $time, '@stat' => 'splot.render', '@time' => $time, '@memory' => $memory));
     // and finally send out the response
     $response->send();
 }