Cookie Encoding is not handled properly in 4.1.1 where as properly handled in 4.0.19

18 views
Skip to first unread message

Mani Chaitanya

unread,
Aug 17, 2016, 3:25:01 AM8/17/16
to Netty discussions
Hello,

I see the code difference between 4.1.1 and 4.0.19 while encoding cookie due to which we are facing problems. When I encode the cookie [UNIQEID=758B59989313E60ECA0FDF8BD7BECD87, path=/, secure, HTTPOnly] using ClientCookieEncoder then it is converting into [JSESSIONID=758B59989313E60ECA0FDF8BD7BECD87] where path is missing. This is happening with 4.1.1 and not with 4.0.19.

Code in 4.0.19 - where name, value, path, domain, version every thing is handled properly.
private static void encode(StringBuilder buf, Cookie c) {
            if (c.getVersion() >= 1) {
                add(buf, '$' + CookieHeaderNames.VERSION, 1);
            }

            add(buf, c.getName(), c.getValue());

            if (c.getPath() != null) {
                add(buf, '$' + CookieHeaderNames.PATH, c.getPath());
            }

            if (c.getDomain() != null) {
                add(buf, '$' + CookieHeaderNames.DOMAIN, c.getDomain());
            }

            if (c.getVersion() >= 1) {
                .........
                }
            }
        }

Code in 4.1.1 - where path, domain, version are missing due to this I am facing problems
private void encode(StringBuilder buf, Cookie c) {
final String name = c.name();
final String value = c.value() != null ? c.value() : "";

validateCookie(name, value);

if (c.wrap()) {
addQuoted(buf, name, value);
} else {
add(buf, name, value);
}
}

Rogan Dawes

unread,
Aug 17, 2016, 3:32:13 AM8/17/16
to Netty discussions
User Agents (clients) are not expected to encode the path or any other attributes when sending the cookie to the server. All they are expected to do is determine for themselves whether the cookie applies, given a specific path in the URL.

--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/859d115e-920d-43e9-a6ee-ac1c2dbb81e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages