开发者

htmlunit cookie/refer question

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 Html开发者_StackOverflow中文版Unit 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


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);
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜