[undertow-dev] Changing headers on proxy response

Jeff Williams jeffw at wherethebitsroam.com
Fri Oct 31 09:43:38 EDT 2014


Hi,

I am currently using a customer handler wrapping the proxy handler. I want
to set some response headers from my handler, but if they exist in the
response from the proxy's backend, they are overridden. Example code:

Undertow.builder()
  .addHttpListener(8080, "localhost")
  .setHandler(new MyHandler(new ProxyHandler(proxy, 30000,
ResponseCodeHandler.HANDLE_404))).build();

class MyHandler extends HttpHandler {
  private static final HttpString ACCESS_CONTROL_EXPOSE_HEADERS = new
HttpString("Access-Control-Expose-Headers");
  private HTTPHandler next;
  public MyHandler(HttpHandler next) {
    this.next = next;
  }
  public  void handleRequest(HttpServerExchange exchange) throws Exception {
    exchange.getResponseHeaders().put(ACCESS_CONTROL_EXPOSE_HEADERS, "new
ACEH");
  }
}

The problem here is that the backend server responds with an
Access-Control-Expose-Headers header and that replaces the one I set in
MyHandler.

Is there any way I can change headers after proxy has received the response
from backend and before it starts sending the response to the client?

Regards,
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20141031/bd1c1915/attachment.html 


More information about the undertow-dev mailing list