开发者

htmlunit cookie/refer question

开发者 https://www.devze.com 2022-12-16 08:50 出处:网络
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..

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

精彩评论

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