try {
if (bufferedResponseContent != null) {
bufferedResponseContent.close();
}
ResponseContent buffer = new ResponseContentImpl(bufferedResponseContent.toByteArray(),
Charset.forName(getCharacterEncoding()));
new ResponseContentInterceptorChainImpl(responseContentInterceptors).begin(new HttpBufferRewriteImpl(
request, this, servletContext), buffer);
if (!Charset.forName(getCharacterEncoding()).equals(buffer.getCharset()))
setCharacterEncoding(buffer.getCharset().name());
ServletOutputStream outputStream = isResponseStreamWrapped() ? wrappedOutputStream : super
.getOutputStream();
if (outputStream != null)
Streams.copy(new ByteArrayInputStream(buffer.getContents()), outputStream);
if (printWriter != null) {
printWriter.close();
}
}