hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Terrell" <Steve.Terr...@guideworkstv.com>
Subject RE: found an Error in HttpMethodBase class
Date Fri, 17 Aug 2007 12:32:01 GMT
Why would the second 'if' be a problem? The first test is to see if
there is already a response stream. The second 'if' is only called when
there is no response stream. In that case, if there is a response body,
then create a stream from it.

My only change to this code would be to drop the local declaration of
byteResponseStream, and instead use the class instance variable
responseStream. This way, any subsequent calls to
getResponseBodyAsStream would not have to create a new input stream. Of
course, I don't know why you would call this method more than once...

--Steve

-----Original Message-----
From: Bala mani [mailto:balaiimani@mail2world.com] 
Sent: Friday, August 17, 2007 7:36 AM
To: httpclient-user@jakarta.apache.org
Subject: found an Error in HttpMethodBase class


   /**
     * Returns the response body of the HTTP method, if any, as an
{@link
InputStream}. 
     * If response body is not available, returns <tt>null</tt>
     * 
     * @return The response body or <code>null</code>.
     * 
     * @throws IOException If an I/O (transport) problem occurs while
obtaining the 
     * response body.
     */
    public InputStream getResponseBodyAsStream() throws IOException {
        if (responseStream != null) {
            return responseStream;
        }
        if (responseBody != null) {
            InputStream byteResponseStream = new
ByteArrayInputStream(responseBody);
            LOG.debug("re-creating response stream from byte array");
            return byteResponseStream;
        }
        return null;
    }

the above code segment is part of the HttpMethodBase class.
on observation we find that the second if is a dead code segment and 
what correction is required.

-- 
View this message in context:
http://www.nabble.com/found-an-Error-in-HttpMethodBase-class-tf4285189.h
tml#a12198079
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message