vmassol     01/08/28 03:39:24

  Modified:    cactus/src/framework/share/org/apache/commons/cactus
                        WebResponse.java
  Log:
  additional logs + protected parseSetCookieHeader() instead of private so that we can 
unit test the method
  
  Revision  Changes    Path
  1.5       +20 -4     
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/WebResponse.java
  
  Index: WebResponse.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/WebResponse.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebResponse.java  2001/08/24 16:23:17     1.4
  +++ WebResponse.java  2001/08/28 10:39:24     1.5
  @@ -59,6 +59,7 @@
   
   import org.apache.commons.cactus.*;
   import org.apache.commons.cactus.util.*;
  +import org.apache.commons.cactus.util.log.*;
   
   /**
    * Default web response implementation that provides a minimal
  @@ -68,11 +69,17 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: WebResponse.java,v 1.4 2001/08/24 16:23:17 vmassol Exp $
  + * @version $Id: WebResponse.java,v 1.5 2001/08/28 10:39:24 vmassol Exp $
    */
   public class WebResponse
   {
       /**
  +     * The logger
  +     */
  +    private static Log logger =
  +        LogService.getInstance().getLog(WebResponse.class.getName());
  +
  +    /**
        * The connection object that was used to call the URL
        */
       private HttpURLConnection connection;
  @@ -162,6 +169,8 @@
        */
       public Hashtable getCookies()
       {
  +        this.logger.entry("getCookies()");
  +
           // We conform to the RFC 2109 :
           //
           //   The syntax for the Set-Cookie response header is
  @@ -186,6 +195,9 @@
           String headerValue = this.connection.getHeaderField(0);
           for (int i = 1; (headerName != null) || (headerValue != null); i++) {
   
  +            this.logger.debug("Header name  = [" + headerName + "]");
  +            this.logger.debug("Header value = [" + headerValue + "]");
  +
               if ((headerName != null) && headerName.equals("Set-Cookie")) {
   
                   // Parse the cookie definition
  @@ -216,6 +228,7 @@
   
           }
   
  +        this.logger.exit("getCookies");
           return cookies;
       }
   
  @@ -225,8 +238,10 @@
        * @return a vector og <code>ClientCookie</code> objects containing the
        *         parsed values from the "Set-Cookie" header.
        */
  -    private Vector parseSetCookieHeader(String theHeaderValue)
  +    protected Vector parseSetCookieHeader(String theHeaderValue)
       {
  +        this.logger.entry("parseSetCookieHeader([" + theHeaderValue + "])");
  +
           String name;
           String value;
           String comment = null;
  @@ -255,7 +270,7 @@
   
               int pos = param.indexOf("=");
               if (pos < 0) {
  -                System.err.println("Bad 'Set-Cookie' syntax, missing '=' [" +
  +                this.logger.warn("Bad 'Set-Cookie' syntax, missing '=' [" +
                       param + "], ignoring it !");
                   continue;
               }
  @@ -294,7 +309,7 @@
                   } else if (left.equalsIgnoreCase("version")) {
                       version = Float.parseFloat(right);
                   } else {
  -                    System.err.println("Bad 'Set-Cookie' syntax, bad name [" +
  +                    this.logger.warn("Bad 'Set-Cookie' syntax, bad name [" +
                           param + "], ignoring it !");
                       continue;
                   }
  @@ -308,6 +323,7 @@
               cookies.add(cookie);
           }
   
  +        this.logger.exit("parseSetCookieHeader");
           return cookies;
       }
   
  
  
  

Reply via email to