class Cookies {

    public void set(HttpCookie cookie) {
        if (getHeader(HttpHeaders.COOKIE).isEmpty()) {
            request.setHeader(new BasicHeader(HttpHeaders.COOKIE, cookie.toString()));
        } else {
            //cookie always added to first cookie header found
            Header cookieHeader = getHeader(HttpHeaders.COOKIE).get(0);
            List<HttpCookie> cookieList = getAllCookiesFromHeader(cookieHeader);
            cookieList = cookieList.stream()
                .filter(c -> !c.getName().equalsIgnoreCase(cookie.getName()))
                .collect(Collectors.toList());
            cookieList.add(cookie);
            request.setHeader(getCookieHeader(cookieList));
        }
    }

    private  Cookies(HttpRequest request);

}