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 Roland Weber <ht...@dubioso.net> on 2007/02/19 19:52:50 UTC

Re: Problem posting login information (ajax)

Hello Marcelo,

> But this url has a redirect!

What is the problem? HttpClient typically follows redirects
automatically if configured to do that:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpMethod.html#setFollowRedirects(boolean)

There are few cases where HttpClient is not allowed to follow
the redirect without user interaction. In that case, your
application will get a 3xx response and you can take the
target URL from the "Location" header in the response.

hope that helps,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Problem posting login information (ajax)

Posted by Roland Weber <ht...@dubioso.net>.
Hello Marcelo,

> I always send the parameters to the final url when posting data,

That is wrong. If the server application expects the POST data at
URL X and then sends you to URL Y after processing the posted data,
you can't just post the data to URL Y and expect that to work.
Please take the time to study the Client HTTP Programming Primer:
http://wiki.apache.org/jakarta-httpclient/ForAbsoluteBeginners

> Besides, when I set method.setFollowRedirects(true) and execute this
> method, i receive an error:
> java.lang.IllegalArgumentException: Entity enclosing requests cannot be
> redirected without user intervention

That is an error message from HttpClient...

> and a statuscode 500.

...and that is a status code from the server. How do you get both
at once? If an exception is thrown, you shouldn't get a status code!?

Regarding the exception (and Michelle's question), see RFC 2616.
Section 10.3 (http://rfc.net/rfc2616.html#s10.3):

   The action
   required MAY be carried out by the user agent without interaction
   with the user if and only if the method used in the second request is
   GET or HEAD.

Section 10.3.3 (http://rfc.net/rfc2616.html#s10.3.3):

   If the 302 status code is received in response to a request other
   than GET or HEAD, the user agent MUST NOT automatically redirect the
   request unless it can be confirmed by the user

Section 10.3.8 (http://rfc.net/rfc2616.html#s10.3.8):

   If the 307 status code is received in response to a request other
   than GET or HEAD, the user agent MUST NOT automatically redirect the
   request unless it can be confirmed by the user


HttpClient will never interact with the user directly, and therefore
is not allowed to follow such redirects automatically.

cheers,
  Roland

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Problem posting login information (ajax)

Posted by Marcelo Chryssovergis <ma...@iea.org.br>.
Well,

I always send the parameters to the final url when posting data, and this is 
not the final.

Besides, when I set method.setFollowRedirects(true) and execute this method, 
i receive an error:
java.lang.IllegalArgumentException: Entity enclosing requests cannot be 
redirected without user intervention
and a statuscode 500.

ideas?
Thanks,
Marcelo


----- Original Message ----- 
From: "Roland Weber" <ht...@dubioso.net>
To: "HttpClient User Discussion" <ht...@jakarta.apache.org>
Sent: Monday, February 19, 2007 3:52 PM
Subject: Re: Problem posting login information (ajax)


> Hello Marcelo,
>
>> But this url has a redirect!
>
> What is the problem? HttpClient typically follows redirects
> automatically if configured to do that:
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpMethod.html#setFollowRedirects(boolean)
>
> There are few cases where HttpClient is not allowed to follow
> the redirect without user interaction. In that case, your
> application will get a 3xx response and you can take the
> target URL from the "Location" header in the response.
>
> hope that helps,
>  Roland
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Problem posting login information (ajax)

Posted by Marcelo Chryssovergis <ma...@iea.org.br>.
When I try to access directly (with a browser) the url I´m using to send the 
login parameters with httpclient, it returns an alert box:

"Error. This may be due to an unsupported browser.
See the mailing lists at http://www.getahead.ltd.uk/dwr/ for more 
information"



>
> What is the problem? HttpClient typically follows redirects
> automatically if configured to do that:
> http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpMethod.html#setFollowRedirects(boolean)
>
> There are few cases where HttpClient is not allowed to follow
> the redirect without user interaction. In that case, your
> application will get a 3xx response and you can take the
> target URL from the "Location" header in the response.
>
> hope that helps,
>  Roland
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Problem posting login information and redirect

Posted by Erxiang Liu <er...@us.ibm.com>.

I have the same problem. I did a post and also setFollowRedirects to true.
But it did not go to the Location automatically. I had to
manually read the location from the header and then do a get again. Any
idea?

thanks,

Michelle



                                                                           
             Roland Weber                                                  
             <http-async@dubio                                             
             so.net>                                                    To 
                                       HttpClient User Discussion          
             02/19/2007 12:52          <httpclient-user@jakarta.apache.org 
             PM                        >                                   
                                                                        cc 
                                                                           
             Please respond to                                     Subject 
             "HttpClient User          Re: Problem posting login           
                Discussion"            information (ajax)                  
             <httpclient-user@                                             
             jakarta.apache.or                                             
                    g>                                                     
                                                                           
                                                                           
                                                                           




Hello Marcelo,

> But this url has a redirect!

What is the problem? HttpClient typically follows redirects
automatically if configured to do that:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpMethod.html#setFollowRedirects(boolean)


There are few cases where HttpClient is not allowed to follow
the redirect without user interaction. In that case, your
application will get a 3xx response and you can take the
target URL from the "Location" header in the response.

hope that helps,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org