I am trying to connect to some website using the HTMLUnit library. The problem is that my HTMLUnit client does not accept cookies from this site with the following message:
WARNING: Cookie rejected: "[version: 0] [name: remixchk] [value: 5] [domain: .vkontakte.ru] [path: /] [expiration: Tue Feb 21 08:53:46 MSK 2012]". Illegal domain attribute "vkontakte.ru". Domain of origin: "login.vk.com"
This is due to the fact that the login form is sent to an address different from the site address.
I need to change the cookie policy in my client. I know that I have to rewrite the method getCookiesin the class CookieManager. I did this in a subclass CookieManagerand then changed CookieManagermy client this way:
webClient.setCookieManager(new mySubclassedCookieManager());
But it does not change anything. Moreover, when a cookie is rejected, the getCookies method never starts.
Where did I go wrong? How to force HTMLUnit to accept this cookie?
source
share