[Webtest] Re: HTTP error 302
John and Pip
John and Pip" <pipandjohn@gmail.com
Fri, 5 Jan 2007 01:33:01 +1300
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
>