You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2002/01/12 00:56:07 UTC
cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters IdentityOutputFilter.java
remm 02/01/11 15:56:07
Modified: http11/src/java/org/apache/coyote/http11/filters
IdentityOutputFilter.java
Log:
- Fix incorrect handling of the number of bytes remaining on output.
Revision Changes Path
1.4 +8 -11 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java
Index: IdentityOutputFilter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/IdentityOutputFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IdentityOutputFilter.java 4 Dec 2001 06:33:07 -0000 1.3
+++ IdentityOutputFilter.java 11 Jan 2002 23:56:07 -0000 1.4
@@ -102,7 +102,7 @@
/**
* Remaining bytes.
*/
- protected long remaining = -1;
+ protected long remaining = 0;
/**
@@ -141,25 +141,23 @@
public int doWrite(ByteChunk chunk)
throws IOException {
- int result = chunk.getLength();
-
- if (result <= 0) {
- return -1;
- }
+ int result = 0;
if (contentLength > 0) {
if (remaining > 0) {
- if (chunk.getLength() > remaining) {
+ result = chunk.getLength();
+ if (result > remaining) {
// The chunk is longer than the number of bytes remaining
// in the body; changing the chunk length to the number
// of bytes remaining
chunk.setBytes(chunk.getBytes(), chunk.getStart(),
(int) remaining);
result = (int) remaining;
- remaining = -1;
+ remaining = 0;
} else {
remaining = remaining - result;
}
+ buffer.doWrite(chunk);
} else {
// No more bytes left to be written : return -1 and clear the
// buffer
@@ -168,8 +166,6 @@
}
}
- buffer.doWrite(chunk);
-
return result;
}
@@ -185,6 +181,7 @@
*/
public void setResponse(Response response) {
contentLength = response.getContentLength();
+ remaining = contentLength;
}
@@ -215,7 +212,7 @@
*/
public void recycle() {
contentLength = -1;
- remaining = -1;
+ remaining = 0;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>