views:

147

answers:

1

Hi.

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

A: 

Hi,

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);
        }
    });
Ahmed Ashour