{
// Set cookie policy:
rcBuilder.setCookieSpec(CookieSpecs.BEST_MATCH);
// Add to CookieStore:
CookieStore store = new RESTClientCookieStore();
List<HttpCookie> cookies = request.getCookies();
for(HttpCookie cookie: cookies) {
BasicClientCookie c = new BasicClientCookie(
cookie.getName(), cookie.getValue());
c.setVersion(cookie.getVersion());
c.setDomain(urlHost);
c.setPath("/");
store.addCookie(c);
}
// Attach store to client:
hcBuilder.setDefaultCookieStore(store);
}