commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ballard, Margaret" <Margaret.Ball...@planethome.com>
Subject AW: [httpclient] Problem with Post Redirect
Date Tue, 25 Mar 2003 09:00:53 GMT
Hello Adrian,

Thank you very much for your helpful reply. In preparing the wirelog and
debug logs
to send to you I think I may have stumbled upon the problem.  

I think that problem is that when I make the GET redirect, I somehow
lose my login information.  The website then tries to redirect me to
back to the login page.  I can see that the login was successfully made,
because it originally tries to redirect me to the successful login page.


I'm going to continue looking in this direction for now.  Takes me a
little while, because I'm new to this.  I wanted to say Thank You for
your help in the meantime.

Margaret

-----Ursprüngliche Nachricht-----
Von: Adrian Sutton [mailto:adrian.sutton@ephox.com]
Gesendet: Freitag, 21. März 2003 00:12
An: 'Jakarta Commons Users List'
Betreff: RE: [httpclient] Problem with Post Redirect


Hi Margaret,
Sorry for not replying to your last message, I generally try to at least
provide an I don't know but I'll ask the developers message to any
HttpClient messages I see, guess this one got lost in the ether of my
brain
somewhere.

Actually, this looks like a case that I will have to pass on to the
developers, but there are a few things that I can suggest that might
help
you find the problem and will definitely make the developers lives
easier.
If you could go through the suggestions at
http://jakarta.apache.org/commons/httpclient/troubleshooting.html and
provide whatever results you can that would be appreciated (the last
couple
of suggestions, using telnet and netcat probably aren't worth it at this
stage).  Particularly, the output of the wire trace would be useful,
instructions are available at
http://jakarta.apache.org/commons/httpclient/troubleshooting.html

It would definitely be worth finding out if it works correctly without
the
proxy in the middle if that's at all possible.  The results of a HEAD
method
on the exact URL that you are being redirected to might help as well.

erm, possibly the site is wanting a referrer header?  HttpClient doesn't
provide one by default.

It would be really good to see exactly what a browser sends in response
to
that behaviour so if you can access the url via http instead of https
and
use a packet sniffer that would help as well.  If not, I may be able to
simulate the server responses with netcat and the wire log from your
attempts with HttpClient, so don't spend too much effort on acquiring a
log
of a browser logging in.

That's about all I can come up with at the moment, if you can gather as
much
of that information as possible and hit me with it I'll see what I can
track
down for you.

Adrian Sutton, Software Engineer
Ephox Corporation
www.ephox.com


-----Original Message-----
From: Ballard, Margaret [mailto:Margaret.Ballard@planethome.com]
Sent: Friday, 21 March 2003 12:50 AM
To: Jakarta Commons Users List
Subject: [httpclient] Problem with Post Redirect


Hi,
 
I posted this last week, and haven't received a reply.  Trying it again
with
a more indicative Subject line. 
 
My problem is that I'm getting a status 405 "method not allowed" status
even
though the method I'm sending is a get method, and get is listed by the
response as an allowed method.  
 
How I get to this point: I am going through a proxy using ssl.  I post
login
information and then, after a successful login, am redirected to a new
page.  
I know that followRedirects is disabled for post, so I find out where
I'm 
being redirected to, and redirect myself by making a getmethod to the
redirect 
url. Result is what I listed above; a 405 "Method not allowed" Status
code.
 
Again, am I missing a step?  Is there another way to handle a post
redirect?
 
Code:
    public static void main(String[] args) throws Exception {
        HttpClient client = new HttpClient();
        client.getHostConfiguration().setProxy("ourproxy", 8080);
        HttpState state = new HttpState();
        state.setProxyCredentials("realm",new
  UsernamePasswordCredentials("proxyname","proxypassword"));
        client.setState(state);
        
        String _uri = "
https://secure.planethome.de/myplanet/login.jsp";
        GetMethod method = new GetMethod(_uri);
 
        int status = client.executeMethod(method);
 
        PostMethod postmethod = new PostMethod(_uri);
        
        // Add Request Body
        NameValuePair[] params = new NameValuePair[4];
        params[0] = new NameValuePair("hidden", "yes");
        params[1] = new NameValuePair("username", "username");
        params[2] = new NameValuePair("password", "password");
        params[3] = new NameValuePair("request", "login");
        postmethod.setRequestBody(params);
        
        // Execute Post
        status = client.executeMethod(postmethod);
 
        
        // Returns a Status Code 100, so I resubmit
        postmethod.recycle();
        status = client.executeMethod(postmethod);
        
        // This time, it returns a Status Code 302 Redirect,
        // so I find where it's redirecting to, and send a Get
        Header location = postmethod.getResponseHeader("Location");
        String redirect = location.getValue();
        GetMethod redirectmethod = new GetMethod(redirect);
        
        // Here's my problem - it returns a 405 Method not allowed
        // code.  But Get is listed as an Allowed Method in the Response
Header
        status = client.executeMethod(new GetMethod(redirect));
        
    }
 
 
Any help greatly appreciated!!
 
Margaret Ballard
 



Mime
View raw message