You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by "Delimon, Alan" <Al...@xerox.com> on 2006/03/24 22:48:47 UTC
Entity enclosing requests cannot be redirected without user intervention
Recently we converted a servlet using HTTPClient to talk to a webapp
server from 2.02 to 3.0. Under 2.02 everything worked fine.
Under 3.0, when we do a form post using client side javascript in the
webapp server, we get this exception:
java.lang.IllegalArgumentException: Entity enclosing requests cannot be
redirected without user intervention
at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.setFollowRed
irects(EntityEnclosingMethod.java:221)
The Javadoc for setFollowRedirects says that this was implemented as
part of RFC 2616. Was this added in 3.0, and if so, will I not be able
to use 3.0 to do this type of request? If so I think it's probably OK
for us to use 2.02 for now.
Re: question on javascript
Posted by Roland Weber <ht...@dubioso.net>.
Hi Song,
sorry for the late reply. I already tried yesterday but had
problems with my mail server. Then, I forgot to try again :-(
> <script language="javascript">
> <!--
>
> function load_results() {
> document.location.href = "http://www.google.com";
> }
>
> setTimeout("load_results()", 1000);
>
> // --></script>
>
> What I am interested is the redirected page, in this
> case "http://www.google.com". I guess I could parse
> the html file and figure out I should sleep for 1 sec
> and load www.google.com. Is there a better way to do
> that?
Forget about the second and fetch the page right away.
> Also from HttpClient side, is there a way to
> simulate
> the browser behavior as how browser runs javascript?
Nope, and there never will be. HttpClient is not a browser.
We don't interpret content, be it JavaScript or HTML.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
question on javascript
Posted by Song Chang <cs...@yahoo.com>.
Hi, I use HttpClient to retrieve a html page. And that
page has something like the following:
<script language="javascript">
<!--
function load_results() {
document.location.href = "http://www.google.com";
}
setTimeout("load_results()", 1000);
// --></script>
What I am interested is the redirected page, in this
case "http://www.google.com". I guess I could parse
the html file and figure out I should sleep for 1 sec
and load www.google.com. Is there a better way to do
that? Also from HttpClient side, is there a way to
simulate
the browser behavior as how browser runs javascript?
Song
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: Entity enclosing requests cannot be redirected without user intervention
Posted by Oleg Kalnichevski <ol...@apache.org>.
Delimon, Alan wrote:
> Recently we converted a servlet using HTTPClient to talk to a webapp
> server from 2.02 to 3.0. Under 2.02 everything worked fine.
>
>
>
> Under 3.0, when we do a form post using client side javascript in the
> webapp server, we get this exception:
>
> java.lang.IllegalArgumentException: Entity enclosing requests cannot be
> redirected without user intervention
>
> at
> org.apache.commons.httpclient.methods.EntityEnclosingMethod.setFollowRed
> irects(EntityEnclosingMethod.java:221)
>
>
>
> The Javadoc for setFollowRedirects says that this was implemented as
> part of RFC 2616. Was this added in 3.0, and if so, will I not be able
> to use 3.0 to do this type of request? If so I think it's probably OK
> for us to use 2.02 for now.
>
>
Alan,
Per default HttpClient automatically handles redirects for all non
entity enclosing methods. Just do not PostMethod#setFollowRedirects() to
true in your code and everything should be fine. See the HttpClient
redirect handling guide for details:
http://jakarta.apache.org/commons/httpclient/redirects.html
You can continue using HttpClient 2.0.2 if it still serves you well,
however it is no longer maintained and supported
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org