+ cookieToString(cookie) + "\". " + ex.getMessage()); if (this.log.isWarnEnabled()) { this.log.warn("Invalid cookie header: \"" + header + "\". " + ex.getMessage());
throw new IllegalArgumentException("Cookie origin may not be null"); String headervalue = header.getValue(); boolean isNetscapeCookie = false; int i1 = headervalue.toLowerCase(Locale.ENGLISH).indexOf("expires="); ParserCursor cursor; if (header instanceof FormattedHeader) { buffer = ((FormattedHeader) header).getBuffer(); cursor = new ParserCursor( ((FormattedHeader) header).getValuePos(), buffer.length()); } else { String s = header.getValue(); if (s == null) { throw new MalformedCookieException("Header value is null"); buffer = new CharArrayBuffer(s.length()); buffer.append(s); cursor = new ParserCursor(0, buffer.length()); elems = header.getElements();
@Override public final List<Cookie> parse(final Header header, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(header, "Header"); Args.notNull(origin, "Cookie origin"); if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) { throw new MalformedCookieException("Unrecognized cookie header: '" + header.toString() + "'"); buffer = ((FormattedHeader) header).getBuffer(); cursor = new ParserCursor(((FormattedHeader) header).getValuePos(), buffer.length()); } else { final String s = header.getValue(); if (s == null) { throw new MalformedCookieException("Header value is null"); buffer = new CharArrayBuffer(s.length()); buffer.append(s); cursor = new ParserCursor(0, buffer.length()); return Collections.emptyList(); if (cursor.atEnd()) { return Collections.emptyList(); cursor.updatePos(cursor.getPos() + 1); if (valueDelim != '=') { throw new MalformedCookieException("Cookie value is invalid: '" + header.toString() + "'");
@Override public List<Cookie> parse(final Header header, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(header, "Header"); Args.notNull(origin, "Cookie origin"); if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) { throw new MalformedCookieException("Unrecognized cookie header '" + header.toString() + "'"); } final HeaderElement[] elems = header.getElements(); return parse(elems, origin); }
HeaderElement[] elems = header.getElements(); String value = headerelement.getValue(); if (name == null || name.length() == 0) { throw new MalformedCookieException("Cookie name may not be empty"); if (header.getName().equals(SM.SET_COOKIE2)) { cookie = createCookie2(name, value, origin); } else {
@Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } if (value.trim().isEmpty()) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (value == null) { throw new MalformedCookieException("Missing value for expires attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } cookie.setExpiryDate(expiry); }
final CookieManager cookieManager = getCookieManager(); if (cookieManager.isCookiesEnabled()) { final CharArrayBuffer buffer = new CharArrayBuffer(cookieString.length() + 22); buffer.append("Set-Cookie: "); buffer.append(cookieString); + cookieString + "'; reason: '" + e.getMessage() + "'.", origin);
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } if (value.trim().length() == 0) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); }
@Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (cookie.getVersion() < 0) { throw new MalformedCookieException("Cookie version may not be negative"); } }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException("Missing value for max-age attribute"); } int age; try { age = Integer.parseInt(value); } catch (NumberFormatException e) { throw new MalformedCookieException ("Invalid max-age attribute: " + value); } if (age < 0) { throw new MalformedCookieException ("Negative max-age attribute: " + value); } cookie.setExpiryDate(new Date(System.currentTimeMillis() + age * 1000L)); }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException("Missing value for version attribute"); } if (value.trim().length() == 0) { throw new MalformedCookieException("Blank value for version attribute"); } try { cookie.setVersion(Integer.parseInt(value)); } catch (NumberFormatException e) { throw new MalformedCookieException("Invalid version: " + e.getMessage()); } }
} catch (MalformedCookieException e) { // This means the cookie was wrong for the URL log.info("Not storing invalid cookie: <{}> for URL {} ({})", cookieHeader, url, e.getLocalizedMessage()); continue;
@Override public final List<Cookie> parse(final Header header, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(header, "Header"); Args.notNull(origin, "Cookie origin"); if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) { throw new MalformedCookieException("Unrecognized cookie header: '" + header.toString() + "'"); buffer = ((FormattedHeader) header).getBuffer(); cursor = new ParserCursor(((FormattedHeader) header).getValuePos(), buffer.length()); } else { final String s = header.getValue(); if (s == null) { throw new MalformedCookieException("Header value is null"); buffer = new CharArrayBuffer(s.length()); buffer.append(s); cursor = new ParserCursor(0, buffer.length()); return Collections.emptyList(); if (cursor.atEnd()) { return Collections.emptyList(); cursor.updatePos(cursor.getPos() + 1); if (valueDelim != '=') { throw new MalformedCookieException("Cookie value is invalid: '" + header.toString() + "'");
public List<Cookie> parse(final Header header, final CookieOrigin origin) throws MalformedCookieException { Args.notNull(header, "Header"); Args.notNull(origin, "Cookie origin"); if (!header.getName().equalsIgnoreCase(SM.SET_COOKIE)) { throw new MalformedCookieException("Unrecognized cookie header '" + header.toString() + "'"); } final HeaderElement[] elems = header.getElements(); return parse(elems, origin); }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } if (value.trim().length() == 0) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (value == null) { throw new MalformedCookieException("Missing value for expires attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } cookie.setExpiryDate(expiry); }
final CookieManager cookieManager = getCookieManager(); if (cookieManager.isCookiesEnabled()) { final CharArrayBuffer buffer = new CharArrayBuffer(cookieString.length() + 22); buffer.append("Set-Cookie: "); buffer.append(cookieString); + cookieString + "'; reason: '" + e.getMessage() + "'.", origin);
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null) { throw new MalformedCookieException("Missing value for domain attribute"); } if (value.trim().length() == 0) { throw new MalformedCookieException("Blank value for domain attribute"); } cookie.setDomain(value); }
@Override public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } String name = cookie.getName(); if (name.indexOf(' ') != -1) { throw new MalformedCookieException("Cookie name may not contain blanks"); } if (name.startsWith("$")) { throw new MalformedCookieException("Cookie name may not start with $"); } super.validate(cookie, origin); }