bloritsch 01/03/12 09:53:12
Modified: src/org/apache/cocoon/reading Tag: xml-cocoon2
ResourceReader.java
Log:
Fixed problem with using buffered reader, and made optimizations for memmory
with large resources.
Revision Changes Path
No revision
No revision
1.1.2.23 +12 -8
xml-cocoon/src/org/apache/cocoon/reading/Attic/ResourceReader.java
Index: ResourceReader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/reading/Attic/ResourceReader.java,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -r1.1.2.22 -r1.1.2.23
--- ResourceReader.java 2001/03/12 05:55:23 1.1.2.22
+++ ResourceReader.java 2001/03/12 17:53:12 1.1.2.23
@@ -38,7 +38,7 @@
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.22 $ $Date: 2001/03/12 05:55:23 $
+ * @version CVS $Revision: 1.1.2.23 $ $Date: 2001/03/12 17:53:12 $
*
* The <code>ResourceReader</code> component is used to serve binary data
* in a sitemap pipeline. It makes use of HTTP Headers to determine if
@@ -129,16 +129,12 @@
}
try {
- byte[] buffer = new byte[(int)len];
- is.read(buffer);
- is.close();
-
String mimeType = this.getMimeType();
if (mimeType != null) {
res.setContentType(mimeType);
}
-
- res.setContentLength(buffer.length);
+
+ res.setContentLength((int) len);
long expires = parameters.getParameterAsInteger("expires", -1);
if (expires > 0) {
@@ -146,7 +142,15 @@
}
res.setHeader("Accept-Ranges", "bytes");
- out.write ( buffer );
+
+ byte[] buffer = new byte[8192];
+ int length = -1;
+
+ while ((length = is.read(buffer)) > -1) {
+ out.write(buffer, 0, length);
+ }
+ is.close();
+ out.flush();
} catch (IOException ioe) {
getLogger().debug("Received an IOException, assuming client
severed connection on purpose");
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]