rwaldhoff    01/08/14 16:06:17

  Modified:    httpclient/src/java/org/apache/commons/httpclient Tag:
                        rlwrefactoring HttpMethodBase.java
               httpclient/src/java/org/apache/commons/httpclient/methods
                        Tag: rlwrefactoring PutMethod.java
  Log:
  Add rudimentary response body buffering to HttpMethodBase
  Add methods to PutMethod to return this data
  Also reset http11 to true when recycled
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.10.2.15 +17 -12    
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.10.2.14
  retrieving revision 1.10.2.15
  diff -u -r1.10.2.14 -r1.10.2.15
  --- HttpMethodBase.java       2001/08/14 22:39:21     1.10.2.14
  +++ HttpMethodBase.java       2001/08/14 23:06:17     1.10.2.15
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.10.2.14 2001/08/14 22:39:21 rwaldhoff Exp $
  - * $Revision: 1.10.2.14 $
  - * $Date: 2001/08/14 22:39:21 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.10.2.15 2001/08/14 23:06:17 rwaldhoff Exp $
  + * $Revision: 1.10.2.15 $
  + * $Date: 2001/08/14 23:06:17 $
    * ====================================================================
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -67,7 +67,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
    * @author Rodney Waldhoff
  - * @version $Id: HttpMethodBase.java,v 1.10.2.14 2001/08/14 22:39:21 rwaldhoff Exp $
  + * @version $Id: HttpMethodBase.java,v 1.10.2.15 2001/08/14 23:06:17 rwaldhoff Exp $
    */
   public abstract class HttpMethodBase implements HttpMethod {
   
  @@ -931,8 +931,8 @@
        */
       protected void readResponseBody(State state, HttpConnection conn) throws 
IOException, HttpException {
           log.debug("HttpMethodBase.readResponseBody(State,HttpConnection)");
  -
  -        //OutputStream out = new ByteArrayOutputStream();
  +        responseBody = null;
  +        ByteArrayOutputStream out = new ByteArrayOutputStream();
           int expectedLength = 0;
           int foundLength = 0;
           {
  @@ -955,14 +955,16 @@
           int nb = 0;
           while(expectedLength == -1 || foundLength < expectedLength) {
               nb = is.read(buffer);
  -            if (nb == -1)
  +            if(nb == -1) {
                   break;
  -            //if (out == null)
  -            //    throw new IOException("Unable to buffer data");
  +            }
  +            if(out == null) {
  +                throw new IOException("Unable to buffer data");
  +            }
               if(wireLog.isInfoEnabled()) {
                   wireLog.info("<< \"" + new String(buffer,0,nb) + "\"");
               }
  -            //out.write(buffer, 0, nb);
  +            out.write(buffer, 0, nb);
               foundLength += nb;
               if(expectedLength > -1) {
                   if(foundLength == expectedLength) {
  @@ -973,7 +975,8 @@
                   }
               }
           }
  -        //out.close();
  +        out.close();
  +        responseBody = out.toByteArray();
       }
   
       /**
  @@ -1008,8 +1011,9 @@
           statusCode = -1;
           statusText = "Not executed";
           used = false;
  -        http11 = false;
  +        http11 = true;
           bodySent = false;
  +        responseBody = null;
       }
   
       // ---------------------------------------------- Protected Utility Methods
  @@ -1121,6 +1125,7 @@
       protected boolean used = false;
       protected boolean http11 = true;
       protected boolean bodySent = false;
  +    protected byte[] responseBody = null;
   
   }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.6   +11 -3     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java
  
  Index: PutMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
  retrieving revision 1.3.2.5
  retrieving revision 1.3.2.6
  diff -u -r1.3.2.5 -r1.3.2.6
  --- PutMethod.java    2001/08/13 23:35:29     1.3.2.5
  +++ PutMethod.java    2001/08/14 23:06:17     1.3.2.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
 1.3.2.5 2001/08/13 23:35:29 rwaldhoff Exp $
  - * $Revision: 1.3.2.5 $
  - * $Date: 2001/08/13 23:35:29 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PutMethod.java,v
 1.3.2.6 2001/08/14 23:06:17 rwaldhoff Exp $
  + * $Revision: 1.3.2.6 $
  + * $Date: 2001/08/14 23:06:17 $
    *
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -256,6 +256,14 @@
           } else {
               return 0;
           }
  +    }
  +
  +    public byte[] getResponseBody() {
  +        return responseBody;
  +    }
  +
  +    public String getResponseBodyAsString() {
  +        return null == responseBody ? null : new String(responseBody);
       }
   
       public void recycle() {
  
  
  

Reply via email to