tags:

views:

102

answers:

1

Hello, I want to find a way to get the settings of the request that would be sent if I clicked a certain link. I want to send the request after making some modifications. Is that possible?

Answering the comments, right now I want to change the headers sent, but post values or target url may be of interest too. I want to grab the request before it is sent, modify it and send.

+2  A: 

You can subclass HttpWebConnection and manipulate the 'settings', as in:

    webClient.setWebConnection(new HttpWebConnection(webClient) {
        public WebResponse getResponse(WebRequestSettings settings) throws IOException {
            System.out.println(settings.getUrl());
            return super.getResponse(settings);
        }
    });
Ahmed Ashour
Thanks a lot....
roddik