/** * EXPENSIVE!!! only for debugging. */ @Override public String toString() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("=== Cookies ==="); int count = getCookieCount(); for (int i = 0; i < count; ++i) { pw.println(getCookie(i).toString()); } return sw.toString(); }
/** * @deprecated - Use private method * {@link #getTokenEndPosition(byte[], int, int, boolean)} instead */ public static final int getTokenEndPosition(byte bytes[], int off, int end){ return getTokenEndPosition(bytes, off, end, true); }
public int getCookieCount() { if( unprocessed ) { unprocessed=false; processCookies(headers); } return cookieCount; }
!CookieSupport.ALLOW_HTTP_SEPARATORS_IN_V0 || CookieSupport.isV0Separator((char) bytes[pos]) || isWhiteSpace(bytes[pos]))) {pos++; } pos = nameEnd = getTokenEndPosition(bytes,pos,end,version,true); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } } while (pos < end && isWhiteSpace(bytes[pos])); valueEnd=getQuotedValueEndPosition(bytes, valueStart, end); valueEnd=getTokenEndPosition(bytes, valueStart, end, version, false); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } if (equals( "Version", bytes, nameStart, nameEnd) && sc == null) { if (equals( "Domain", bytes, nameStart, nameEnd)) { sc.getDomain().setBytes( bytes, valueStart, if (equals( "Path", bytes, nameStart, nameEnd)) { sc.getPath().setBytes( bytes, valueStart,
(isSeparator(bytes[pos]) || isWhiteSpace(bytes[pos]))) {pos++; } pos = nameEnd = getTokenEndPosition(bytes,pos,end,true); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; }; } while (pos < end && isWhiteSpace(bytes[pos])); valueEnd=getQuotedValueEndPosition(bytes, valueStart, end); if (!isSeparator(bytes[pos]) || bytes[pos] == '=' && ALLOW_EQUALS_IN_VALUE) { valueEnd = getTokenEndPosition(bytes, valueStart, end, false); log("Invalid cookie. Value not a token or quoted value"); while (pos < end && bytes[pos] != ';' && bytes[pos] != ',') while (pos < end && isWhiteSpace(bytes[pos])) {pos++; }; if (equals( "Version", bytes, nameStart, nameEnd) && sc == null) { if (equals( "Domain", bytes, nameStart, nameEnd)) { sc.getDomain().setBytes( bytes,
public ServerCookie getCookie( int idx ) { if( unprocessed ) { getCookieCount(); // will also update the cookies } return scookies[idx]; }
/** * This method parses the value of an HTTP {@linkplain HttpConstants#HEADER_COOKIE * "Cookie"} header that comes from a client to a server. It returns all the * Cookies present in the header. * * @param headerValue the value of the header from which the cookie will be * parsed. */ public static Cookie[] parseCookiesAsAServer(String headerValue, URI uri) { MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addValue(HttpConstants.HEADER_COOKIE).setBytes(headerValue.getBytes(), 0, headerValue.length()); Cookies cs = new Cookies(mimeHeaders); Cookie[] cookies = new Cookie[cs.getCookieCount()]; for (int i = 0; i < cs.getCookieCount(); i++) { ServerCookie serverCookie = cs.getCookie(i); cookies[i] = transformServerCookieToClientCookie(serverCookie); if (uri != null) { cookies[i].setSecure(uri.getScheme() != null && uri.getScheme().equalsIgnoreCase("https")); cookies[i].setDomain(uri.getHost()); cookies[i].setPath(uri.getPath()); } } return cookies; }
/** * Set the headers from which cookies will be pulled. * This has the side effect of recycling the object. * * @param headers Cookies are lazy-evaluated and will extract the * information from the provided headers. */ // [seguin] added so that an empty Cookies object could be // created, have headers set, then recycled. public void setHeaders(MimeHeaders headers) { recycle(); this.headers=headers; }
log.debug("Cookies: Parsing b[]: " + cookieValue.toString()); ByteChunk bc=cookieValue.getByteChunk(); processCookieHeader( bc.getBytes(), bc.getOffset(), bc.getLength());
String value = token.substring(i+1, token.length()).trim(); value=stripQuote( value ); ServerCookie cookie = addCookie();
!CookieSupport.ALLOW_HTTP_SEPARATORS_IN_V0 || CookieSupport.isV0Separator((char) bytes[pos]) || isWhiteSpace(bytes[pos]))) {pos++; } pos = nameEnd = getTokenEndPosition(bytes,pos,end,version,true); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } } while (pos < end && isWhiteSpace(bytes[pos])); valueEnd=getQuotedValueEndPosition(bytes, valueStart, end); valueEnd=getTokenEndPosition(bytes, valueStart, end, version, false); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } if (equals( "Version", bytes, nameStart, nameEnd) && sc == null) { if (equals( "Domain", bytes, nameStart, nameEnd)) { sc.getDomain().setBytes( bytes, valueStart, if (equals( "Path", bytes, nameStart, nameEnd)) { sc.getPath().setBytes( bytes, valueStart,
public ServerCookie getCookie( int idx ) { if( unprocessed ) { getCookieCount(); // will also update the cookies } return scookies[idx]; }
public void recycle() { bytesRead=0; contentLength = -1; contentTypeMB = null; charEncoding = null; headers.recycle(); serverNameMB.recycle(); serverPort=-1; localNameMB.recycle(); localPort = -1; remotePort = -1; available = 0; cookies.recycle(); parameters.recycle(); unparsedURIMB.recycle(); uriMB.recycle(); decodedUriMB.recycle(); queryMB.recycle(); methodMB.recycle(); protoMB.recycle(); schemeMB.recycle(); instanceId.recycle(); remoteUser.recycle(); authType.recycle(); attributes.clear(); listener = null; allDataReadEventSent.set(false); startTime = -1; }
byte[] buf = new byte[len]; System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len); processCookieHeader(buf, 0, len); processCookieHeader( bc.getBytes(), bc.getOffset(), bc.getLength());
/** * EXPENSIVE!!! only for debugging. */ public String toString() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("=== Cookies ==="); int count = getCookieCount(); for (int i = 0; i < count; ++i) { pw.println(getCookie(i).toString()); } return sw.toString(); }
!CookieSupport.ALLOW_HTTP_SEPARATORS_IN_V0 || CookieSupport.isV0Separator((char) bytes[pos]) || isWhiteSpace(bytes[pos]))) {pos++; } pos = nameEnd = getTokenEndPosition(bytes,pos,end,version,true); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } } while (pos < end && isWhiteSpace(bytes[pos])); valueEnd=getQuotedValueEndPosition(bytes, valueStart, end); valueEnd=getTokenEndPosition(bytes, valueStart, end, version, false); while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } if (equals( "Version", bytes, nameStart, nameEnd) && sc == null) { if (equals( "Domain", bytes, nameStart, nameEnd)) { sc.getDomain().setBytes( bytes, valueStart, if (equals( "Path", bytes, nameStart, nameEnd)) { sc.getPath().setBytes( bytes, valueStart,
public ServerCookie getCookie( int idx ) { if( unprocessed ) { getCookieCount(); // will also update the cookies } return scookies[idx]; }
/** * Recycles this object and readies it further use. */ public void recycle() { method.recycle(); protocol.recycle(); requestURI.recycle(); remoteAddr.recycle(); remoteHost.recycle(); serverName.recycle(); serverPort = 80; remoteUser.recycle(); authType.recycle(); queryString.recycle(); authorization.recycle(); scheme = SCHEME_HTTP; secure = false; contentLength = 0; contentType.recycle(); headers.recycle(); cookies.recycle(); attributes.clear(); tomcatInstanceId.recycle(); }
public int getCookieCount() { if( unprocessed ) { unprocessed=false; processCookies(headers); } return cookieCount; }
if( dbg>0 ) log( "Parsing b[]: " + cookieValue.toString()); ByteChunk bc=cookieValue.getByteChunk(); processCookieHeader( bc.getBytes(), bc.getOffset(), bc.getLength()); } else { if( dbg>0 ) log( "Parsing S: " + cookieValue.toString()); processCookieHeader( cookieValue.toString() );