I am setting 2 Cookies in CookieStore using HttpContext. But only one
cookie seems to be going on Http. Can someone please help me as to why
that would be the case?
output shows:
17:30:21,879 INFO [STDOUT] INFO ApacheCookieUtils - Domain null
nameqbn.ptc.authId value212163844 pathnull version1
17:30:21,879 INFO [STDOUT] INFO ApacheCookieUtils - Domain null
nameqbn.ptc.ticket valueV1-4-KLR_cmMlPijWrrDDINX4kQ pathnull version1
But I only see the first one going out. This util is reasing from
Servlet Cookie Object.
-----
private HttpContext getHttpClientCookie() {
CookieStore cookieStore = new BasicCookieStore();
HttpContext httpContext = new BasicHttpContext();
if (null != request.getServletCookie()){
for (Cookie c : request.getServletCookie()){
cookieStore.addCookie(ApacheCookieUtils.apacheCookieFromServletCookie(c));
}
}
httpContext.setAttribute(ClientContext.COOKIE_STORE,
cookieStore);
return httpContext;
}
public static org.apache.http.cookie.Cookie
apacheCookieFromServletCookie(Cookie cookie) {
if(cookie == null) {
return null;
}
BasicClientCookie apacheCookie = null;
// get all the relevant parameters
String domain = cookie.getDomain();
String name = cookie.getName();
String value = cookie.getValue();
String path = cookie.getPath();
int maxAge = cookie.getMaxAge();
boolean secure = cookie.getSecure();
log.info("Domain " + domain + " name" + name + " value" + value +
" path" + path + " version" + cookie.getVersion());
// create the apache cookie
apacheCookie = new BasicClientCookie(name, value);
apacheCookie.setDomain(domain);
apacheCookie.setPath(path);
apacheCookie.setSecure(secure);
// set additional parameters
apacheCookie.setComment(cookie.getComment());
apacheCookie.setVersion(cookie.getVersion());
// return the apache cookie
return apacheCookie;
}
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]