{
char []buf = rawCookie.getBuffer();
int j = rawCookie.getOffset();
int end = j + rawCookie.length();
int version = 0;
Cookie cookie = null;
while (j < end) {
char ch = 0;
CharBuffer cbName = _cbName;
CharBuffer cbValue = _cbValue;
cbName.clear();
cbValue.clear();
for (;
j < end && ((ch = buf[j]) == ' ' || ch == ';' || ch ==',');
j++) {
}
if (end <= j)
break;
boolean isSpecial = false;
if (buf[j] == '$') {
isSpecial = true;
j++;
}
for (; j < end; j++) {
ch = buf[j];
if (ch < 128 && TOKEN[ch])
cbName.append(ch);
else
break;
}
for (; j < end && (ch = buf[j]) == ' '; j++) {
}
if (end <= j)
break;
else if (ch == ';' || ch == ',') {
try {
cookie = new Cookie(cbName.toString(), "");
cookie.setVersion(version);
_cookies.add(cookie);
// some clients can send bogus cookies
} catch (Exception e) {
log.log(Level.FINE, e.toString(), e);
}
continue;
}
else if (ch != '=') {
for (; j < end && (ch = buf[j]) != ';'; j++) {
}
continue;
}
j++;
for (; j < end && (ch = buf[j]) == ' '; j++) {
}
if (ch == '"') {
for (j++; j < end; j++) {
ch = buf[j];
if (ch == '"')
break;
cbValue.append(ch);
}
j++;
}
else {
for (; j < end; j++) {
ch = buf[j];
if (ch < 128 && VALUE[ch])
cbValue.append(ch);
else
break;
}
}
if (! isSpecial) {
if (cbName.length() == 0)
log.warning("bad cookie: " + rawCookie);
else {
cookie = new Cookie(toName(cbName), cbValue.toString());
cookie.setVersion(version);
_cookies.add(cookie);
}
}
else if (cookie == null) {
if (cbName.matchesIgnoreCase("Version"))
version = cbValue.charAt(0) - '0';
}
else if (cbName.matchesIgnoreCase("Version"))
cookie.setVersion(cbValue.charAt(0) - '0');
else if (cbName.matchesIgnoreCase("Domain"))
cookie.setDomain(cbValue.toString());
else if (cbName.matchesIgnoreCase("Path"))
cookie.setPath(cbValue.toString());
}
}