vmassol 01/08/30 05:10:00 Modified: cactus/src/framework/share/org/apache/commons/cactus/client AutoReadHttpURLConnection.java Log: only read response data if there are data to read Revision Changes Path 1.5 +18 -5 jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/client/AutoReadHttpURLConnection.java Index: AutoReadHttpURLConnection.java =================================================================== RCS file: /home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/client/AutoReadHttpURLConnection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AutoReadHttpURLConnection.java 2001/08/24 16:23:17 1.4 +++ AutoReadHttpURLConnection.java 2001/08/30 12:10:00 1.5 @@ -74,7 +74,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Bob Davison</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a> * - * @version $Id: AutoReadHttpURLConnection.java,v 1.4 2001/08/24 16:23:17 vmassol Exp $ + * @version $Id: AutoReadHttpURLConnection.java,v 1.5 2001/08/30 12:10:00 vmassol Exp $ */ final class AutoReadHttpURLConnection extends HttpURLConnection { @@ -149,11 +149,24 @@ { this.logger.entry("copy(...)"); - byte[] buf = new byte[this.chunkSize]; - int count; + // Only copy if there are data to copy ... The problem is that not + // all servers return a content-length header. If there is no header + // getContentLength() returns -1. It seems to work and it seems + // that all servers that return no content-length header also do + // not block on read() operations ! + + this.logger.debug("Content-Length : [" + + this.delegate.getContentLength() + "]"); + + if (this.delegate.getContentLength() != 0) { + + byte[] buf = new byte[this.chunkSize]; + int count; + + while(-1 != (count = is.read(buf))) { + os.write(buf, 0, count); + } - while(-1 != (count = is.read(buf))) { - os.write(buf, 0, count); } this.logger.exit("copy");