Class RsWithCookie

  • All Implemented Interfaces:
    Body, Head, Response

    public final class RsWithCookie
    extends RsWrap
    Response decorator, with an additional cookie. The decorator validates cookie name according to RFC 2616 and cookie value according to RFC 6265

    Use this decorator in order to return a response with a "Set-Cookie" header inside, for example:

     return new RsWithCookie(
       new RsText("hello, world!"),
       "u", "Jeff",
       "Path=/", "Expires=Wed, 13 Jan 2021 22:23:01 GMT"
     );

    This response will contain this header:

     Set-Cookie: u=Jeff;Path=/;Expires=Wed, 13 Jan 2021 22:23:01 GMT

    The class is immutable and thread-safe.

    Since:
    0.1
    • Constructor Detail

      • RsWithCookie

        public RsWithCookie​(CharSequence name,
                            CharSequence value,
                            CharSequence... attrs)
        Ctor.
        Parameters:
        name - Cookie name
        value - Value of it
        attrs - Optional attributes, for example "Path=/"
      • RsWithCookie

        public RsWithCookie​(Response res,
                            CharSequence name,
                            CharSequence value,
                            CharSequence... attrs)
        Ctor.
        Parameters:
        res - Original response
        name - Cookie name
        value - Value of it
        attrs - Optional attributes, for example "Path=/"