[Webtest] Re: HTTP error 302

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Fri, 05 Jan 2007 12:09:07 +0100


Hi John,

I think that this was a consequence of
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1627983&group_id=47038

which is now fixed in htmlunit's SVN.

Marc.

John and Pip wrote:
> 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
> 
> On 1/5/07, John and Pip <pipandjohn@gmail.com> wrote:
>> 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 <mguillemot@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.
>> >
>> > _______________________________________________
>> > WebTest mailing list
>> > WebTest@lists.canoo.com
>> > http://lists.canoo.com/mailman/listinfo/webtest
>> >
>>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>