Hi folks.

So, we've been bit by this cookie problem as well.

After diving into the debugger for a couple of hours I think I've
pinpointed exactly where cookie reading is failing.

>From what I can tell, the problem isn't that request.getCookies() is
returning only the first cookie, it's that it's returning all cookies
EXCEPT FOR THE LAST ONE.

The problem is an interaction between the code in
HeaderReader.addValues() and the code in CookieReader.readValue().
The former runs a do-while loop based on peek()ing to see if the end
of the string has been reached.   the readValue() method does some
weird stuff where it reads the NEXT value after it is done reading the
current value, and stores the next one in the CookieReader.cachedPair
field, to be returned during the next call to readValue.  However,
when it reads ahead I think it must be advancing the current index
into the header value.  The final time through the addValues() method
gets short-circuited due to peek() returning -1, so the final CACHED
cookie value is never added to the collection.

I'm not sure what the best way is to fix this.  It seems like the
CookieReader is doing something fundamentally incompatible with the
algorithm in the HeaderReader.addValues() method- it seems like a hack
gone awry.  I don't know what the "special" cookie values involving
"$" are for.

I would put this bug at the HIGHEST PRIORITY, since being unable to
read all cookies is a very broken state for the build to be in!

-Dave Fogel

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2465694

Reply via email to