如何在GAE上向HtmlUnit webclient添加cookie

时间:2017-02-26 12:33:53

标签: java google-app-engine cookies htmlunit

我想向webclient添加一个cookie,这段代码在GAE之外按预期工作:

WebClient webClient = new WebClient(CHROME);
webClient.addCookie("storepath=us/en", new URL("http://www.zara.com/"), null);

但是在GAE上它会抛出:

java.lang.IllegalArgumentException: Port may not be negative
    at org.apache.http.util.Args.notNegative(Args.java:115)
    at org.apache.http.cookie.CookieOrigin.<init>(CookieOrigin.java:52)
    at com.gargoylesoftware.htmlunit.CookieManager.buildCookieOrigin(CookieManager.java:102)
    at com.gargoylesoftware.htmlunit.WebClient.addCookie(WebClient.java:2258)

如何在GAE上添加此Cookie?

1 个答案:

答案 0 :(得分:1)

有一个关于此的GAE bug,可能你应该在那里创建一个新的,因为根本原因仍然存在。

要解决它,您可以使用:

using