Here's what comes back in the headers of the first request. Is this helpful?

*** Response ***
Status Line: HTTP/1.1 200 OK
Date: Wed, 07 Sep 2005 11:58:31 GMT
Server: Apache/1.3.33 (Unix) mod_jk/1.2.8 Sun-ONE-ASP/4.0.0 mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.11 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a
Set-Cookie: id=bmedia; expires=Wed,14-Sep-2005 10:37:31 GMT;
Set-Cookie: pw=solutions; expires=Wed,14-Sep-2005 10:37:31 GMT;
Set-Cookie: listing_search=;
Set-Cookie: listing_keyword=;
Set-Cookie: listing_pagenum=1;
Transfer-Encoding: chunked
Content-Type: text/html


Michael Becke wrote:

Hi Thom,

The 2109 implementation uses the version of the cookies set by the
server.  My guess is that the Set-Cookie header is setting the cookies
with version 0.  This is what 2109 will send back.

Mike

On 9/7/05, Thom Hehl <[EMAIL PROTECTED]> wrote:
OK, I think I'm beginning to understand what's going on with my cookie
problem, but need some more guidance if anyone can help.

Here is my sourcecode:

   /**
    * Constructor
    * @param base the base URL from which all CGI scripts will be relative
    * @param user user name to use for logging in
    * @param passwd password to use for logging in
    */
   public ItoolsRepublish(String base, String user, String passwd)
   {
       MyLog.setLevel(Level.DEBUG);
       MyLog.info("Constructor");
       if(MyLog.isDebugEnabled())
       {
           MyLog.debug("base:"+base);
           MyLog.debug("user:"+user);
           MyLog.debug("passwd:"+passwd);
       }
       //create a singular HttpClient object
       Client = new HttpClient();

       //establish a connection within 5 seconds
       Client.getHttpConnectionManager().
           getParams().setConnectionTimeout(TIMEOUT);
       Client.getHostConfiguration().setHost(base, 80, "http");
       Client.getParams().setCookiePolicy(CookiePolicy.RFC_2109);

       StringBuffer sb=new StringBuffer("http://";);
       sb.append(base);
       sb.append(ADMIN);

       UrlBase=sb.toString();
       User=user;
       Password=passwd;
   }

   /**
    * process the admin script to re-publish the web pages
    * @throws heavyweight.Exception for a variety of problems
    */
   public void process()
       throws heavyweight.Exception,
              java.io.IOException
   {
       String response;

       // Prepare login parameters
       NameValuePair userid   = new NameValuePair("id", User);
       NameValuePair password = new NameValuePair("pw", Password);

       //and login
       response=execute(UrlBase, new NameValuePair[] {userid, password});
       response=execute(UrlBase, new NameValuePair[] {
                           new NameValuePair("setup_options_edit","1")});

   }

   /**
    * execute a method
    * @param url the url to be executed
    * @param parms a name value pair array of parameters to pass to the
    *              script.
    * @return a string containing the HTML returned
    * @throws heavyweight.Exception for a variety of problems
    */
   private String execute(String url, NameValuePair[] parms)
       throws heavyweight.Exception
   {
       PostMethod method = new PostMethod(url);

       if(parms==null)
       {
           throw new IllegalArgumentException("Must pass paramters to
execute (url, parms). For no parms, use execute(String)\n");
       }
       method.setRequestBody(parms);

       //execute the method
       String responseBody = null;
       int tries=0;
       boolean successful=false;

       do
       {
           try
           {
               Client.executeMethod(method);
               responseBody = method.getResponseBodyAsString();
               successful=true;
           } catch (HttpException he)
           {
               StringBuffer sb=new StringBuffer("Http error connecting
to '");
               sb.append(url);
               sb.append("'\n");
               MyLog.error(sb.toString());
               MyLog.error(he.getMessage());

               if(++tries>RETRY_COUNT)
               {
                   throw new heavyweight.Exception(sb.toString(), he);
               }
           } catch (IOException ioe)
           {
               StringBuffer sb=new StringBuffer("Unable to connect to '");
               sb.append(url);
               sb.append("'\n");
               MyLog.error(sb.toString());
               MyLog.error(ioe.getMessage());

               if(++tries>RETRY_COUNT)
               {
                   throw new heavyweight.Exception(sb.toString(), ioe);
               }
           }
       } while(!successful);

       //write out the request headers
       System.out.println("*** Request ***");
       System.out.println("Request Path: " + method.getPath());
       System.out.println("Request Query: " + method.getQueryString());
       Header[] requestHeaders = method.getRequestHeaders();
       for (int i=0; i<requestHeaders.length; i++){
           System.out.print(requestHeaders[i]);
       }

       //write out the cookies
       if(MyLog.isDebugEnabled())
       {
           MyLog.debug("*** Cookies ***");
           for(Cookie ck:Client.getState().getCookies())
           {
               MyLog.debug(ck.toString());
           }
       }

       //write out the response headers
       System.out.println("*** Response ***");
       System.out.println("Status Line: " + method.getStatusLine());
       Header[] responseHeaders = method.getResponseHeaders();
       for (int i=0; i<responseHeaders.length; i++){
           System.out.print(responseHeaders[i]);
       }

       //write out the response body
       System.out.println("*** Response Body ***");
       System.out.println(responseBody);

       //clean up the connection resources
       method.releaseConnection();

       return responseBody;
   }

Now the problem appears to be that my cookie doesn't make it from the
first request for login into the second request to do something. I've
been researching this and have maybe figured something out.

As you can see in my source, I am using CookiePolicy.RFC_2109. I pulled
the spec for this from http://www.ietf.org/rfc/rfc2109.txt which says:

  Version=version
     Required.  The Version attribute, a decimal integer, identifies to
     which version of the state management specification the cookie
     conforms.  For this specification, Version=1 applies.






But in my request header, when it sends the cookies back, it says:
Cookie: $Version=0; id=bmedia
Cookie: $Version=0; pw=solutions
Cookie: $Version=0; listing_search=
Cookie: $Version=0; listing_keyword=
Cookie: $Version=0; listing_pagenum=1

According to RFC_2109, shouldn't this be $Version=1? Could this be
causing me to lose my login information on following attempts to access
the web page?

Please advise.

Thanks.



--
"In every revolution, there is one man with a vision."--Jerome Bixby

Thom Hehl
<A href="www.heavyweightsoftware.com"> www.heavyweightsoftware.com</A>


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



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




--
"In every revolution, there is one man with a vision."--Jerome Bixby

Thom Hehl
<A href="www.heavyweightsoftware.com"> www.heavyweightsoftware.com</A>


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

Reply via email to