in

HttpServletResponseWrapper that records size of bytes written or a Guava version of ContentCachingResponseWrapper exists?


I’ve created servlet filters for my java webserver. I wanted to keep record of the number of bytes written into the response output stream. There are two ways I’ve seen so far to accomplish this:

1.) Making your own custom HttpServletResponseWrapper: How to read and copy the HTTP servlet response output stream content for logging

2.) Spring’s ContentCachingResponseWrapper: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/ContentCachingResponseWrapper.html

Is there any other solutions for this? Specifically, something that does not use Spring? Preferably something in Guava? It would be nice to see a solution where I don’t have to create a custom ServletOutputStream and HttpServletResponseWrapper (per the first solution).



Source: https://stackoverflow.com/questions/70600107/httpservletresponsewrapper-that-records-size-of-bytes-written-or-a-guava-version

The Nebulant CLI tool is a single binary that can be used as a helper for the web editor

A basic and minimal e-commerce store using Gatsby, Stripe, Use-Shopping-Cart and Netlify