Hi Marc,
I think you must be right because I made my fix to 1303 but when I
sucked down 1305, and applied my fix, it now works fine. Thanks!
That still leaves the question I asked: "I don't know how to go about
requesting this change for the next htmlunit release, if people think
it is a sensible one."
I think the change would be to replace:
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.");
else if ((statusCode == 301 || statusCode == 307)
&& method.equals(SubmitMethod.GET) ) {
final WebRequestSettings wrs = new
WebRequestSettings(webRequestSettings, newUrl);
wrs.setRequestParameters(parameters);
return loadWebResponse(wrs);
}
With simply:
if ((statusCode == 301 || statusCode == 307 || statusCode == 302)
&& method.equals(SubmitMethod.GET) ) {
final WebRequestSettings wrs = new
WebRequestSettings(webRequestSettings, newUrl);
wrs.setRequestParameters(parameters);
return loadWebResponse(wrs);
}
which assumes that 302 is only used for GETs if we are redirecting
through to the same page, and that it is always OK to allow this
through. those assumptions appear OK to me but what would I know?
In fact I think the next chunk of code would then never be called (in
fact it looks to me like it is never called even now?) and could be
removed:
else if (statusCode <= 303) {
final WebRequestSettings wrs = new
WebRequestSettings(webRequestSettings, newUrl);
wrs.setSubmitMethod(SubmitMethod.GET);
return loadWebResponse(wrs);
}
Can you advise me please Marc - when you get time?
regards,
John
On 1/6/07, Marc Guillemot <[EMAIL PROTECTED]> wrote:
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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
>> > [email protected]
>> > http://lists.canoo.com/mailman/listinfo/webtest
>> >
>>
> _______________________________________________
> WebTest mailing list
> [email protected]
> http://lists.canoo.com/mailman/listinfo/webtest
>
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest