// next token
cookieLine = nextToken(st);
} else {
String name = cookieLine.substring(0, equalPos);
String value = extractFromQuotes(cookieLine.substring(equalPos + 1));
Cookie thisCookie = new Cookie(name, value);
thisCookie.setVersion(version);
thisCookie.setSecure(isSecure());
cookieList.add(thisCookie);
// check for path / domain / port
cookieLine = nextToken(st);
while ((cookieLine != null) && cookieLine.trim().startsWith("$")) {
cookieLine = cookieLine.trim();
equalPos = cookieLine.indexOf('=');
String attrValue = equalPos == -1 ? "" : cookieLine
.substring(equalPos + 1).trim();
if (cookieLine.startsWith("$Path")) {
thisCookie.setPath(extractFromQuotes(attrValue));
} else if (cookieLine.startsWith("$Domain")) {
thisCookie.setDomain(extractFromQuotes(attrValue));
}
cookieLine = nextToken(st);
}
Logger.log(Logger.FULL_DEBUG, Launcher.RESOURCES,
"WinstoneRequest.CookieFound", thisCookie.toString());
if (thisCookie.getName().equals(WinstoneSession.SESSION_COOKIE_NAME)) {
// Find a context that manages this key
HostConfiguration hostConfig = this.hostGroup.getHostByName(this.serverName);
WebAppConfiguration ownerContext = hostConfig.getWebAppBySessionKey(thisCookie.getValue());
if (ownerContext != null) {
this.requestedSessionIds.put(ownerContext.getContextPath(),
thisCookie.getValue());
this.currentSessionIds.put(ownerContext.getContextPath(),
thisCookie.getValue());
}
// If not found, it was probably dead
else {
this.deadRequestedSessionId = thisCookie.getValue();
}
// this.requestedSessionId = thisCookie.getValue();
// this.currentSessionId = thisCookie.getValue();
Logger.log(Logger.FULL_DEBUG, Launcher.RESOURCES,
"WinstoneRequest.SessionCookieFound",
new String[] {thisCookie.getValue(),
ownerContext == null ? "" : "prefix:" + ownerContext.getContextPath()});
}
}
}
}