【问题标题】:htmlunit cookie/refer questionhtmlunit cookie/参考问题
【发布时间】:2010-01-13 12:46:14
【问题描述】:

测试 java HtmlUnit 库。试图弄清楚是否有办法设置/删除 webclient 对象使用的 cookie 文件 (cookiejar)..

我已经搜索了多个文档以及 HtmlUnit API,但没有成功,所以我假设我遗漏了一些东西。

另外,有没有办法在我的测试期间查看在客户端/服务器之间传输的标头(请求/响应/引用)...

谢谢

汤姆

【问题讨论】:

    标签: cookies htmlunit referer


    【解决方案1】:

    您可以使用webClient.getCookieManager(),并且可以将 HttpWebConnection 子类化为:

        webClient.setWebConnection(new HttpWebConnection(webClient) {
            public WebResponse getResponse(WebRequestSettings settings) throws IOException {
                System.out.println(settings.getUrl());
                return super.getResponse(settings);
            }
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-03
      • 2011-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多