protected void onOkRenderingResultsStatus(PostGadgetRenderingParams params) throws IOException { UriStatus urlStatus = params.getUrlStatus(); HttpServletResponse resp = params.getResponse(); if (params.getContext().getIgnoreCache() || urlStatus == UriStatus.INVALID_VERSION) { HttpUtil.setCachingHeaders(resp, 0); } else if (urlStatus == UriStatus.VALID_VERSIONED) { // Versioned files get cached indefinitely HttpUtil.setCachingHeaders(resp, true); } else { // Unversioned files get cached for 5 minutes by default, but this can be overridden // with a query parameter. int ttl = DEFAULT_CACHE_TTL; String ttlStr = params.getRequest().getParameter(Param.REFRESH.getKey()); if (!Strings.isNullOrEmpty(ttlStr)) { try { ttl = Integer.parseInt(ttlStr); } catch (NumberFormatException e) { // Ignore malformed TTL value if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "onOkRenderingResultsStatus", MessageKeys.MALFORMED_TTL_VALUE, new Object[] {ttlStr}); } } } HttpUtil.setCachingHeaders(resp, ttl, true); } resp.getWriter().print(params.getResults().getContent()); }
protected void onOkRenderingResultsStatus(PostGadgetRenderingParams params) throws IOException { UriStatus urlStatus = params.getUrlStatus(); HttpServletResponse resp = params.getResponse(); if (params.getContext().getIgnoreCache() || urlStatus == UriStatus.INVALID_VERSION) { HttpUtil.setCachingHeaders(resp, 0); } else if (urlStatus == UriStatus.VALID_VERSIONED) { // Versioned files get cached indefinitely HttpUtil.setCachingHeaders(resp, true); } else { // Unversioned files get cached for 5 minutes by default, but this can be overridden // with a query parameter. int ttl = DEFAULT_CACHE_TTL; String ttlStr = params.getRequest().getParameter(Param.REFRESH.getKey()); if (!StringUtils.isEmpty(ttlStr)) { try { ttl = Integer.parseInt(ttlStr); } catch (NumberFormatException e) { // Ignore malformed TTL value LOG.info("Bad TTL value '" + ttlStr + "' was ignored"); } } HttpUtil.setCachingHeaders(resp, ttl, true); } resp.getWriter().print(params.getResults().getContent()); }
protected void onOkRenderingResultsStatus(PostGadgetRenderingParams params) throws IOException { UriStatus urlStatus = params.getUrlStatus(); HttpServletResponse resp = params.getResponse(); if (params.getContext().getIgnoreCache() || urlStatus == UriStatus.INVALID_VERSION) { HttpUtil.setCachingHeaders(resp, 0); } else if (urlStatus == UriStatus.VALID_VERSIONED) { // Versioned files get cached indefinitely HttpUtil.setCachingHeaders(resp, true); } else { // Unversioned files get cached for 5 minutes by default, but this can be overridden // with a query parameter. int ttl = DEFAULT_CACHE_TTL; String ttlStr = params.getRequest().getParameter(Param.REFRESH.getKey()); if (!StringUtils.isEmpty(ttlStr)) { try { ttl = Integer.parseInt(ttlStr); } catch (NumberFormatException e) { // Ignore malformed TTL value LOG.info("Bad TTL value '" + ttlStr + "' was ignored"); } } HttpUtil.setCachingHeaders(resp, ttl, true); } resp.getWriter().print(params.getResults().getContent()); }
@Test public void renderTypeHtml() { RenderingResults results = renderer.render(makeContext("html")); assertEquals(RenderingResults.Status.OK, results.getStatus()); assertEquals(BASIC_HTML_CONTENT, results.getContent()); }
@Test public void renderTypeHtml() { RenderingResults results = renderer.render(makeContext("html")); assertEquals(RenderingResults.Status.OK, results.getStatus()); assertEquals(BASIC_HTML_CONTENT, results.getContent()); }
@Test public void renderTypeHtml() { RenderingResults results = renderer.render(makeContext("html")); assertEquals(RenderingResults.Status.OK, results.getStatus()); assertEquals(BASIC_HTML_CONTENT, results.getContent()); }