Reputation: 31
How can I parse the raw cookie string.
It must return the javax.servlet.http.Cookie object.
The raw cookie like this:
Set-Cookie: BAIDUID=66AA214F9A534411A339CE5E60D36E28:FG=1; expires=Sun, 05-Aug-42 06:41:06 GMT; path=/; domain=.baidu.com
Upvotes: 1
Views: 2372
Reputation: 12538
I don't understand what is the difficulty you face - What have you tried ?
String[] pairs = String.split(";")
will give you an array of name-value pairs.pair.subString(0, pair.indexOf(':') + 1)
will give you the namepair.subString(pair.indexOf(':') + 1, pair.length - (pair.indexOf(':') + 1))
will give you the valuepair.indexOf(':')
into a variable and reuseUpvotes: 1