From: markt Date: Tue, 25 Mar 2008 22:13:49 +0000 (+0000) Subject: Revert original proposal for BZ44494 since an alternative patch was committed to... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8299b43b3b19c17acc8aa715c50ee7a77b2cf8f1;p=tomcat7.0 Revert original proposal for BZ44494 since an alternative patch was committed to 6.0.x git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@641043 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/connector/InputBuffer.java b/java/org/apache/catalina/connector/InputBuffer.java index d6f19394e..f989ce61c 100644 --- a/java/org/apache/catalina/connector/InputBuffer.java +++ b/java/org/apache/catalina/connector/InputBuffer.java @@ -354,9 +354,9 @@ public class InputBuffer extends Reader cb.setEnd(0); } - conv.convert(bb, cb); - bb.setOffset(bb.getEnd()); state = CHAR_STATE; + conv.convert(bb, cb, len); + bb.setOffset(bb.getEnd()); return cb.getLength(); diff --git a/java/org/apache/tomcat/util/buf/B2CConverter.java b/java/org/apache/tomcat/util/buf/B2CConverter.java index 0b763918e..c743ce7a5 100644 --- a/java/org/apache/tomcat/util/buf/B2CConverter.java +++ b/java/org/apache/tomcat/util/buf/B2CConverter.java @@ -68,22 +68,31 @@ public class B2CConverter { char result[]=new char[BUFFER_SIZE]; /** Convert a buffer of bytes into a chars + * @deprecated */ public void convert( ByteChunk bb, CharChunk cb ) throws IOException { // Set the ByteChunk as input to the Intermediate reader - iis.setByteChunk( bb ); - convert(cb); + convert(bb, cb, cb.getBuffer().length - cb.getEnd()); } - private void convert(CharChunk cb) + public void convert( ByteChunk bb, CharChunk cb, int limit) + throws IOException + { + iis.setByteChunk( bb ); + convert(cb, limit); + } + + private void convert(CharChunk cb, int limit) throws IOException { try { // read from the reader - while( iis.available()>0 ) { // conv.ready() ) { - int cnt=conv.read( result, 0, BUFFER_SIZE ); + int count = 0; + while( limit > 0 ) { // conv.ready() ) { + int size = limit < BUFFER_SIZE ? limit : BUFFER_SIZE; + int cnt=conv.read( result, 0, size ); if( cnt <= 0 ) { // End of stream ! - we may be in a bad state if( debug>0) @@ -96,6 +105,7 @@ public class B2CConverter { // XXX go directly cb.append( result, 0, cnt ); + limit -= cnt; } } catch( IOException ex) { if( debug>0) @@ -211,10 +221,6 @@ final class ReadConvertor extends InputStreamReader { return super.read( cbuf, off, len ); } - public final int read() throws IOException { - return super.read(); - } - /** Reset the buffer */ public final void recycle() { @@ -229,10 +235,7 @@ final class ReadConvertor extends InputStreamReader { not be called if recycling the converter and if data was not flushed. */ final class IntermediateInputStream extends InputStream { - byte buf[]; - int pos; - int len; - int end; + ByteChunk bc = null; public IntermediateInputStream() { } @@ -243,64 +246,18 @@ final class IntermediateInputStream extends InputStream { } public final int read(byte cbuf[], int off, int len) throws IOException { - if( pos >= end ) return -1; - if (pos + len > end) { - len = end - pos; - } - if (len <= 0) { - return 0; - } - System.arraycopy(buf, pos, cbuf, off, len); - pos += len; - return len; + return bc.substract(cbuf, off, len); } public final int read() throws IOException { - return (pos < end ) ? (buf[pos++] & 0xff) : -1; + return bc.substract(); } - + // -------------------- Internal methods -------------------- - void setBuffer( byte b[], int p, int l ) { - buf=b; - pos=p; - len=l; - end=pos+len; - } void setByteChunk( ByteChunk mb ) { - buf=mb.getBytes(); - pos=mb.getStart(); - len=mb.getLength(); - end=pos+len; - } - - public int available() throws IOException { - return end-pos; - } - - public boolean markSupported() { - return false; - } - - public int read(byte[] b) throws IOException { - return read(b,0,b.length); - } - - /** - * Repositions this stream to the position at the time the mark method was last called on this input - * stream. - * - * @throws IOException if this stream has not been marked or if the mark has been invalidated. - * @todo Implement this java.io.InputStream method - */ - public synchronized void reset() throws IOException { - //not implemented - } - - public long skip(long n) throws IOException { - //not implemented - return 0L; + bc = mb; } }