I'm using the following snippet of code to add a cookie to an http request in Android, sent using Android's DefaultHttpClient:
CookieStore cookieStore = new BasicCookieStore();
BasicClientCookie2 cookie = new BasicClientCookie2("AUTH_TOKEN", "MY_TOKEN");
cookie.setVersion(1);
cookie.setDomain("my.domain.com");
cookie.setPath("/");
cookieStore.addCookie(cookie);
context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
When I look at the received cookie value on the server, I get
Cookie: $Version=1; AUTH_TOKEN="MY_TOKEN"
but what I am expecting is (notice the missing quotes):
Cookie: $Version=1; AUTH_TOKEN=MY_TOKEN
Unfortunately, the extra quotes causes the server (which I don't manage) to choke, and completely ignore the cookie.
I tried using BasicClientCookie
instead of BasicClientCookie2
with no luck. Is there a fix for this or am I missing something obvious?