package net.pterodactylus.demoscenemusic.core;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.pterodactylus.demoscenemusic.page.ServletRequest;
import net.pterodactylus.util.io.Closer;
+import net.pterodactylus.util.io.StreamCopier;
import net.pterodactylus.util.template.HtmlFilter;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.Template;
} catch (URISyntaxException use1) {
throw new IOException("Could not create URI from " + request.getRequestURI(), use1);
}
- Response response = new Response(httpServletResponse.getOutputStream());
+ ByteArrayOutputStream responseOutputBuffer = new ByteArrayOutputStream();
+ Response response = new Response(responseOutputBuffer);
response = page.handleRequest(servletRequest, response);
for (Header header : response.getHeaders()) {
for (String value : header) {
}
httpServletResponse.setContentType(response.getContentType());
httpServletResponse.setStatus(response.getStatusCode());
+ StreamCopier.copy(new ByteArrayInputStream(responseOutputBuffer.toByteArray()), httpServletResponse.getOutputStream());
return;
}
}