nacho 01/06/02 14:53:46
Modified: src/share/org/apache/tomcat/util/buf ByteChunk.java
Log:
Latest encoding fixes left some problems in the way.
Fixing a hack is a hazardous task..
Revision Changes Path
1.5 +11 -10
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
Index: ByteChunk.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ByteChunk.java 2001/05/27 23:16:19 1.4
+++ ByteChunk.java 2001/06/02 21:53:46 1.5
@@ -208,12 +208,13 @@
public int getStart() {
return start;
}
-
+
public int getOffset() {
- return getStart();
+ return getEnd();
}
public void setOffset(int off) {
+ if (end < off ) end=off;
start=off;
}
@@ -263,7 +264,7 @@
{
append( (byte)c);
}
-
+
public void append( byte b )
throws IOException
{
@@ -275,13 +276,13 @@
}
buff[end++]=b;
}
-
+
public void append( ByteChunk src )
throws IOException
{
append( src.getBytes(), src.getOffset(), src.getLength());
}
-
+
/** Add data to the buffer
*/
public void append( byte src[], int off, int len )
@@ -297,7 +298,7 @@
end+=len;
return;
}
-
+
// if we have limit and we're below
if( len <= limit - end ) {
// makeSpace will grow the buffer to the limit,
@@ -311,7 +312,7 @@
// buffer
// the buffer is already at ( or bigger than ) limit
-
+
// Optimization:
// If len-avail < length ( i.e. after we fill the buffer with
// what we can, the remaining will fit in the buffer ) we'll just
@@ -327,12 +328,12 @@
int avail=limit-end;
System.arraycopy(src, off, buff, end, avail);
end += avail;
-
+
flushBuffer();
-
+
System.arraycopy(src, off+avail, buff, end, len - avail);
end+= len - avail;
-
+
} else { // len > buf.length + avail
// long write - flush the buffer and write the rest
// directly from source