remm 01/06/20 09:00:40 Modified: httpclient/src/java/org/apache/commons/httpclient HttpClient.java RequestOutputStream.java ResponseInputStream.java Log: - The input stream will not attempt to read any bytes on the stream if the method indicates that there's no response body. - Both the input and output streams will get the method as a parameter. Revision Changes Path 1.16 +7 -6 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.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- HttpClient.java 2001/06/09 00:13:49 1.15 +++ HttpClient.java 2001/06/20 16:00:31 1.16 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v 1.15 2001/06/09 00:13:49 remm Exp $ - * $Revision: 1.15 $ - * $Date: 2001/06/09 00:13:49 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v 1.16 2001/06/20 16:00:31 remm Exp $ + * $Revision: 1.16 $ + * $Date: 2001/06/20 16:00:31 $ * * ==================================================================== * @@ -547,7 +547,8 @@ // Consume bytes returned (if any) method.processResponseHeaders(responseHeaders); ResponseInputStream responseInputStream = - new ResponseInputStream(input, responseHeaders); + new ResponseInputStream(input, method, + responseHeaders); // FIXME : Really set the interceptors here ? // The content is meant to be discarded //responseInputStream.setInterceptor @@ -609,7 +610,7 @@ method.setUsed(); // Parse response ResponseInputStream responseInputStream = - new ResponseInputStream(input, responseHeaders); + new ResponseInputStream(input, method, responseHeaders); responseInputStream.setInterceptor(streamInterceptor); method.parseResponse(responseInputStream); @@ -925,7 +926,7 @@ // Writing request body RequestOutputStream requestOutputStream = - new RequestOutputStream(output); + new RequestOutputStream(output, method); requestOutputStream.setInterceptor(streamInterceptor); if (method.isStreamedQuery()) { 1.2 +11 -4 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java Index: RequestOutputStream.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RequestOutputStream.java 2001/04/25 18:42:52 1.1 +++ RequestOutputStream.java 2001/06/20 16:00:33 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v 1.1 2001/04/25 18:42:52 remm Exp $ - * $Revision: 1.1 $ - * $Date: 2001/04/25 18:42:52 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/RequestOutputStream.java,v 1.2 2001/06/20 16:00:33 remm Exp $ + * $Revision: 1.2 $ + * $Date: 2001/06/20 16:00:33 $ * * ==================================================================== * @@ -74,7 +74,7 @@ * Socket output stream wrapper. * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> - * @version $Revision: 1.1 $ $Date: 2001/04/25 18:42:52 $ + * @version $Revision: 1.2 $ $Date: 2001/06/20 16:00:33 $ */ public class RequestOutputStream @@ -89,11 +89,12 @@ * * @param stream Wrapped input stream */ - public RequestOutputStream(OutputStream stream) { + public RequestOutputStream(OutputStream stream, HttpMethod method) { super(); this.stream = stream; + this.method = method; } @@ -153,6 +154,12 @@ * 1. */ private byte one[] = "1".getBytes(); + + + /** + * The associated method. + */ + protected HttpMethod method = null; // ------------------------------------------------------------- Properties 1.5 +18 -12 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java Index: ResponseInputStream.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ResponseInputStream.java 2001/06/20 03:15:47 1.4 +++ ResponseInputStream.java 2001/06/20 16:00:34 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v 1.4 2001/06/20 03:15:47 remm Exp $ - * $Revision: 1.4 $ - * $Date: 2001/06/20 03:15:47 $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/ResponseInputStream.java,v 1.5 2001/06/20 16:00:34 remm Exp $ + * $Revision: 1.5 $ + * $Date: 2001/06/20 16:00:34 $ * * ==================================================================== * @@ -74,7 +74,7 @@ * Socket input stream wrapper. * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> - * @version $Revision: 1.4 $ $Date: 2001/06/20 03:15:47 $ + * @version $Revision: 1.5 $ $Date: 2001/06/20 16:00:34 $ */ public class ResponseInputStream @@ -89,7 +89,8 @@ * * @param request The associated request */ - public ResponseInputStream(InputStream stream, Hashtable responseHeaders) { + public ResponseInputStream(InputStream stream, HttpMethod method, + Hashtable responseHeaders) { super(); closed = false; @@ -114,6 +115,7 @@ } this.stream = stream; + this.method = method; } @@ -182,6 +184,12 @@ protected InputStream stream = null; + /** + * The associated method. + */ + protected HttpMethod method = null; + + // ------------------------------------------------------------- Properties @@ -210,13 +218,6 @@ throw new IOException("Stream is already closed"); */ - int available = stream.available(); - // Don't do anything if no bytes are available - if (available <= 0) { - closed = true; - return; - } - if (!closed) { if (chunk) { @@ -321,6 +322,11 @@ // Have we read the specified content length already? if ((contentLength >= 0) && (count >= contentLength)) return false; // End of file indicator + + // If method doesn't have a body + if (!method.hasResponseBody()) { + return false; + } pos = 0;