hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: question about following redirects
Date Fri, 02 Feb 2007 17:01:41 GMT
Hello Reeve,

> What I am trying to do, is post some data to a form, if the form sees
> the key "secure_payload' in the query string it needs to perform an auto
> login into the site vs a traditional login. It then redirects me to a
> new page which I need to get the response and display 

Have you enabled or disabled automatic redirects? In other words, do
you have a problem with the default behavior of HttpClient, or one in
your application?

> Rather when I  try to follow the redirect url by doing a  get 
> 
> I get a 
> 
>    Method failed : HTTP/1.1 320 Found , when I do a post .

Do you get that problem when executing the POST, or when doing
the followup GET? Is the "Method failed" a message from your code?
320 is not a defined status code. Message "Found" is assigned to
status code 302.

> Which is what
> I expect as I need to follow this to the new resource.
> 
>    <html><head><title>Object moved</title></head><body>

> 
>    <h2>Object moved to <a href="/AWD/login.aspx">here</a>.</h2>
> 
>   </body></html>
> 
>  
> 
> Then it throws 
> 
> java.lang.IllegalArgumentException: host parameter is null 

Servers are required to send absolute URLs in a redirect, but
many don't. If you've tried to send a GET request to a relative
URL, this is the what you might see. You have to resolve the
relative URL manually.

> ########################################################################
> This is what I have in my code

>             //check the response code
> 
>             // 200 status ok
> 
>             if (statusCode != HttpStatus.SC_OK) {
> 
>                 System.out.println("Method failed: " +
> post.getStatusLine());
> 
>             }    

If you expect a redirect with status code 302, why do you
print "Method failed" if you get anything but status 200?

I didn't look into the log, see Oleg's comment on HttpClient version.

cheers,
  Roland

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


Mime
View raw message