This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have code in place which creates an HttpUrlConnection and then needs to read the cookies. I've noticed that if I iterate through the headers returned:
...the cookie name=value always appears first in the string hdrString (as opposed to path=/; domain=.whatever.com )
Does anyone know if this is a requirement? That the cookie name=value always appears first? If so I am going to write my code to rely on that...
Joined: Oct 14, 2004
Update - according to wikipedia the name=value is first...
Example of an HTTP response from google.com, which sets a cookie with attributes.
Beside the name/value pair, a cookie may also contain an expiration date, a path, a domain name, and whether the cookie is intended only for encrypted connections. RFC 2965 also specifies that cookies must have a mandatory version number, but this is usually omitted. These pieces of data follow the name=newvalue pair and are separated by semicolons. For example, a cookie can be created by the server by sending a line Set-Cookie: name=newvalue; expires=date; path=/; domain=.example.org.