From: Brad C. <yo...@br...> - 2005-03-02 16:15:32
|
Assuming that this works in the browser for you then it's likely a bug with no simple fix (you could pull latest CVS and make a custom RefreshHandler but it would not be a generic fix because the data it's given would be incorrect). That seems like a strange thing to specify in a Location header for the response you expect. Is there a spec anywhere on interpretation of incomplete URIs in HTTP Location headers? --- Mike Firth <mik...@ho...> wrote: > Hi, > > Is there a quick workaround to this problem? And should I submit it as a > bug? > > A redirect (302) occurs in a frame. It specifies a relative location, but > HtmlUnit is truncating the address, causing the website to respond with the > whole frameset. When autoredirect is on, this causes an infinite loop! I > never get past webClient.getPage(url) and the log fills up with: > > 22:33:15,132 (HttpMethodDirector:780) INFO [main] - Redirect requested but > followRedirects is disabled > 22:33:17,059 (HttpMethodDirector:780) INFO [main] - Redirect requested but > followRedirects is disabled > etc, etc, etc. > > My code: > final WebClient webClient = new > WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); > webClient.setRedirectEnabled(true); > final URL url = new URL("http://somewhere.com/main/"); > final HtmlPage page = (HtmlPage) webClient.getPage(url); > > The response is 200 OK and this: > > <html> > <head> > <title>somewhere.com</title> > <meta http-equiv="Content-Type" content="text/html"> > </head> > <frameset rows="0,*" frameborder="NO" border="0" framespacing="0"> > <frame src="blank.php" name="stealthFrame" scrolling="NO" noresize > > <frame src="front.php" name="frontFrame"> > </frameset> > <noframes> > <body> > </body></noframes> > </html> > > but front.php returns 302 Found, with location: ?choice=first , which should > cause this: > > GET /main/front.php?choice=first > > but instead HtmlUnit does this: > > GET /main/?choice=first > > which the website responds to by sending the first page again. Instant loop. > > Is there a quick workaround? How do you code to handle a redirect manually? > > Regards, > > Mike |