public void parse(final SetCookie cookie, String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } if (value == null || value.trim().length() == 0) { value = "/"; } cookie.setPath(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 max-age attribute"); } final int age; try { age = Integer.parseInt(value); } catch (final 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)); }
@Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); if (TextUtils.isBlank(value)) { return; } final Matcher matcher = MAX_AGE_PATTERN.matcher(value); if (matcher.matches()) { final int age; try { age = Integer.parseInt(value); } catch (final NumberFormatException e) { return; } final Date expiryDate = age >= 0 ? new Date(System.currentTimeMillis() + age * 1000L) : new Date(Long.MIN_VALUE); cookie.setExpiryDate(expiryDate); } }
@Override public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { Args.notNull(cookie, "Cookie"); cookie.setComment(value); }
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException { if (cookie == null) { throw new IllegalArgumentException("Cookie may not be null"); } cookie.setSecure(true); }