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: Cookie and Post Issue..
Date Wed, 21 Jun 2006 13:28:44 GMT
Hello Henry,

please sit back, relax, and then explain in detail what you
are trying to do. I assumed that you are interacting with
a web page from a browser, and want to do the same thing
automatically from an application. But I am obviously wrong,
since that does not explain the existence of a servlet.

In response to some of your questions: if you have HttpClient
configured to automatically follow redirects, you won't see
30x response codes in the application.
In the wire log you sent, I can see that the server is sending
a page with some JavaScript that is auto-executed by browsers:

<script language="javascript">function submitform() {
document.frmdologin.submit(); }</script></head>
<body onload="submitform();"><center><b>Logging in...please
  <form name="frmdologin" method="post" action="
     <input type="hidden" name="message" value="Your browser is not
accepting the login cookie.  Please enable cookies in your browser.">

HttpClient is not going to do that for you. You'll have to send
another POST request to the URL given in the action= attribute,
with the parameters from that form. I don't think that the value
of the "message" parameter matters much, but you never know
until you tried.

You have sent some code that is absolutely pointless:

    Cookie[] cookies = httpClient.getState().getCookies();
    if (cookies.length == 0) {
    } else {
        for (int i = 0; i < cookies.length; i++) {
            System.out.println(" - " + cookies[i].toExternalForm());

Have a look at the else{} block - why are you putting
the cookies into the state from which you just got them?

Regarding URLs from the address bar, the primer says that you
can't determine the target address of a POST request reliably
by looking at the address bar. You can see an example above:
the server returns a page that implements a redirect by POST.
You're not even going to see more than a flicker in your browser
of that step. Afterwards, the address bar shows "/v240/..."
but the original POST request had to be sent to "/user/...".
The primer doesn't say you shouldn't use full URLs. It just says
you should get them from looking at the returned HTTP headers
and HTML code, not from looking at the address bar of the browser.
I'll review the primer some of these days, maybe I can point
that out more clearly.

hope that helps,

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

View raw message