olegk       2003/01/25 10:24:13

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java
  Log:
  Makes code in getResponseAsString() a bit more defensive
  
  Revision  Changes    Path
  1.98      +18 -13    
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.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- HttpMethodBase.java       25 Jan 2003 03:28:29 -0000      1.97
  +++ HttpMethodBase.java       25 Jan 2003 18:24:13 -0000      1.98
  @@ -155,13 +155,13 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>dIon Gillard</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jeff Dever</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
  - * @author Ortwin Glück
  + * @author Ortwin Gl�ck
    * @author Eric Johnson
    * @author Michael Becke
    * @author <a href="mailto:[EMAIL PROTECTED]";>Oleg Kalnichevski</a>
    */
   public abstract class HttpMethodBase implements HttpMethod {
  -    //~ Static variables/initializers ··········································
  +    //~ Static variables/initializers 
������������������������������������������
   
       /** Maximum number of redirects and authentications that will be followed */
       private static int maxForwards = 100;
  @@ -183,7 +183,7 @@
           USER_AGENT = new Header("User-Agent", agent);
       }
   
  -    //~ Instance variables ·····················································
  +    //~ Instance variables 
�����������������������������������������������������
   
       /** My request headers, if any. */
       private Map requestHeaders = new HashMap();
  @@ -252,7 +252,7 @@
   
       private boolean doneWithConnection = false;
   
  -    //~ Constructors ···························································
  +    //~ Constructors 
�����������������������������������������������������������
   
       // ----------------------------------------------------------- Constructors
   
  @@ -306,7 +306,7 @@
           }
       }
   
  -    //~ Methods ································································
  +    //~ Methods 
����������������������������������������������������������������
   
       // ------------------------------------------- Property Setters and Getters
   
  @@ -681,11 +681,16 @@
        */
       public String getResponseBodyAsString()
       {
  -        if (!responseAvailable()) 
  -        {
  -            return null;
  +             byte[] rawdata = null;
  +        if (responseAvailable()) {
  +            rawdata = getResponseBody();
           }
  -        return HttpConstants.getContentString(getResponseBody(), 
getResponseCharSet());
  +        if (rawdata != null) {
  +             return HttpConstants.getContentString(rawdata, getResponseCharSet());
  +        }
  +         else {
  +             return null;
  +         }
       }
   
   
  
  
  

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

Reply via email to