Greg,
It is also possible to disable redirects and then handle them manually. Setting the HttpClient param "http.protocol.max-redirects" to 0 will do this. See <http://jakarta.apache.org/commons/httpclient/3.0/preference- api.html#HTTP%20client%20parameters>.
Mike
On Jan 7, 2005, at 4:14 AM, Ortwin Gl�ck wrote:
Hi Greg,
The redirect is completely handled inside HttpClient. You get the response code of the last request, which is 2xx normally. The only way to know if the request was redirected, is to compare the URI of the request after execution with the one before execution:
HttpMethod get = new GetMethod("...."); URI uri = get.getURI(); client.execute(get); boolean wasRedirected = ! method.getURI().equals(uri);
Ortwin Gl�ck
Gregory Gershman wrote:I'm upgrading from version 2.X to 3.X, looking to get rid of some of my
redirect code. I've noticed that when I hit a URL that returns a 301,
the new 3.1 client automatically redirects to the new Location, and
fetches it successfully. This is good, but the status code returned is
a 200, not a 301; I have no way of finding out if I should permanently
change the URL in my database. Is there access to the earlier request
responses? I would think that in the case of a 301, the response code
should not be 200...
Greg Gershman
-- _________________________________________________________________ NOSE applied intelligence ag
ortwin gl�ck [www] http://www.nose.ch software engineer hardturmstrasse 171 [pgp id] 0x81CF3416 8005 z�rich [office] +41-1-277 57 35 switzerland [fax] +41-1-277 57 12
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
