[undertow-dev] Adding setResponseCookies method to HttpServerExchange?

arjan tijms arjan.tijms at gmail.com
Thu Jun 5 16:23:40 EDT 2014


On Thu, Jun 5, 2014 at 7:08 PM, Stuart Douglas <sdouglas at redhat.com> wrote:

> It is not obvious, but you can add a wrapper to io.undertow.server.
> HttpServerExchange#addResponseWrapper, which will then be called just
> before the response is written.
>

Woh, that's indeed not entirely obvious! ;)

I guess I'll just have to return factory.create(); then, and right before
that iterate over the cookies and change their value. Well, I'll try it.
Thanks!

I currently solved the issue by setting the responseCookies instance
variable of HttpServerExchange anyway by using reflection, but that's of
course not so nice. Is there any reason there's isn't a setter? Lot's of
other things are directly mutable it seems, like the relativePath and such
(which is great for handlers that need to do request rewriting).

Kind regards,
Arjan



>
> Even though this primary purpose of this hook is to wrap the response
> channel, you can also use it to do actions that need to occur just before
> the response is written, such as modifying cookies.
>
> Stuart
>
> arjan tijms wrote:
>
>> Hi,
>>
>> I'm trying to intercept the way that cookies are being written in
>> Undertow. The idea is to do something like can be done with a cookie
>> rewrite rule in Apache (like e.g. add or replace something to the domain
>> attribute of each and every cookie being written).
>>
>> After some hacking on the Undertow code it became clear that
>> HttpServerExchange#setResonseCookie is the central place where cookies
>> arrive.
>>
>> However, HttpServerExchange is a final class, so can't (easily) be
>> wrapped. If HttpServerExchange only had a setResponseCookies method then
>> handlers could install a special map that does the rewriting, making
>> this a fairly easy task.
>>
>> What do you think? Would it be a good idea to add such a method. or is
>> there an other way to easily do something like this?
>>
>> Kind regards,
>> Arjan Tijms
>>
>> _______________________________________________
>> 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/20140605/a2670728/attachment.html 


More information about the undertow-dev mailing list