/** * Executes a request, returning the response as JSON to be handled by makeRequest. */ public void fetch(HttpServletRequest request, HttpServletResponse response) throws GadgetException, IOException { HttpRequest rcr = buildHttpRequest(request); // Serialize the response HttpResponse results = requestPipeline.execute(rcr); // Rewrite the response if (contentRewriterRegistry != null) { try { results = contentRewriterRegistry.rewriteHttpResponse(rcr, results); } catch (RewritingException e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e, e.getHttpStatusCode()); } } // Serialize the response String output = convertResponseToJson(rcr.getSecurityToken(), request, results); // Find and set the refresh interval setResponseHeaders(request, response, results); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(UNPARSEABLE_CRUFT + output); }
/** * Executes a request, returning the response as JSON to be handled by makeRequest. */ public void fetch(HttpServletRequest request, HttpServletResponse response) throws GadgetException, IOException { HttpRequest rcr = buildHttpRequest(request); // Serialize the response HttpResponse results = requestPipeline.execute(rcr); // Rewrite the response if (contentRewriterRegistry != null) { try { results = contentRewriterRegistry.rewriteHttpResponse(rcr, results); } catch (RewritingException e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e, e.getHttpStatusCode()); } } // Serialize the response String output = convertResponseToJson(rcr.getSecurityToken(), request, results); // Find and set the refresh interval setResponseHeaders(request, response, results); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(UNPARSEABLE_CRUFT + output); }
String output = convertResponseToJson(rcr.getSecurityToken(), request, results);