@Test public void testEndOutput() { CacheTransaction tx = response.startTransaction(handle, null); CacheTransaction txEnd = response.endOutput(); assertEquals(tx, txEnd); }
CacheTransaction endOutput() { try { if (out != null) { out.flush(); out.close(); out = null; } else if (tx != null) { tx.getOutputStream().flush(); tx.getOutputStream().close(); CachedOutputStream cacheOs = tx.getOutputStream(); OutputStream clientOs = super.getOutputStream(); ByteArrayInputStream cacheIs = new ByteArrayInputStream(cacheOs.getContent()); IOUtils.copy(cacheIs, clientOs); clientOs.flush(); clientOs.close(); } else { super.getOutputStream().flush(); super.getOutputStream().close(); } } catch (IOException e) { if (RequestUtils.isCausedByClient(e)) logger.debug("Can't write cached response back to client: " + e.getMessage()); else logger.error("Unknown error while writing cached response back to client", e); } return tx; }
CacheableHttpServletResponse extends HttpServletResponseWrapper { CacheTransaction endOutput() { try { if (out != null) { out.flush(); out.close(); out = null; } else if (tx != null) { tx.getOutputStream().flush(); tx.getOutputStream().close(); CachedOutputStream cacheOs = tx.getOutputStream(); OutputStream clientOs = super.getOutputStream(); ByteArrayInputStream cacheIs = new ByteArrayInputStream(cacheOs.getContent()); IOUtils.copy(cacheIs, clientOs); clientOs.flush(); clientOs.close(); } else { super.getOutputStream().flush(); super.getOutputStream().close(); } } catch (IOException e) { if (RequestUtils.isCausedByClient(e)) logger.debug("Can't write cached response back to client: " + e.getMessage()); else logger.error("Unknown error while writing cached response back to client", e); } return tx; } }
CacheableHttpServletResponse extends HttpServletResponseWrapper { CacheTransaction endOutput() { try { if (out != null) { out.flush(); out.close(); out = null; } else if (tx != null) { tx.getOutputStream().flush(); tx.getOutputStream().close(); CachedOutputStream cacheOs = tx.getOutputStream(); OutputStream clientOs = super.getOutputStream(); ByteArrayInputStream cacheIs = new ByteArrayInputStream(cacheOs.getContent()); IOUtils.copy(cacheIs, clientOs); clientOs.flush(); clientOs.close(); } else { super.getOutputStream().flush(); super.getOutputStream().close(); } } catch (IOException e) { if (RequestUtils.isCausedByClient(e)) logger.debug("Can't write cached response back to client: " + e.getMessage()); else logger.error("Unknown error while writing cached response back to client", e); } return tx; } CacheableHttpServletResponse(HttpServletResponse response); }
CacheableHttpServletResponse extends HttpServletResponseWrapper { CacheTransaction endOutput() { try { if (out != null) { out.flush(); out.close(); out = null; } else if (tx != null) { tx.getOutputStream().flush(); tx.getOutputStream().close(); CachedOutputStream cacheOs = tx.getOutputStream(); OutputStream clientOs = super.getOutputStream(); ByteArrayInputStream cacheIs = new ByteArrayInputStream(cacheOs.getContent()); IOUtils.copy(cacheIs, clientOs); clientOs.flush(); clientOs.close(); } else { super.getOutputStream().flush(); super.getOutputStream().close(); } } catch (IOException e) { if (RequestUtils.isCausedByClient(e)) logger.debug("Can't write cached response back to client: " + e.getMessage()); else logger.error("Unknown error while writing cached response back to client", e); } return tx; } CacheableHttpServletResponse(HttpServletResponse response); CacheTransaction startTransaction(CacheHandle handle,
      StreamFilter filter); @Override PrintWriter getWriter(); @Override ServletOutputStream getOutputStream(); boolean isValid(); CacheTransaction getTransaction(); @Override void setContentType(String type); @Override void flushBuffer(); @Override void addHeader(String name, String value); @Override void setHeader(String name, String value); @Override void addDateHeader(String name, long date); @Override void addIntHeader(String name, int value); @Override void setDateHeader(String name, long date); @Override void setIntHeader(String name, int value); }
CacheableHttpServletResponse extends HttpServletResponseWrapper { CacheTransaction endOutput() { try { if (out != null) { out.flush(); out.close(); out = null; } else if (tx != null) { tx.getOutputStream().flush(); tx.getOutputStream().close(); CachedOutputStream cacheOs = tx.getOutputStream(); OutputStream clientOs = super.getOutputStream(); ByteArrayInputStream cacheIs = new ByteArrayInputStream(cacheOs.getContent()); IOUtils.copy(cacheIs, clientOs); clientOs.flush(); clientOs.close(); } else { super.getOutputStream().flush(); super.getOutputStream().close(); } } catch (IOException e) { if (RequestUtils.isCausedByClient(e)) logger.debug("Can't write cached response back to client: " + e.getMessage()); else logger.error("Unknown error while writing cached response back to client", e); } return tx; } CacheableHttpServletResponse(HttpServletResponse response); CacheTransaction startTransaction(CacheHandle handle,
      StreamFilter filter); @Override PrintWriter getWriter(); @Override ServletOutputStream getOutputStream(); boolean isValid(); CacheTransaction getTransaction(); @Override void setContentType(String type); @Override void flushBuffer(); @Override void addHeader(String name, String value); @Override void setHeader(String name, String value); @Override void addDateHeader(String name, long date); @Override void addIntHeader(String name, int value); @Override void setDateHeader(String name, long date); @Override void setIntHeader(String name, int value);  }