WebClient is using apache httpclient, so it is an HttpClient problem.
From my experience, it has to do with redirections. I've gotten rid of this problem using HttpClient and registering my own cookie support:
// Create a local instance of cookie store
CookieStore cookieStore = new BasicCookieStore();
// Bind custom cookie store to the local context
httpclient.setCookieStore(cookieStore);
CookieSpecFactory csf = new CookieSpecFactory() {
public CookieSpec newInstance(HttpParams params) {
return new BrowserCompatSpec() {
@Override
public void validate(Cookie cookie, CookieOrigin origin)
throws MalformedCookieException {
// Oh, I am easy.
// Allow all cookies
log.debug("custom validate");
}
};
}
};
httpclient.getCookieSpecs().register("easy", csf);
httpclient.getParams().setParameter(
ClientPNames.COOKIE_POLICY, "easy");
Well, in HtmlUnit I have no direct access to httpclient, but I'm thinking of changing its source code to do so, as I need to connect to wordpress with JavaScript support.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…