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 expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
class LenientCookieSpec extends BrowserCompatSpec { public LenientCookieSpec() { super(); registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(DATE_PATTERNS) { @Override public void parse(SetCookie cookie, String value) throws MalformedCookieException { if (TextUtils.isEmpty(value)) { // You should set whatever you want in cookie cookie.setExpiryDate(null); } else { super.parse(cookie, value); } } }); } }
@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"); 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"); 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"); 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"); 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); } }
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 expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
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 expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
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 expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
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 expires attribute"); } try { cookie.setExpiryDate(DateUtils.parseDate(value, this.datepatterns)); } catch (DateParseException dpe) { throw new MalformedCookieException("Unable to parse expires attribute: " + value); } }
@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 'expires' attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Invalid 'expires' attribute: " + value); } cookie.setExpiryDate(expiry); }
@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 'expires' attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Invalid 'expires' attribute: " + value); } cookie.setExpiryDate(expiry); }
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); }
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); }
@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 'expires' attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Invalid 'expires' attribute: " + value); } cookie.setExpiryDate(expiry); }
@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 'expires' attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Invalid 'expires' attribute: " + value); } cookie.setExpiryDate(expiry); }
@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 'expires' attribute"); } final Date expiry = DateUtils.parseDate(value, this.datepatterns); if (expiry == null) { throw new MalformedCookieException("Invalid 'expires' attribute: " + value); } cookie.setExpiryDate(expiry); }