In my Grails app I’d like to make a custom request filter that looks for an existing ‘Location’ redirect header and modifies it if the response has not yet been committed.
I don’t see a method on the response object to even READ the existing headers, much less overwrite them.
Is there a way to do this?
Thanks!
This is done by creating a wrapper (extending
HttpServletResponseWrapper) and overrideing thesetHeader(..)method. There you can replace the header right before it is added to the response.The wrapper is utilized by creating it in a filter: