vgritsenko 2002/06/04 18:41:35
Modified: src/java/org/apache/cocoon/reading ResourceReader.java
Log:
Fix not yet found bug: One can not set headers when response is already written to
the out
Revision Changes Path
1.14 +11 -11
xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java
Index: ResourceReader.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/reading/ResourceReader.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ResourceReader.java 5 Jun 2002 01:14:46 -0000 1.13
+++ ResourceReader.java 5 Jun 2002 01:41:35 -0000 1.14
@@ -89,7 +89,7 @@
* </dl>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Id: ResourceReader.java,v 1.13 2002/06/05 01:14:46 vgritsenko Exp $
+ * @version CVS $Id: ResourceReader.java,v 1.14 2002/06/05 01:41:35 vgritsenko Exp $
*/
public class ResourceReader
extends AbstractReader
@@ -169,23 +169,23 @@
response.setDateHeader("Expires", System.currentTimeMillis() +
expires);
}
+ long contentLength = this.inputSource.getContentLength();
+ if (contentLength != -1) {
+ // FIXME (VG): Environment has setContentLength, and
+ // Response interface has not. Strange.
+ response.setHeader("Content-Length", Long.toString(contentLength));
+ }
+
+ // Bug #9539: This resource reader does not support ranges
+ response.setHeader("Accept-Ranges", "none");
+
byte[] buffer = new byte[8192];
int length = -1;
- long contentLength = 0;
InputStream inputStream = this.inputSource.getInputStream();
while ((length = inputStream.read(buffer)) > -1) {
out.write(buffer, 0, length);
- contentLength += length;
}
-
- // FIXME (VG): Environment has setContentLength, and
- // Response interface has not. Strange.
- response.setHeader("Content-Length", Long.toString(contentLength));
-
- // Bug #9539: This resource reader does not support ranges
- response.setHeader("Accept-Ranges", "none");
-
inputStream.close();
inputStream = null;
out.flush();
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]