morgand     01/05/07 13:09:32

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpClient.java
  Log:
  deprecated a constructor and added startSession(URL, Credentials)
  and startSession(String, int, Credentials)
  
  Revision  Changes    Path
  1.8       +39 -8     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- HttpClient.java   2001/05/07 08:31:01     1.7
  +++ HttpClient.java   2001/05/07 20:09:28     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
 1.7 2001/05/07 08:31:01 jericho Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/05/07 08:31:01 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v
 1.8 2001/05/07 20:09:28 morgand Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/05/07 20:09:28 $
    *
    * ====================================================================
    *
  @@ -110,7 +110,7 @@
   
   
       /**
  -     * One of two preferred constructors for HttpClient.  Call 
  +     * Preferred constructor for HttpClient.  Call 
        * {@link #startSession(URL)} or 
        * {@link #startSession(String, int)} to begin a
        * session.
  @@ -124,16 +124,14 @@
       }
   
       /**
  -     * One of two preferred constructors for HttpClient.  Call 
  -     * {@link #startSession(URL)} or 
  -     * {@link #startSession(String, int)} to begin a
  -     * session.
        * 
        * <b>Note:</b> The HttpClient constructors used to 
        * implicitly start a session.  That behavior has been 
        * removed.
        * @param user
        * @param password
  +     * @deprecated Use a startSession method that takes credentials
  +     *             instead
        */
       public HttpClient(String user, String password) {
           setCredentials(new Credentials(user, password));
  @@ -163,6 +161,11 @@
        */
       public HttpClient(URL url, String user, String password) {
           this(url);
  +        /*
  +         * when this constructor is finally removed,
  +         * the endSession method should be altered
  +         * to null out the credentials
  +         */
           setCredentials(new Credentials(user, password));
       }
       
  @@ -618,6 +621,21 @@
       }
   
       /**
  +     * Start a session.
  +     */
  +    public void startSession(String host, int port, Credentials creds) {
  +
  +        if (debug > 0)
  +            System.out.println("Start session : Host:" + host
  +                               + " Port:" + port);
  +        setCredentials(creds);
  +        state = new State();
  +        this.sessionHost = host;
  +        this.sessionPort = port;
  +
  +    }
  +
  +    /**
        * Start a session.  When starting a session, only the
        * hostname and port are considered.  The path must still
        * be set when constructing an HttpMethod (GetMethod, 
  @@ -626,6 +644,19 @@
        * @param url    URL object containing the target hostname and port
        */
       public void startSession(URL url) {
  +      startSession(url.getHost(), url.getPort() == -1 ? 80 : url.getPort());
  +    }
  +
  +    /**
  +     * Start a session.  When starting a session, only the
  +     * hostname and port are considered.  The path must still
  +     * be set when constructing an HttpMethod (GetMethod, 
  +     * PutMethod, etc.)
  +     * 
  +     * @param url    URL object containing the target hostname and port
  +     */
  +    public void startSession(URL url, Credentials creds) {
  +      setCredentials(creds);
         startSession(url.getHost(), url.getPort() == -1 ? 80 : url.getPort());
       }
   
  
  
  

Reply via email to