[undertow-dev] How to modify the response with ProxyHandler

Andrea Di Cesare andrea at softinstigate.com
Thu Feb 28 08:20:49 EST 2019


Thanks Stuart,

this works very well. For future reference this is our implementation of
the modifiable conduit
https://github.com/SoftInstigate/uiam/blob/master/src/main/java/io/uiam/handlers/ModifiableContentSinkConduit.java

We use it to modify both the request and the response for a proxied
resource (via ProxyHandler and LoadBalancingProxyClient). In order to get
the plain response to modify it without the need of decod it, we force the
Accept-Encoding=identity before proxying it. However we are struggling
encoding it according to the original Accept-Encoding after our
ModifiableContentSinkConduit.terminateWrites() executes.

We thought to set the Accept-Encoding back to its original value and use
the EncodingHandler, however the fact that we overwrite the header seems to
mess things. Do you have any suggestions?

Thanks,
 Andrea

Il giorno ven 22 feb 2019 alle ore 13:25 Stuart Douglas <sdouglas at redhat.com>
ha scritto:

> io.undertow.server.HttpServerExchange#addResponseWrapper lets you add a
> conduit that can modify the response.
>
> Stuart
>
> On Fri, Feb 22, 2019 at 11:13 PM Andrea Di Cesare <
> andrea at softinstigate.com> wrote:
>
>> Hi undertow-dev <undertow-dev at lists.jboss.org>,
>>
>> I'm using ProxyHandler with LoadBalancingProxyClient and in some cases I
>> need to modify the response content received from the backed before sending
>> it to the client.
>>
>> HttpServerExchange.addResponseCommitListener() allows to modify the
>> response and using it I'm able, for instance, to add a response header but
>> not modifyng the content from the backend since it is not available.
>>
>> Is it possible? What are the suggested ways of implementing this behavior?
>>
>> Thanks,
>>  Andrea Di Cesare
>>
>>
>> _______________________________________________
>> undertow-dev mailing list
>> undertow-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20190228/c05ce629/attachment-0001.html 


More information about the undertow-dev mailing list