I'm using Retrofit (1.7.1) that uses the default OkHttp (2.1.0) client (I guess) to authenticate on a server and get some session cookies to reply with each other request.
I have a CookieManager and an Interceptor that sets the "Cookie" header.
The interceptor builds the cookie as
cookieName + "=" + cookieValue + "; "
(I actually use a StringWriter but the results its the same)
The correct headers result should be:
Cookie: PHPSESSID=<my_php_sess_id>; session=<my_session_id>;
BUT
The default implementation (OkHttp I guess) adds another Cookie header resulting in:
Cookie: PHPSESSID=<my_php_sess_id>; session=<my_session_id>;
Cookie: $Version="1"; PHPSESSID="<my_php_sess_id>";$Path="/";$Domain="<my_domain>"; session="<my_session_id>";$Path="/";$Domain="<my_domain>"
I could find the second header only inspecting the network packets with WireShark, all the libraries logs shows only the first one.
I think this second header causes some trouble: note the quotes around the cookie value.
Is there a way to tell OkHttp, or Retrofit, to use the "plain" version of the cookie?
Maybe I misunderstood all the whole Cookie/Client/Interceptor mechanism, but setting the Retrofit client to:
.setClient(new ApacheClient(new DefaultHttpClient()))
solved the problem.