You can set them in a response wrapper
(io.undertow.server.HttpServerExchange#addResponseWrapper) and they should not be
overriden, although this is not ideal.
If you file a JIRA I will look at adding better support for this into the proxy.
Stuart
----- Original Message -----
From: "Jeff Williams" <jeffw(a)wherethebitsroam.com>
To: undertow-dev(a)lists.jboss.org
Sent: Saturday, 1 November, 2014 12:43:38 AM
Subject: [undertow-dev] Changing headers on proxy response
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;
}
p ublic 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
_______________________________________________
undertow-dev mailing list
undertow-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev