Re: netclient ignores #set_redirect_mode method -- a test case
Gerd Stolpmann <[email protected]> Fri, 01 Jul 2005 11:15:39 +0200
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <[email protected]> |
Am Donnerstag, den 30.06.2005, 14:02 +0100 schrieb Richard Jones: > On Thu, Jun 30, 2005 at 01:59:28PM +0100, rich wrote: > > let url = "http://www.merjis.com" (* redirects to http://merjis.com/ *) > > Try also replacing that with: > > let url = "http://www.slashdot.org" > > The program still fails (as in, it redirects when it shouldn't), but > doesn't go into an eternal loop. I'm not sure why this is, since the > request and response headers look substantially the same in both > cases. > > The redirect on http://www.merjis.com/ is being done using > mod_rewrite, so there wouldn't seem to be anything unusual or > non-standard about it. Very funny examples. However, I think the root of the loop problem is on the server's side. Maybe netclient should become more intelligent to cope with such problems. So, what is going on: - http://www.merjis.com: Netclient requests with GET / HTTP/1.1 Host: www.merjis.com:80 and is then pointed to http://merjis.com (note that http://merjis.com and http://merjis.com/ have the same representation in HTTP): GET / HTTP/1.1 Host: merjis.com:80 and is then pointed to the same URL again. Of course, this is nonsense, but it is clearly the server's fault. Interestingly, the ":80" suffix confuses the server - if you omit it, the server does not respond with a redirection. - http://www.slashdot.org: This URL works, there is one redirection to http://slashdot.org. Here, the ":80" suffix does not confuse the server. You are right that netclient ignores #set_redirect_mode. This is a problem of improper initialisation order (method prepare, which is called just before sending the request, overwrites the current redirect mode). I think the following two changes should be made to improve the robustness: - Do not add ":80" to the "host" header. Other HTTP clients do not do this (although legal), and servers may get confused. - Limit the maximum number of redirections. I can do these changes soon. Gerd -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany [email protected] http://www.gerd-stolpmann.de ------------------------------------------------------------ ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click