in src/main/java/org/apache/sling/launchpad/testservices/servlets/requestdispatcher/RequestDispatcherIncludeBufferedServlet.java [53:70]
protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().write("includeBuffered(");
// build "synthetic response"
SlingHttpServletResponseResult syntheticResponse = Builders.newResponseBuilder().build();
// write output of other servlet to this response to allow to post-process or validate it
RequestDispatcher requestDispatcher = request.getRequestDispatcher(OriginalResponseServlet.PATH);
requestDispatcher.include(request, syntheticResponse);
// write generated output to response
response.getWriter().write(syntheticResponse.getOutputAsString());
response.getWriter().write(")");
}