htmlunit cookie/参考问题

发布于 2024-08-17 19:36:10 字数 208 浏览 2 评论 0原文

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

我搜索了多个文档,以及 HtmlUnit API 但没有运气,所以我假设我是缺少一些东西。

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

谢谢

汤姆

Testing out the java HtmlUnit lib. Trying to figure out if there's a way to set/delete the cookie file (cookiejar) used by the webclient object..

I've searched multiple docs, as well as the HtmlUnit API with no luck, so I'm assuming I'm missing something.

Also, is there a way to see the headers (request/respnse/referer) being xfered between the client/server during my testing...

thanks

tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

同展鸳鸯锦 2024-08-24 19:36:10

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

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

You can use webClient.getCookieManager(), and you can subclass HttpWebConnection as:

    webClient.setWebConnection(new HttpWebConnection(webClient) {
        public WebResponse getResponse(WebRequestSettings settings) throws IOException {
            System.out.println(settings.getUrl());
            return super.getResponse(settings);
        }
    });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文