Handling Client-Side Redirection [Was: Problem in downloading a file]

Dear Mr. Edison Aspert,

	I am responding to your request for Jigsaw help.  I believe that your 
problem lies in the realm of "Handling Client-Side Redirects."

	To begin, I tried accessing the URL in question (http://www.cel.com/) with 
a web browser (IE5.5).  The browser was redirected to :

http://64.4.30.250/cgi-bin/linkrd?_lang=EN&lah=f83c92f27a62450860b6682571f738b5&lat=976991997&hm___action=http%3a%2f%2fwww%2ecel%2ecom%2f

So, I believe that the 302/"Moved Temporarily" message that you is actually 
correct.


	 Here is a piece of code that I use to Handle Client-Side Redirects:

		while(reply.getStatus() == 302){
		    String redirectURL = reply.getLocation();
		    request = manager.createRequest();
		    request.setURL(new URL(redirectURL));
		    reply = manager.runRequest(request);
		}

	However, this does not all Handling Client-Side Redirects.  Sometimes, 
reply.getLocation() holds a String that looks like "/foo/bar" or "?foobar", 
as opposed to "http://foo.bar.etc"  As such, you may have to use 
request.getHost() and "cut and paste" some of these URL Strings to properly 
follow the redirections.  (I am working on such code which I hope to 
implement as a Jigsaw filter, like CookieFilter, but it is not done yet).

	I hope that this helps you.

	Truly yours,
	John Philip Anderson
	Michigan, USA

	jpanderson_215@hotmail.com


>From: Edison Aspert <aspertedison@yahoo.com>
>To: www-jigsaw@w3.org
>Subject: Prolem in downloading a file
>Date: Fri, 15 Dec 2000 13:57:40 -0800 (PST)
>
>Hi,
>
>I am trying to download a file using the Jigsaw API.
>
>Here is the code
>
>HttpManager manager = HttpManager.getManager() ;
>Request request = manager.createRequest() ;
>request.setMethod("GET") ;
>request.setURL(new URL("http://www.cel.com/"));
>Reply    reply = manager.runRequest(request) ;
>// Get the reply input stream that contains the actual
>data:
>InputStream in = reply.getInputStream() ;
>System.out.println("Code "+reply.getStatus());
>//printing 302
>BufferedReader bufferedReader = new BufferedReader(new
>InputStreamReader(in));
>String inputLine;
>while ((inputLine = bufferedReader.readLine()) !=
>null)
>{
>	System.out.println(inputLine);
>	//writing to a file
>}
>System.out.println("Reason "+reply.getReason());
>
>For the url http://www.cel.com/ I am getting the
>message
>"Moved Temporarily" which is not correct.
>
>Please help me.
>
>Thanks in Advance.
>
>Aspert Edison
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Shopping - Thousands of Stores. Millions of Products.
>http://shopping.yahoo.com/
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Received on Saturday, 16 December 2000 14:06:35 UTC