I created this little filter to automatically return a 304 if the
"If-None-Match" filter matches the ETag.
It's not clear to me however, how i can now prevent the entity to be
written to the output stream, wile preserving the response headers.

public class NotModifiedFilter implements Filter {
        private static final Logger log = 

        public void doFilter(final ServletRequest request, final
ServletResponse response, FilterChain chain) throws IOException,
ServletException {
                chain.doFilter(request, new
HttpServletResponseWrapper((HttpServletResponse) response) {
                        boolean set_304 = false; // TODO use this flag to 
intercept the
output stream, preventing the writing of the entity?
                        public void addHeader(String name, String value) {
                                if (name.equals("ETag")){
                                        if (request instanceof 
HttpServletRequest) {
                                                String etagin = 
                                                if (value.equals(etagin)) {
                                                        set_304 = true;
response status 200 into 304 because the
ETag matches the If-None-Match header");
                                super.addHeader(name, value);

Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
Resteasy-users mailing list

Reply via email to