<div dir="ltr">Thanks, that worked perfectly for now.<div><br></div><div>Jeff</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 3 November 2014 08:57, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You just return the original conduit, but set the headers in the wrapper class itself.<br>
<span class="im HOEnZb"><br>
Stuart<br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Jeff Williams&quot; &lt;<a href="mailto:jeffw@wherethebitsroam.com">jeffw@wherethebitsroam.com</a>&gt;<br>
</span><div class="HOEnZb"><div class="h5">&gt; To: &quot;Stuart Douglas&quot; &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt;<br>
&gt; Cc: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; Sent: Monday, 3 November, 2014 6:34:28 PM<br>
&gt; Subject: Re: [undertow-dev] Changing headers on proxy response<br>
&gt;<br>
&gt; Stuart,<br>
&gt;<br>
&gt; Thanks for that. I&#39;m guessing I can just extend<br>
&gt; org.xnio.conduits.AbstractStreamSinkConduit&lt;StreamSinkConduit&gt; and just<br>
&gt; pass everything through to next? Since there is not much information around<br>
&gt; about the StreamSinkConduit, where would be the best place to add the<br>
&gt; headers? In the first call to one of the transferFrom methods?<br>
&gt;<br>
&gt; I&#39;ve added a JIRA for this: <a href="https://issues.jboss.org/browse/UNDERTOW-340" target="_blank">https://issues.jboss.org/browse/UNDERTOW-340</a><br>
&gt;<br>
&gt; Regards,<br>
&gt; Jeff<br>
&gt;<br>
&gt; On 2 November 2014 04:24, Stuart Douglas &lt;<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; You can set them in a response wrapper<br>
&gt; &gt; (io.undertow.server.HttpServerExchange#addResponseWrapper) and they should<br>
&gt; &gt; not be overriden, although this is not ideal.<br>
&gt; &gt;<br>
&gt; &gt; If you file a JIRA I will look at adding better support for this into the<br>
&gt; &gt; proxy.<br>
&gt; &gt;<br>
&gt; &gt; Stuart<br>
&gt; &gt;<br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; From: &quot;Jeff Williams&quot; &lt;<a href="mailto:jeffw@wherethebitsroam.com">jeffw@wherethebitsroam.com</a>&gt;<br>
&gt; &gt; &gt; To: <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; Sent: Saturday, 1 November, 2014 12:43:38 AM<br>
&gt; &gt; &gt; Subject: [undertow-dev] Changing headers on proxy response<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Hi,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I am currently using a customer handler wrapping the proxy handler. I<br>
&gt; &gt; want to<br>
&gt; &gt; &gt; set some response headers from my handler, but if they exist in the<br>
&gt; &gt; response<br>
&gt; &gt; &gt; from the proxy&#39;s backend, they are overridden. Example code:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Undertow.builder()<br>
&gt; &gt; &gt; .addHttpListener(8080, &quot;localhost&quot;)<br>
&gt; &gt; &gt; .setHandler(new MyHandler(new ProxyHandler(proxy, 30000,<br>
&gt; &gt; ResponseCodeHandler.<br>
&gt; &gt; &gt; HANDLE_404 ))).build();<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; class MyHandler extends HttpHandler {<br>
&gt; &gt; &gt; private static final HttpString ACCESS_CONTROL_EXPOSE_HEADERS = new<br>
&gt; &gt; &gt; HttpString(&quot;Access-Control-Expose-Headers&quot;);<br>
&gt; &gt; &gt; private HTTPHandler next;<br>
&gt; &gt; &gt; public MyHandler(HttpHandler next) {<br>
&gt; &gt; &gt; this.next = next;<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt; p ublic void handleRequest(HttpServerExchange exchange ) throws<br>
&gt; &gt; Exception {<br>
&gt; &gt; &gt; exchange .getResponseHeaders().put( ACCESS_CONTROL_EXPOSE_HEADERS , &quot; new<br>
&gt; &gt; &gt; ACEH&quot; );<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; The problem here is that the backend server responds with an<br>
&gt; &gt; &gt; Access-Control-Expose-Headers header and that replaces the one I set in<br>
&gt; &gt; &gt; MyHandler.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Is there any way I can change headers after proxy has received the<br>
&gt; &gt; response<br>
&gt; &gt; &gt; from backend and before it starts sending the response to the client?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Regards,<br>
&gt; &gt; &gt; Jeff<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; undertow-dev mailing list<br>
&gt; &gt; &gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/undertow-dev</a><br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>