22 messages in com.canoo.lists.webtestRe: [Webtest] Re: HTTP error 302
FromSent OnAttachments
John and Pip16 Nov 2006 13:01 
Charlie Kuharski16 Nov 2006 14:20 
John and Pip16 Nov 2006 14:38 
Charlie Kuharski16 Nov 2006 14:49 
Rob Manthey16 Nov 2006 15:14 
Rob Manthey16 Nov 2006 15:17 
John and Pip16 Nov 2006 16:35 
Aarathi Niranjan16 Nov 2006 17:48 
Rob Manthey16 Nov 2006 17:53 
Michael Habbert16 Nov 2006 23:07 
Marc Guillemot17 Nov 2006 00:04 
Paul King17 Nov 2006 00:28 
John and Pip17 Nov 2006 11:55 
John and Pip02 Jan 2007 11:10 
John and Pip02 Jan 2007 12:00 
John and Pip02 Jan 2007 12:37 
Marc Guillemot04 Jan 2007 01:24 
John and Pip04 Jan 2007 04:32 
John and Pip04 Jan 2007 18:38 
Marc Guillemot05 Jan 2007 03:08 
John and Pip06 Jan 2007 23:09 
Marc Guillemot08 Jan 2007 00:39 
Subject:Re: [Webtest] Re: HTTP error 302
From:John and Pip (pipa@gmail.com)
Date:01/04/2007 06:38:19 PM
List:com.canoo.lists.webtest

Hi Marc and all,

I just spent some time tracking down a problem with my test suite and found it is due to the new htmlunit jar mentioned below. I won't have a chance to check whether it is my change or the version of the code in svn until after the weekend, but the new problem (that goes away when I go back to the standard jar) is as follows:

When I have a form that is submitted, and then redisplayed with an error message e.g. if a field is not filled in correctly, and then I modify the field to fix the problem and resubmit, the modifcation seems to happen correctly (no problem recorded even in debug mode) but the old value and not the new value is posted back. Specifically this is happening for select dropdowns.

regards, John

Hi Marc and all,

Thanks for your response.

Yes, it is really a Get with a redirect to itself (302).

I agree about the ?. It is only my guess but I think from playing around a bit that when the site gets a URL that isn't quite right it redirects to a default one, which happened to be the one I was trying to hit a month or so ago, and so by pure coincidence the ? trick worked, but on the new page I'm trying to hit it doesn't and instead redirects to the other one.

I have managed to such down the htmlunit-1.10 source and patched it to just remove the ignoring of HTTP 302 Responses so that it now handled the redirect of a Get to itself, and it has solved the issue. I have a new jar file I can use.

I don't know how to go about requesting this change for the next htmlunit release, if people think it is a sensible one. The quick hack I did was:

patched WebClient.java: if (webRequestSettings.getSubmitMethod().equals(SubmitMethod.GET) && webResponse.getUrl().toExternalForm().equals(locationString) ) { // getLog().warn("Got a redirect but the location is the same as the page we just loaded " // + locationString + ". Skipping redirection."); // replaced with below 20070104 JWL: final WebRequestSettings wrs = new WebRequestSettings(webRequestSettings, newUrl); wrs.setRequestParameters(parameters); return loadWebResponse(wrs); // end of change 20070104 JWL:

Can you advise please ( I know you are a committer of htmlunit) ?

regards, John

On 1/4/07, Marc Guillemot <mgui@yahoo.fr> wrote:

Hi John,

which version of htmlunit do you use? Do you really have a initial GET (and not a POST) to url x followed by a redirect to url x again?

I don't really understand the trick with "?" instead of "/" and doubt that it safely works.

Marc.