void ensureContentLengthIsValid() { List<String> contentLengths = headers().getAll(CONTENT_LENGTH); checkArgument(contentLengths.size() <= 1, "Duplicate Content-Length found. %s", contentLengths); if (contentLengths.size() == 1) { checkArgument(isInteger(contentLengths.get(0)), "Invalid Content-Length found. %s", contentLengths.get(0)); } }
private Builder removeCookiesIf(Predicate<String> removeIfName) { Predicate<ResponseCookie> keepIf = cookie -> !removeIfName.test(cookie.name()); List<ResponseCookie> newCookies = decode(headers.getAll(SET_COOKIE)).stream() .filter(keepIf) .collect(toList()); return cookies(newCookies); }
private Builder removeCookiesIf(Predicate<String> removeIfName) { Predicate<ResponseCookie> keepIf = cookie -> !removeIfName.test(cookie.name()); List<ResponseCookie> newCookies = decode(headers.getAll(SET_COOKIE)).stream() .filter(keepIf) .collect(toList()); return cookies(newCookies); }