Hello,
I have a scenario in which I am sending a POST request to a server. The server replies with a 302 (Moved temporarily) status and sets the "Location" header to a URL which contains, in the form of parameter-value pairs, the actual results of the initial request. I am therefore interested in this new URL, but I do not want to actually follow it; I just need to get it. So far, I have not managed to do this.
If I set redirection to false, i.e.
con.setInstanceFollowRedirects(false);
then, after I submit the POST, the "Location" header is empty. As a side-note, I know it is not supposed to be empty, as I have tested this is Firefox and the "Location" header was set correctly.
If I set redirection to true, i.e.
con.setInstanceFollowRedirects(true);
then I end up with a 405 (Method not allowed) status message.
How can I get this URL? Is it possible to somehow read the "Location" header without performing the actual redirect?
Thanks in advance,
Catalin