On Thu, Jun 5, 2014 at 10:38 PM, Stuart Douglas <sdouglas@redhat.com> wrote:
I could add some other interface+method that makes it more obvious, although there would be a very slight performance impact as it means an extra allocation (for the adaptor to go from the new interface to the wrapper).

Hmmm, it may not be worth it then especially since this is perhaps not about such a major use case. Some extra documentation somewhere that this would be the place to do "pre response write" operations would surely help.

The map itself is directly mutable, is there any reason why you would need a whole new map vs just clearing the existing one?

To be absolutely sure that nothing else can possibly see the unmodified cookie. As an external user I don't know which code all over the place does a call to any of the getResponseCookies methods before I have had a chance to that do clearing or replacing/modifying. The new map I now set is a sub class of some map that modifies the cookie immediately in its put() method. 

Of course what I conceptually actually would like to do is wrap HttpServerExchange so that I could directly intercept its setResponseCookie method.

Since that is rather hard with the current setup (HttpServerExchange is a final class and a huge one at that) the ability to set your own specialized map type seems to be the next best thing for this use case.

Kind regards,
Arjan

 

Stuart


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@lists.jboss.org <mailto:undertow-dev@lists.jboss.org>
        https://lists.jboss.org/__mailman/listinfo/undertow-dev
        <https://lists.jboss.org/mailman/listinfo/undertow-dev>