Yes, this is my concern as well. Also, in cases of multiple redirects (301 to 302 to 200), you are unable to ascertain the correct location.
In the mean time, I've turned off redirects using setFollowRedirects to false, and implements a response collection mechanism that sets a boolean if a redirect is encounterd, and creates an ordered lists of the URLs visited and their response codes. It would be nice if this were incorporated into the framework; I'm new to the project, so it might be the case that HttpClient is simply meant to be embedded in GUI applications, which may not require this level of transparency, but for using HttpClient within an application like a crawler (as I am), it would help a great deal to make this change. I'm happy to contribute whatever I have. If there is another project that is more suited to the application type I'm developing, please let me know, but I've been very satisfied with HttpClient. Thanks! Greg Gershman -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, January 07, 2005 9:38 AM To: HttpClient Project Subject: Re: Getting 200 code when 301 is executed Ortwin Gl�ck <ortwin.glueck 'at' nose.ch> writes: > 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); If I'm correct, this makes HttpClient users unable to be more than "conditionally compliant" with the HTTP specifications. To be fully compliant, one must (e.g. SHOULD is used in RFC) not refer anymore to a permanently moved resource (301), which is not the case with a temporarily moved resource (302), and there is no way to distinguish between these two cases using your proposed technique. -- Guillaume Cottenceau --------------------------------------------------------------------- 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]
