public function writeResponse(ResponseInterface $response, RequestInterface $request)
 {
     //set default header-collection in case, exception was thrown while reading the request
     if (!$request->getHeaderCollection() instanceof HeaderCollectionInterface) {
         $request->setHeaderCollection(new HeaderCollection());
     }
     foreach ($this->responseHeaderModifier as $modifier) {
         $modifier->modify($response->getHeaderCollection(), $request);
     }
     $this->statusCodeWriter->writeResponseStatusCode($response->getStatusCode());
     $this->headerWriter->writeResponseHeader($response->getHeaderCollection());
     $content = $response->getContent();
     $requestedContentType = $request->getHeaderCollection()->getHeaderValue(HeaderName::ACCEPT, ContentType::APPLICATION_JSON);
     $this->contentWriter->writeResponseContent($content, $requestedContentType);
 }