Folks
I would like to apply the following patch to get rid of superfluous info
message in the responseBodyConsumed. Nothing really drastic
If nobody complains loudly, I'll apply the patch in a couple of days
Oleg
-----Forwarded Message-----
> From: Michael Taft <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Problem Downloading Images
> Date: Sat, 06 Nov 2004 19:37:19 -0800
>
> Hello -
> I have a quick question. I am downloading images and writing them to
> disk using code that looks like this:
>
>
> -----------------------------------------------------------------------------------------------------
>
>
>
> String nextPic = "img01.jpg";
> for (int i=1; i<=24; i++)
> {
> String iString = Integer.toString(i);
> if(i<10)iString = "0"+iString;
> nextPic = "img" + iString + ".jpg";
> // System.out.println("saved " + nextPic);
> get.setURI(new URI("http://targetsite" + nextPic, false));
> client.executeMethod( get );
> InputStream is = get.getResponseBodyAsStream();
> BufferedInputStream bis = new BufferedInputStream( is );
> FileOutputStream fos = new FileOutputStream( nextPic );
> byte[] bytes = new byte[ 200000 ];//room for a 200K file
> int count = bis.read( bytes );
> while( count != -1 && count <= 200000 ) {
> System.out.print( "-" );
> fos.write( bytes, 0, count );
> count = bis.read( bytes );
> }
> System.out.println("saved " + nextPic);
> if( count != -1 ) {
> fos.write( bytes, 0, count );
> }
> fos.close();
> bis.close();
> }
> System.out.println("saved" + nextPic);
>
> -------------------------------------------------------------------------------------
>
>
>
>
> In this example, the assumption is that there are 24 images, named in
> numberical order. The code works fine, except that every once in a
> while, I'm getting a "responseBodyConsumed" message like this one:
>
> ---------------------
> Nov 6, 2004 7:10:53 PM org.apache.commons.httpclient.HttpMethodBase
> responseBodyConsumed
> INFO: Stream closed
> ---------------------
>
> I've been trying to figure out what causes this problem, and how to fix
> it. Any help?
>
> Thanks,
> M.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
Index: java/org/apache/commons/httpclient/HttpMethodBase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.219
diff -u -r1.219 HttpMethodBase.java
--- java/org/apache/commons/httpclient/HttpMethodBase.java 19 Oct 2004 18:09:45 -0000 1.219
+++ java/org/apache/commons/httpclient/HttpMethodBase.java 7 Nov 2004 22:17:38 -0000
@@ -1,5 +1,5 @@
/*
- * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v 1.219 2004/10/19 18:09:45 olegk Exp $
+ * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v 1.219 2004/10/19 18:09:45 olegk Exp $
* $Revision: 1.219 $
* $Date: 2004/10/19 18:09:45 $
*
@@ -2248,23 +2248,24 @@
// If there is data available, regard the connection as being
// unreliable and close it.
- try {
- if(responseConnection.isResponseAvailable()) {
- boolean logExtraInput =
- getParams().isParameterTrue(HttpMethodParams.WARN_EXTRA_INPUT);
-
- if(logExtraInput) {
- LOG.warn("Extra response data detected - closing connection");
- }
- setConnectionCloseForced(true);
- }
- }
- catch (IOException e) {
- LOG.info(e.getMessage());
- responseConnection.close();
- }
if (shouldCloseConnection(responseConnection)) {
responseConnection.close();
+ } else {
+ try {
+ if(responseConnection.isResponseAvailable()) {
+ boolean logExtraInput =
+ getParams().isParameterTrue(HttpMethodParams.WARN_EXTRA_INPUT);
+
+ if(logExtraInput) {
+ LOG.warn("Extra response data detected - closing connection");
+ }
+ responseConnection.close();
+ }
+ }
+ catch (IOException e) {
+ LOG.warn(e.getMessage());
+ responseConnection.close();
+ }
}
}
this.connectionCloseForced = false;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]