Hello, 

I'm having an issue where a cookie set by posting to a https:// link is not being 
recognized/picked up when i make a http:// call.  

I'm using HttpClient and PostMethod to send username/password to be authenticated at 
the https link.  Once authenticated, a cookie is set by the server and then I make a 
http call using GetMethod to access the link I need.  However, the http call does not 
pickup the cookie and I get redirected to authenticate again.  If I make a https get 
call after the cookie is set, the link works fine in detecting the cookie, the problem 
is with http calls.  Can someone help by telling me how to make the cookie visible to 
http when it has been set by https?

Below is my sample code:

         //Setup the httpclient
         HttpClient client = new HttpClient();
         client.setTimeout(TIMEOUT);
         client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);

         Protocol.registerProtocol("https", new Protocol("https",
                                        new EasySSLProtocolSocketFactory(), 443));

         String authenticationURL = "https://somelink";;

        //Post the username/password to the authentication URL
        PostMethod postUserPasswod = new PostMethod(authenticationURL);
        postUserPasswod.setFollowRedirects(true);
        postUserPasswod.addParameter("USER",username);
        postUserPasswod.addParameter("PASSWORD",password);


        //Execute the Post, If Successful a authentication cookie will be set
        //Then continue executing the request

        client.executeMethod(postUserPasswod);


          GetMethod requestURL = new GetMethod("http://somelink/test.html";);
          client.executeMethod(requestURL );
          ins = new BufferedInputStream(requestURL .getResponseBodyAsStream());

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to