/** * Extracts cookies from a cookie header. Works in conjunction with a cookie press class, which actually creates * the cookies and adds them to the jar as appropriate. * * 1. Parse the header into tokens, separated by ',' and ';' (respecting single and double quotes) * 2. Process tokens from the end: * a. if the token contains an '=' we have a name/value pair. Add them to the cookie press, which * will decide if it is a cookie name or an attribute name. * b. if the token is a reserved word, flush the cookie press and continue. * c. otherwise, add the token to the cookie press, passing along the last character of the previous token. */ void findCookies( String cookieHeader ) { Vector tokens = getCookieTokens( cookieHeader ); for (int i = tokens.size() - 1; i >= 0; i--) { String token = (String) tokens.elementAt( i ); int equalsIndex = getEqualsIndex( token ); if (equalsIndex != -1) { _press.addTokenWithEqualsSign( this, token, equalsIndex ); } else if (isCookieReservedWord( token )) { _press.clear(); } else { _press.addToken( token, lastCharOf( (i == 0) ? "" : (String) tokens.elementAt( i - 1 ) ) ); } } }
/** * Extracts cookies from a cookie header. Works in conjunction with a cookie press class, which actually creates * the cookies and adds them to the jar as appropriate. * * 1. Parse the header into tokens, separated by ',' and ';' (respecting single and double quotes) * 2. Process tokens from the end: * a. if the token contains an '=' we have a name/value pair. Add them to the cookie press, which * will decide if it is a cookie name or an attribute name. * b. if the token is a reserved word, flush the cookie press and continue. * c. otherwise, add the token to the cookie press, passing along the last character of the previous token. */ void findCookies( String cookieHeader ) { Vector tokens = getCookieTokens( cookieHeader ); for (int i = tokens.size() - 1; i >= 0; i--) { String token = (String) tokens.elementAt( i ); int equalsIndex = getEqualsIndex( token ); if (equalsIndex != -1) { _press.addTokenWithEqualsSign( this, token, equalsIndex ); } else if (isCookieReservedWord( token )) { _press.clear(); } else { _press.addToken( token, lastCharOf( (i == 0) ? "" : (String) tokens.elementAt( i - 1 ) ) ); } } }
/** * Extracts cookies from a cookie header. Works in conjunction with a cookie press class, which actually creates * the cookies and adds them to the jar as appropriate. * * 1. Parse the header into tokens, separated by ',' and ';' (respecting single and double quotes) * 2. Process tokens from the end: * a. if the token contains an '=' we have a name/value pair. Add them to the cookie press, which * will decide if it is a cookie name or an attribute name. * b. if the token is a reserved word, flush the cookie press and continue. * c. otherwise, add the token to the cookie press, passing along the last character of the previous token. */ void findCookies( String cookieHeader ) { Vector tokens = getCookieTokens( cookieHeader ); for (int i = tokens.size() - 1; i >= 0; i--) { String token = (String) tokens.elementAt( i ); int equalsIndex = getEqualsIndex( token ); if (equalsIndex != -1) { _press.addTokenWithEqualsSign( this, token, equalsIndex ); } else if (isCookieReservedWord( token )) { _press.clear(); } else { _press.addToken( token, lastCharOf( (i == 0) ? "" : (String) tokens.elementAt( i - 1 ) ) ); } } }