tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1187812 [4/8] - in /tomcat/trunk/modules/tomcat-lite: ./ java/org/apache/coyote/lite/ java/org/apache/tomcat/lite/http/ java/org/apache/tomcat/lite/io/ java/org/apache/tomcat/lite/io/jsse/ java/org/apache/tomcat/lite/proxy/ java/org/apache...
Date Sat, 22 Oct 2011 21:31:02 GMT
Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/SpdyConnection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/SpdyConnection.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/SpdyConnection.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/SpdyConnection.java Sat Oct 22 21:30:59 2011
@@ -21,40 +21,40 @@ import org.apache.tomcat.lite.io.IOChann
 import org.apache.tomcat.lite.io.IOConnector;
 
 /*
- * TODO: expectations ? 
+ * TODO: expectations ?
  * Fix docs - order matters
  * Crashes in chrome
- * 
+ *
  * Test with unit tests or:
- *  google-chrome --use-flip=no-ssl 
- *    --user-data-dir=/home/$USER/.config/google-chrome/Test 
+ *  google-chrome --use-flip=no-ssl
+ *    --user-data-dir=/home/$USER/.config/google-chrome/Test
  *    http://localhost:8802/hello
  */
 
-public class SpdyConnection extends HttpConnector.HttpConnection 
+public class SpdyConnection extends HttpConnector.HttpConnection
         implements IOConnector.ConnectedCallback {
-    
-    
+
+
     /** Use compression for headers. Will magically turn to false
      * if the first request doesn't have x8xx ( i.e. compress header )
      */
     boolean headerCompression = true;
     boolean firstFrame = true;
-    
+
     public static long DICT_ID = 3751956914L;
-    private static String SPDY_DICT_S = 
+    private static String SPDY_DICT_S =
         "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" +
         "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" +
-        "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" + 
-        "-agent10010120020120220320420520630030130230330430530630740040140240340440" + 
-        "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" + 
-        "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" + 
-        "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" + 
-        "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" + 
-        "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" + 
-        "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" + 
-        "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" + 
-        "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" + 
+        "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" +
+        "-agent10010120020120220320420520630030130230330430530630740040140240340440" +
+        "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" +
+        "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" +
+        "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" +
+        "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" +
+        "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" +
+        "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" +
+        "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" +
+        "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" +
         ".1statusversionurl ";
     public static byte[] SPDY_DICT = SPDY_DICT_S.getBytes();
     // C code uses this - not in the spec
@@ -64,10 +64,10 @@ public class SpdyConnection extends Http
 
 
     protected static Logger log = Logger.getLogger("SpdyConnection");
-    
+
     /**
      * @param spdyConnector
-     * @param remoteServer 
+     * @param remoteServer
      */
     SpdyConnection(HttpConnector spdyConnector, RemoteServer remoteServer) {
         this.httpConnector = spdyConnector;
@@ -76,7 +76,7 @@ public class SpdyConnection extends Http
     }
 
     AtomicInteger streamErrors = new AtomicInteger();
-    
+
     AtomicInteger lastInStream = new AtomicInteger();
     AtomicInteger lastOutStream = new AtomicInteger();
 
@@ -91,13 +91,13 @@ public class SpdyConnection extends Http
     BBuffer inFrameBuffer = BBuffer.allocate();
 
     BBuffer headW = BBuffer.wrapper();
-    
+
     CompressFilter headCompressIn = new CompressFilter()
         .setDictionary(SPDY_DICT, DICT_ID);
-    
+
     CompressFilter headCompressOut = new CompressFilter()
         .setDictionary(SPDY_DICT, DICT_ID);
-    
+
     IOBuffer headerCompressBuffer = new IOBuffer();
     IOBuffer headerDeCompressBuffer = new IOBuffer();
 
@@ -109,8 +109,8 @@ public class SpdyConnection extends Http
     AtomicInteger outFrames = new AtomicInteger();
     AtomicInteger outDataFrames = new AtomicInteger();
     AtomicInteger outBytes = new AtomicInteger();
-    
-        
+
+
     volatile boolean connecting = false;
     volatile boolean connected = false;
 
@@ -120,7 +120,7 @@ public class SpdyConnection extends Http
     public void withExtraBuffer(BBuffer received) {
         inFrameBuffer = received;
     }
-    
+
     @Override
     public void dataReceived(IOBuffer iob) throws IOException {
         // Only one thread doing receive at a time.
@@ -157,7 +157,7 @@ public class SpdyConnection extends Http
 
     /**
      * Frame received. Must consume all data for the frame.
-     * 
+     *
      * @param iob
      * @throws IOException
      */
@@ -166,7 +166,7 @@ public class SpdyConnection extends Http
         lastFrame = currentInFrame;
         inFrames.incrementAndGet();
         inBytes.addAndGet(currentInFrame.length + 8);
-        
+
         if (currentInFrame.c) {
             if (currentInFrame.type == SpdyConnection.Frame.TYPE_HELO) {
                 // receivedHello = currentInFrame;
@@ -184,7 +184,7 @@ public class SpdyConnection extends Http
                 }
 
                 synchronized (channels) {
-                        channels.put(ch.channelId, ch);                    
+                        channels.put(ch.channelId, ch);
                 }
 
                 try {
@@ -218,9 +218,9 @@ public class SpdyConnection extends Http
                 }
                 try {
                     SpdyConnection.readShort(iob);
-        
+
                     HttpMessageBytes resBytes = ch.getResponse().getMsgBytes();
-                
+
                     BBuffer head = processHeaders(iob, ch, resBytes);
                 } catch (Throwable t) {
                     log.log(Level.SEVERE, "Error parsing head", t);
@@ -271,14 +271,14 @@ public class SpdyConnection extends Http
                 }
             }
             ch.sendHandleReceivedCallback();
-            
+
             if ((currentInFrame.flags & SpdyConnection.Frame.FLAG_HALF_CLOSE) != 0) {
                 ch.handleEndReceive();
             }
         }
         firstFrame = false;
     }
-    
+
     /**
      * On frame error.
      */
@@ -306,9 +306,9 @@ public class SpdyConnection extends Http
             // 0x800 headers seems a bit too much - assume compressed.
             // I wish this was a flag...
             headerDeCompressBuffer.recycle();
-            // stream id ( 4 ) + unused ( 2 ) 
+            // stream id ( 4 ) + unused ( 2 )
             // nvCount is compressed in impl - spec is different
-            headCompressIn.decompress(iob, headerDeCompressBuffer, 
+            headCompressIn.decompress(iob, headerDeCompressBuffer,
                     currentInFrame.length - 6);
             headerDeCompressBuffer.copyAll(headRecvBuf);
             headerDeCompressBuffer.recycle();
@@ -324,7 +324,7 @@ public class SpdyConnection extends Http
         }
         // Wrapper - so we don't change position in head
         headRecvBuf.wrapTo(headW);
-        
+
         BBuffer nameBuf = BBuffer.wrapper();
         BBuffer valBuf = BBuffer.wrapper();
 
@@ -378,15 +378,15 @@ public class SpdyConnection extends Http
         BBuffer headBuf = BBuffer.allocate();
         SpdyConnection.appendShort(headBuf, mimeHeaders.size() + 3);
         serializeMime(mimeHeaders, headBuf);
-        
+
         // TODO: url - with host prefix , method
         // optimize...
         SpdyConnection.appendAsciiHead(headBuf, "version");
         SpdyConnection.appendAsciiHead(headBuf, "HTTP/1.1");
-        
+
         SpdyConnection.appendAsciiHead(headBuf, "method");
         SpdyConnection.appendAsciiHead(headBuf, http.getRequest().getMethod());
-        
+
         SpdyConnection.appendAsciiHead(headBuf, "url");
         // TODO: url
         SpdyConnection.appendAsciiHead(headBuf, http.getRequest().requestURL());
@@ -400,44 +400,44 @@ public class SpdyConnection extends Http
 
         // Frame head - 8
         BBuffer out = BBuffer.allocate();
-        // Syn-reply 
-        out.putByte(0x80); 
-        out.putByte(0x01); 
-        out.putByte(0x00); 
+        // Syn-reply
+        out.putByte(0x80);
         out.putByte(0x01);
-        
+        out.putByte(0x00);
+        out.putByte(0x01);
+
         CBuffer method = http.getRequest().method();
         if (method.equals("GET") || method.equals("HEAD")) {
             http.getOut().close();
         }
-        
+
         if (http.getOut().isAppendClosed()) {
             out.putByte(0x01); // closed
         } else {
-            out.putByte(0x00); 
+            out.putByte(0x00);
         }
-        
-        // Length, channel id (4) + unused (2) - headBuf has header count 
+
+        // Length, channel id (4) + unused (2) - headBuf has header count
         // and headers
         SpdyConnection.append24(out, headBuf.remaining() + 6);
-        
+
         if (serverMode) {
             http.channelId = 2 * lastOutStream.incrementAndGet();
         } else {
-            http.channelId = 2 * lastOutStream.incrementAndGet() + 1;            
+            http.channelId = 2 * lastOutStream.incrementAndGet() + 1;
         }
         SpdyConnection.appendInt(out, http.channelId);
-        
+
         http.setConnection(this);
 
         synchronized (channels) {
-            channels.put(http.channelId, http);            
+            channels.put(http.channelId, http);
         }
-        
-        out.putByte(0x00); // no priority 
-        out.putByte(0x00); 
-        
-        sendFrame(out, headBuf); 
+
+        out.putByte(0x00); // no priority
+        out.putByte(0x00);
+
+        sendFrame(out, headBuf);
 
         if (http.outMessage.state == HttpMessage.State.HEAD) {
             http.outMessage.state = HttpMessage.State.BODY_DATA;
@@ -450,13 +450,13 @@ public class SpdyConnection extends Http
         //sendData(http);
     }
 
-    
+
     public synchronized Collection<HttpChannel> getActives() {
         synchronized(channels) {
             return channels.values();
         }
     }
-    
+
     @Override
     protected synchronized void sendResponseHeaders(HttpChannel http) throws IOException {
         if (!serverMode) {
@@ -464,7 +464,7 @@ public class SpdyConnection extends Http
         }
 
         if (http.getResponse().isCommitted()) {
-            return; 
+            return;
         }
         http.getResponse().setCommitted(true);
 
@@ -482,14 +482,14 @@ public class SpdyConnection extends Http
         //SpdyConnection.appendInt(headers, http.channelId);
         //headers.putByte(0);
         //headers.putByte(0);
-        SpdyConnection.appendShort(headers, mimeHeaders.size() + 2);        
-        
+        SpdyConnection.appendShort(headers, mimeHeaders.size() + 2);
+
         // chrome will crash if we don't send the header
         serializeMime(mimeHeaders, headers);
 
         // Must be at the end
         SpdyConnection.appendAsciiHead(headers, "status");
-        SpdyConnection.appendAsciiHead(headers, 
+        SpdyConnection.appendAsciiHead(headers,
                 Integer.toString(http.getResponse().getStatus()));
 
         SpdyConnection.appendAsciiHead(headers, "version");
@@ -501,16 +501,16 @@ public class SpdyConnection extends Http
             headerCompressBuffer.copyAll(headBuf);
             headerCompressBuffer.recycle();
         }
-        
+
         BBuffer frameHead = BBuffer.allocate();
-        // Syn-reply 
+        // Syn-reply
         frameHead.putByte(0x80); // Control
         frameHead.putByte(0x01); // version
         frameHead.putByte(0x00); // 00 02 - SYN_REPLY
         frameHead.putByte(0x02);
-        
+
         // It seems piggibacking data is not allowed
-        frameHead.putByte(0x00); 
+        frameHead.putByte(0x00);
 
         int len = headBuf.remaining() + 6;
         SpdyConnection.append24(frameHead, len);
@@ -522,17 +522,17 @@ public class SpdyConnection extends Http
 
         sendFrame(frameHead, headBuf);
     }
-    
-    
+
+
     public void startSending(HttpChannel http) throws IOException {
         http.send(); // if needed
-        
+
         if (net != null) {
             sendData(http);
             net.startSending();
         }
     }
-    
+
     private void sendData(HttpChannel http) throws IOException {
         int avail = http.getOut().available();
         boolean closed = http.getOut().isAppendClosed();
@@ -548,7 +548,7 @@ public class SpdyConnection extends Http
         }
     }
 
-    private BBuffer serializeMime(MultiMap mimeHeaders, BBuffer headBuf) 
+    private BBuffer serializeMime(MultiMap mimeHeaders, BBuffer headBuf)
             throws IOException {
 
         // TODO: duplicated headers not allowed
@@ -605,7 +605,7 @@ public class SpdyConnection extends Http
             net.getOut().append(out2, avail);
         }
         net.startSending();
-        outDataFrames.incrementAndGet();        
+        outDataFrames.incrementAndGet();
     }
 
     static void appendInt(BBuffer headBuf, int length) throws IOException {
@@ -664,30 +664,30 @@ public class SpdyConnection extends Http
 
     public static class Frame {
         int flags;
-    
+
         int length;
-    
+
         boolean c; // for control
-    
+
         int version;
-    
+
         int type;
-    
+
         int streamId; // for data
-    
+
         static int TYPE_HELO = 4;
-    
+
         static int TYPE_SYN_STREAM = 1;
 
         static int TYPE_SYN_REPLY = 2;
-    
+
         static int FLAG_HALF_CLOSE = 1;
-    
+
         public void parse(SpdyConnection spdyConnection,
                 BBuffer iob) throws IOException {
             int b0 = iob.read();
             if (b0 < 128) {
-                // data frame 
+                // data frame
                 c = false;
                 streamId = b0;
                 for (int i = 0; i < 3; i++) {
@@ -705,18 +705,18 @@ public class SpdyConnection extends Http
                 b0 = iob.read();
                 type = ((b0 << 8) | iob.read());
             }
-    
+
             flags = iob.read();
             for (int i = 0; i < 3; i++) {
                 b0 = iob.read();
                 length = length << 8 | b0;
             }
-            
+
             iob.recycle();
         }
-    
+
     }
-    
+
     @Override
     protected void endSendReceive(HttpChannel http) throws IOException {
         synchronized (channels) {
@@ -727,31 +727,31 @@ public class SpdyConnection extends Http
         }
         httpConnector.cpool.afterRequest(http, this, true);
     }
-    
-    /** 
+
+    /**
      * Framing error, client interrupt, etc.
      */
     public void abort(HttpChannel http, String t) throws IOException {
         // TODO: send interrupt signal
-        
+
     }
-    
-    
+
+
     private boolean checkConnection(HttpChannel http) throws IOException {
         synchronized(this) {
             if (net == null || !isOpen()) {
                 connected = false;
             }
-        
+
             if (!connected) {
                 if (!connecting) {
-                    // TODO: secure set at start ? 
+                    // TODO: secure set at start ?
                     connecting = true;
-                    httpConnector.cpool.httpConnect(http, 
-                            target.toString(), 
+                    httpConnector.cpool.httpConnect(http,
+                            target.toString(),
                             http.getRequest().isSecure(), this);
                 }
-                
+
                 synchronized (remoteHost) {
                     remoteHost.pending.add(http);
                     httpConnector.cpool.queued.incrementAndGet();
@@ -775,7 +775,7 @@ public class SpdyConnection extends Http
                     httpCh = remoteHost.pending.remove();
                 }
                 httpCh.abort("Can't connect");
-            }            
+            }
         }
 
         synchronized (remoteHost) {
@@ -789,23 +789,23 @@ public class SpdyConnection extends Http
                 }
                 String[] hostPort = httpCh.getTarget().split(":");
 
-                IOChannel ch1 = httpConnector.sslProvider.channel(net, 
+                IOChannel ch1 = httpConnector.sslProvider.channel(net,
                         hostPort[0], Integer.parseInt(hostPort[1]));
                 //net.setHead(ch1);
                 net = ch1;
             }
-        }        
+        }
         if (httpConnector.debugHttp) {
             net = DumpChannel.wrap("SPDY", net);
         }
-        
+
         setSink(net);
-        
+
         synchronized(this) {
             connecting = false;
             connected = true;
         }
- 
+
         while (true) {
             synchronized (remoteHost) {
                 if (remoteHost.pending.size() == 0) {

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBucket.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBucket.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBucket.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBucket.java Sat Oct 22 21:30:59 2011
@@ -6,33 +6,33 @@ import java.nio.ByteBuffer;
 
 
 
-/** 
+/**
  * Holds raw data. Similar interface with a ByteBuffer in 'channel write'
- * or 'read mode'. Data is between position and limit - there is no 
+ * or 'read mode'. Data is between position and limit - there is no
  * switching.
- * 
+ *
  * TODO: FileBucket, DirectBufferBucket, CharBucket, ...
- * 
+ *
  * @author Costin Manolache
  */
 public interface BBucket {
-    
+
     public void release();
 
     public byte[] array();
     public int position();
     public int remaining();
     public int limit();
-    
+
     public boolean hasRemaining();
-    
+
     public void position(int newStart);
 
-    /** 
-     * Return a byte buffer, with data between position and limit. 
-     * Changes in the ByteBuffer position will not be reflected 
+    /**
+     * Return a byte buffer, with data between position and limit.
+     * Changes in the ByteBuffer position will not be reflected
      * in the IOBucket.
-     * 
+     *
      * @return
      */
     public ByteBuffer getByteBuffer();

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBuffer.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBuffer.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BBuffer.java Sat Oct 22 21:30:59 2011
@@ -42,36 +42,36 @@ import java.nio.charset.Charset;
 /**
  * This class is used to represent a chunk of bytes, and utilities to manipulate
  * byte[].
- * 
+ *
  * The buffer can be modified and used for both input and output.
- * 
+ *
  * There are 2 modes: The chunk can be associated with a sink - ByteInputChannel
  * or ByteOutputChannel, which will be used when the buffer is empty ( on input
  * ) or filled ( on output ). For output, it can also grow. This operating mode
  * is selected by calling setLimit() or allocate(initial, limit) with limit !=
  * -1.
- * 
+ *
  * Various search and append method are defined - similar with String and
  * StringBuffer, but operating on bytes.
- * 
+ *
  * This is important because it allows processing the http headers directly on
  * the received bytes, without converting to chars and Strings until the strings
  * are needed. In addition, the charset is determined later, from headers or
  * user code.
- * 
- * 
+ *
+ *
  * @author dac@sun.com
  * @author James Todd [gonzo@sun.com]
  * @author Costin Manolache
  * @author Remy Maucherat
  */
-public class BBuffer implements Cloneable, Serializable, 
+public class BBuffer implements Cloneable, Serializable,
     BBucket {
-    
+
     /**
      * Default encoding used to convert to strings. It should be UTF8, but:
      * - the servlet API requires 8859_1 as default
-     * -  
+     * -
      */
     public static final String DEFAULT_CHARACTER_ENCODING = "ISO-8859-1";
 
@@ -108,10 +108,10 @@ public class BBuffer implements Cloneabl
      * CR.
      */
     public static final byte CR = (byte) '\r';
-    
+
     //private int useCount;
-    
-    
+
+
     private static final boolean[] isDigit = new boolean[256];
 
     static Charset UTF8;
@@ -141,7 +141,7 @@ public class BBuffer implements Cloneabl
     static {
         for (int d = '0'; d <= '9'; d++) {
             isDigit[d] = true;
-        }        
+        }
         UTF8 = Charset.forName("UTF-8");
     }
 
@@ -153,7 +153,7 @@ public class BBuffer implements Cloneabl
         return new BBuffer().makeSpace(initial);
     }
 
-    
+
     public static BBuffer allocate(String msg) {
         BBuffer bc = allocate();
         byte[] data = msg.getBytes();
@@ -183,7 +183,7 @@ public class BBuffer implements Cloneabl
         res.setBytes(b, off, len);
         return res;
     }
-    
+
     public static BBuffer wrapper(BBucket bb, int start, int len) {
         BBuffer res = new IOBucketWrap();
         res.setBytes(bb.array(), bb.position() + start, len);
@@ -216,7 +216,7 @@ public class BBuffer implements Cloneabl
     // -------------------- Adding data to the buffer --------------------
     /**
      * Append a char, by casting it to byte. This IS NOT intended for unicode.
-     * 
+     *
      * @param c
      */
     public void append(char c) {
@@ -232,7 +232,7 @@ public class BBuffer implements Cloneabl
     public byte[] array() {
         return buff;
     }
-    
+
     public int capacity() {
         return buff.length;
     }
@@ -285,7 +285,7 @@ public class BBuffer implements Cloneabl
 
     /**
      * Compares the message bytes to the specified String object.
-     * 
+     *
      * @param s
      *            the String to compare
      * @return true if the comparison succeeded, false otherwise
@@ -307,10 +307,10 @@ public class BBuffer implements Cloneabl
         }
         return true;
     }
-    
+
     /**
      * Compares the message bytes to the specified String object.
-     * 
+     *
      * @param s
      *            the String to compare
      * @return true if the comparison succeeded, false otherwise
@@ -337,7 +337,7 @@ public class BBuffer implements Cloneabl
         return buff[start + off] & 0xFF;
     }
 
-    /** 
+    /**
      * Return a byte buffer. Changes in the ByteBuffer position will
      * not be reflected in the IOBucket
      * @return
@@ -360,7 +360,7 @@ public class BBuffer implements Cloneabl
             return null;
         }
     }
-    
+
     public int getEnd() {
         return end;
     }
@@ -374,7 +374,7 @@ public class BBuffer implements Cloneabl
     public int getLength() {
         return end - start;
     }
-    
+
     public long getLong() {
         return parseLong(buff, start, end - start);
     }
@@ -422,7 +422,7 @@ public class BBuffer implements Cloneabl
 
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param s
      *            the string
      */
@@ -462,7 +462,7 @@ public class BBuffer implements Cloneabl
 
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param c
      *            the character
      * @param starting
@@ -475,7 +475,7 @@ public class BBuffer implements Cloneabl
 
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param s
      *            the string
      * @param pos
@@ -498,7 +498,7 @@ public class BBuffer implements Cloneabl
     public int indexOf(String src) {
         return indexOf(src, 0, src.length(), 0);
     }
-    
+
     public int indexOf(String src, int srcOff, int srcLen, int myOff) {
         if ("".equals(src)) {
             return myOff;
@@ -552,7 +552,7 @@ public class BBuffer implements Cloneabl
     }
 
     /**
-     * Make space for len chars. 
+     * Make space for len chars.
      * If len is small, allocate a reserve space too.
      */
     public BBuffer makeSpace(int count) {
@@ -594,7 +594,7 @@ public class BBuffer implements Cloneabl
 
 //    /**
 //     * Find a character, no side effects.
-//     * 
+//     *
 //     * @return index of char if found, -1 if not
 //     */
 //    public static int findChars(byte buf[], int start, int end, byte c[]) {
@@ -612,7 +612,7 @@ public class BBuffer implements Cloneabl
 
 //    /**
 //     * Find the first character != c
-//     * 
+//     *
 //     * @return index of char if found, -1 if not
 //     */
 //    public static int findNotChars(byte buf[], int start, int end, byte c[]) {
@@ -666,10 +666,10 @@ public class BBuffer implements Cloneabl
         return res.remaining();
     }
 
-    /** 
+    /**
      * Read a chunk from is.
-     * 
-     * You don't need to use buffered input stream, we do the 
+     *
+     * You don't need to use buffered input stream, we do the
      * buffering.
      */
     public int read(InputStream is) throws IOException {
@@ -701,11 +701,11 @@ public class BBuffer implements Cloneabl
 
 
     /**
-     *  Read a line - excluding the line terminator, which is consummed as 
+     *  Read a line - excluding the line terminator, which is consummed as
      *  well but not included in the response.
-     *  
+     *
      *  Line can end with CR, LF or CR/LF
-     * 
+     *
      * @param res
      * @return number of bytes read, or -1 if line ending not found in buffer.
      */
@@ -729,11 +729,11 @@ public class BBuffer implements Cloneabl
         start = cstart;
         return -1;
     }
-    /** 
+    /**
      * Consume up to but not including delim.
-     * 
+     *
      */
-    public final int readToDelimOrSpace(byte delim, 
+    public final int readToDelimOrSpace(byte delim,
             BBuffer res) {
         int resStart = start;
         while (true) {
@@ -751,10 +751,10 @@ public class BBuffer implements Cloneabl
     }
 
 
-    /** 
+    /**
      * Consume all up to the first space or \t, which will be the
      * first character in the buffer.
-     * 
+     *
      * Consumed data is wrapped in res.
      */
     public int readToSpace(BBuffer res) {
@@ -763,7 +763,7 @@ public class BBuffer implements Cloneabl
           if (start >= end) {
               break;
           }
-          if (buff[start] == SP 
+          if (buff[start] == SP
                   || buff[start] == HT) {
               break;
           }
@@ -780,7 +780,7 @@ public class BBuffer implements Cloneabl
         end = 0;
     }
     @Override
-    public void release() { 
+    public void release() {
 //        synchronized (this) {
 //            useCount--;
 //            if (useCount == -1) {
@@ -796,11 +796,11 @@ public class BBuffer implements Cloneabl
     public void reset() {
         buff = null;
     }
-    
+
     // -------------------- Setup --------------------
     /**
      * Sets the message bytes to the specified subarray of bytes.
-     * 
+     *
      * @param b
      *            the ascii bytes
      * @param off
@@ -811,7 +811,7 @@ public class BBuffer implements Cloneabl
     public void setBytes(byte[] b, int off, int len) {
         throw new RuntimeException("Can't setBytes on allocated buffer");
     }
-    
+
     public void wrap(BBucket b) {
         setBytes(b.array(), b.position(), b.remaining());
     }
@@ -819,13 +819,13 @@ public class BBuffer implements Cloneabl
     public void wrap(ByteBuffer b) {
         setBytes(b.array(), b.position(), b.remaining());
     }
-    
+
     protected void setBytesInternal(byte[] b, int off, int len) {
         buff = b;
         start = off;
         end = start + len;
     }
-    
+
 //    public final void lowerCase() {
 //        while (start < end) {
 //            byte chr = buff[start];
@@ -839,7 +839,7 @@ public class BBuffer implements Cloneabl
     public void setEnd(int i) {
         end = i;
     }
-    
+
     /**
      * The old code from MessageBytes, used for setContentLength
      * and setStatus.
@@ -879,14 +879,14 @@ public class BBuffer implements Cloneabl
             end--;
         }
     }
-    
+
     public void setOffset(int off) {
         if (end < off)
             end = off;
         start = off;
     }
-    
-    
+
+
     public int skipEmptyLines() {
         int resStart = start;
         while (buff[start] == CR || buff[start] == LF) {
@@ -897,7 +897,7 @@ public class BBuffer implements Cloneabl
         }
         return start - resStart;
     }
-    
+
     public int skipSpace() {
         int cstart = start;
         while (true) {
@@ -932,7 +932,7 @@ public class BBuffer implements Cloneabl
         return len;
 
     }
-    
+
     public int substract(byte src[], int off, int len)  {
 
         if ((end - start) == 0) {
@@ -948,7 +948,7 @@ public class BBuffer implements Cloneabl
         return n;
 
     }
-    
+
     public String toString() {
         return toString(DEFAULT_CHARACTER_ENCODING);
     }
@@ -959,23 +959,23 @@ public class BBuffer implements Cloneabl
         } else if (end == start) {
             return "";
         }
-        
+
         String strValue = null;
         try {
             if (enc == null) {
                 enc = DEFAULT_CHARACTER_ENCODING;
             }
-            
+
             strValue = new String(buff, start, end - start, enc);
             /*
              * Does not improve the speed too much on most systems, it's safer
              * to use the "clasical" new String().
-             * 
+             *
              * Most overhead is in creating char[] and copying, the internal
              * implementation of new String() is very close to what we do. The
              * decoder is nice for large buffers and if we don't go to String (
              * so we can take advantage of reduced GC)
-             * 
+             *
              * // Method is commented out, in: return B2CConverter.decodeString(
              * enc );
              */
@@ -994,7 +994,7 @@ public class BBuffer implements Cloneabl
     /**
      * Convert specified String to a byte array. This ONLY WORKS for ascii, UTF
      * chars will be truncated.
-     * 
+     *
      * @param value
      *            to convert to byte array
      * @return the byte array value
@@ -1006,10 +1006,10 @@ public class BBuffer implements Cloneabl
         }
         return result;
     }
-    
+
     /**
      * Find a character, no side effects.
-     * 
+     *
      * @return index of char if found, -1 if not
      */
     public static int findChar(byte buf[], int start, int end, char c) {
@@ -1038,7 +1038,7 @@ public class BBuffer implements Cloneabl
         int pos = bucket.position();
         int lastValid = bucket.limit();
         byte[] buf = bucket.array();
-        
+
         for (int i = pos; i < lastValid; i++) {
             byte chr = buf[i];
             if (chr == LF) {
@@ -1062,7 +1062,7 @@ public class BBuffer implements Cloneabl
                         return true;
                     }
                 }
-                
+
             }
         }
         return false;
@@ -1133,7 +1133,7 @@ public class BBuffer implements Cloneabl
 
         long n = c - '0';
         long m;
-        
+
         while (--len > 0) {
             if (!isDigit(c = b[off++])) {
                 throw new NumberFormatException();
@@ -1171,25 +1171,25 @@ public class BBuffer implements Cloneabl
 
     /**
      * A slice of a bucket, holding reference to a parent bucket.
-     * 
+     *
      * This is used when a filter splits a bucket - the original
      * will be replaced with 1 or more slices. When all slices are
      * released, the parent will also be released.
-     * 
+     *
      * It is not possible to add data.
-     * 
+     *
      * @author Costin Manolache
      */
     static class IOBucketWrap extends BBuffer {
         //IOBucket parent;
-        
-        
+
+
         public BBuffer makeSpace(int count) {
             throw new RuntimeException("Attempting to change buffer " +
             		"on a wrapped BBuffer");
         }
 
-        public void release() { 
+        public void release() {
 //            if (parent != null) {
 //                parent.release();
 //            }
@@ -1200,5 +1200,5 @@ public class BBuffer implements Cloneabl
         }
     }
 
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BufferedIOReader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BufferedIOReader.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BufferedIOReader.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/BufferedIOReader.java Sat Oct 22 21:30:59 2011
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import java.nio.CharBuffer;
 /**
  * Cut&pasted from Harmony buffered reader ( apache license ).
  * Changes:
- * - additional method to recycle to avoid re-allocating on 
+ * - additional method to recycle to avoid re-allocating on
  * each request.
  */
 public class BufferedIOReader extends BufferedReader {
@@ -45,9 +45,9 @@ public class BufferedIOReader extends Bu
     private int pos;
 
     public BufferedIOReader(IOReader realReader) {
-        // we're not using super - we override all methods, but need the 
-        // signature 
-        super(DUMMY_READER, 1); 
+        // we're not using super - we override all methods, but need the
+        // signature
+        super(DUMMY_READER, 1);
         this.in = realReader;
         buf = new char[8192];
     }
@@ -55,7 +55,7 @@ public class BufferedIOReader extends Bu
     public void recycle() {
         enc = null;
         closed = false;
-        
+
         if (in != null) {
             in.recycle();
         }
@@ -68,7 +68,7 @@ public class BufferedIOReader extends Bu
     private void checkClosed() throws IOException {
         if (closed) throw new IOException("closed");
     }
-    
+
     public int read(CharBuffer target) throws IOException {
         checkClosed();
         int len = target.remaining();
@@ -88,7 +88,7 @@ public class BufferedIOReader extends Bu
      * Closes this reader. This implementation closes the buffered source reader
      * and releases the buffer. Nothing is done if this reader has already been
      * closed.
-     * 
+     *
      * @throws IOException
      *             if an error occurs while closing this reader.
      */
@@ -230,7 +230,7 @@ public class BufferedIOReader extends Bu
      * represented by zero or more characters followed by {@code '\n'},
      * {@code '\r'}, {@code "\r\n"} or the end of the reader. The string does
      * not include the newline sequence.
-     * 
+     *
      * @return the contents of the line or {@code null} if no characters were
      *         read before the end of the reader has been reached.
      * @throws IOException
@@ -312,7 +312,7 @@ public class BufferedIOReader extends Bu
 
     }
 
-    
+
     @Override
     public boolean ready() throws IOException {
         synchronized (lock) {
@@ -364,7 +364,7 @@ public class BufferedIOReader extends Bu
             return amount;
         }
     }
-    
+
     private static Reader DUMMY_READER = new Reader() {
         @Override
         public void close() throws IOException {

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBucket.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBucket.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBucket.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBucket.java Sat Oct 22 21:30:59 2011
@@ -6,12 +6,12 @@ import java.io.Serializable;
 import java.nio.CharBuffer;
 
 /**
- * Wraps a char[]. 
- * 
+ * Wraps a char[].
+ *
  * Doesn't provide any mutation methods. Classes in this package
- * have access to the buffer, for conversions. 
- * 
- * 
+ * have access to the buffer, for conversions.
+ *
+ *
  * @author Costin Manolache
  */
 public class CBucket implements CharSequence, Comparable, Serializable {
@@ -23,7 +23,7 @@ public class CBucket implements CharSequ
 
     // Reused.
     protected CharBuffer cb;
-    
+
     // cache
     protected String strValue;
     protected int hash;
@@ -31,7 +31,7 @@ public class CBucket implements CharSequ
     public CBucket() {
     }
 
-    /** 
+    /**
      * Used by IOWriter for conversion. Will not modify the content.
      */
     CharBuffer getNioBuffer() {
@@ -43,7 +43,7 @@ public class CBucket implements CharSequ
         }
         return cb;
     }
-    
+
     public void recycle() {
         start = 0;
         end = 0;
@@ -51,7 +51,7 @@ public class CBucket implements CharSequ
         strValue = null;
         hash = 0;
     }
-    
+
     public String toString() {
         if (null == value) {
             return null;
@@ -65,7 +65,7 @@ public class CBucket implements CharSequ
     }
 
     /**
-     * Same as String 
+     * Same as String
      */
     public int hashCode() {
         int h = hash;
@@ -80,7 +80,7 @@ public class CBucket implements CharSequ
         }
         return h;
     }
-    
+
     public long getLong() {
         return parseLong(value, start, end - start);
     }
@@ -143,7 +143,7 @@ public class CBucket implements CharSequ
 
     /**
      * Compares the message bytes to the specified String object.
-     * 
+     *
      * @param s
      *            the String to compare
      * @return true if the comparison succeeded, false otherwise
@@ -165,7 +165,7 @@ public class CBucket implements CharSequ
 
     /**
      * Compares the message bytes to the specified String object.
-     * 
+     *
      * @param s
      *            the String to compare
      * @return true if the comparison succeeded, false otherwise
@@ -232,10 +232,10 @@ public class CBucket implements CharSequ
         return true;
     }
 
-    
+
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param s
      *            the string
      */
@@ -256,7 +256,7 @@ public class CBucket implements CharSequ
 
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param s
      *            the string
      */
@@ -278,12 +278,12 @@ public class CBucket implements CharSequ
     public int indexOf(char c) {
         return indexOf(c, start);
     }
-    
+
     public int lastIndexOf(char c) {
         return lastIndexOf(c, 0, end - start);
     }
 
-    /** 
+    /**
      */
     public int lastIndexOf(char c, int off, int len) {
         char[] buf = value;
@@ -296,10 +296,10 @@ public class CBucket implements CharSequ
         }
         return slash;
     }
-    
+
     /**
      * Returns true if the message bytes starts with the specified string.
-     * 
+     *
      * @param c
      *            the character
      */
@@ -321,7 +321,7 @@ public class CBucket implements CharSequ
     public int indexOf(String src) {
         return indexOf(src, 0, src.length(), 0);
     }
-    
+
     public int indexOf(String src, int srcOff, int srcLen, int myOff) {
         char first = src.charAt(srcOff);
 
@@ -342,7 +342,7 @@ public class CBucket implements CharSequ
         }
         return -1;
     }
-    
+
     public char lastChar() {
         return value[end - 1];
     }
@@ -350,7 +350,7 @@ public class CBucket implements CharSequ
     public char charAt(int index) {
         return value[index + start];
     }
-    
+
     public void wrap(char[] buff, int start, int end) {
         if (value != null) {
             throw new RuntimeException("Can wrap only once");
@@ -359,13 +359,13 @@ public class CBucket implements CharSequ
         this.start = start;
         this.end = end;
     }
-    
+
     public CharSequence subSequence(int sstart, int send) {
         CBucket seq = new CBucket();
         seq.wrap(this.value, start + sstart, start + send);
         return seq;
     }
-    
+
     public int length() {
         return end - start;
     }
@@ -387,13 +387,13 @@ public class CBucket implements CharSequ
                 }
             }
             return len - destLen;
-            
+
         } else if (o instanceof CharSequence) {
             CharSequence dest = (CharSequence) o;
             int o1 = start, o2 = 0, result;
             int len = end - start;
             int destLen = dest.length();
-            int fin = (len < destLen ? 
+            int fin = (len < destLen ?
                     end : start + destLen);
             while (o1 < fin) {
                 if ((result = value[o1++] - dest.charAt(o2++)) != 0) {
@@ -401,7 +401,7 @@ public class CBucket implements CharSequ
                 }
             }
             return len - destLen;
-            
+
         } else {
             throw new RuntimeException("CompareTo not supported " + o);
         }
@@ -462,7 +462,7 @@ public class CBucket implements CharSequ
         }
         return result;
     }
-    
+
     public int getExtension(CBuffer ext, char slashC, char dotC) {
         int slash = lastIndexOf(slashC);
         if (slash < 0) {
@@ -483,17 +483,17 @@ public class CBucket implements CharSequ
         char[] c = value;
         int pos = start;
         int count = 0;
-    
+
         while (pos < end) {
             if ((c[pos++] == '/') && ((++count) == n)) {
                 pos--;
                 break;
             }
         }
-    
+
         return pos - start;
     }
-    
+
 
     public boolean hasUpper() {
         for (int i = start; i < end; i++) {
@@ -504,5 +504,5 @@ public class CBucket implements CharSequ
         }
         return false;
     }
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBuffer.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBuffer.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/CBuffer.java Sat Oct 22 21:30:59 2011
@@ -22,22 +22,22 @@ import java.nio.CharBuffer;
 
 
 /**
- * Similar with StringBuilder or StringBuffer, but with access to the 
+ * Similar with StringBuilder or StringBuffer, but with access to the
  * raw buffer - this avoids copying the data.
- * 
+ *
  * Utilities to manipluate char chunks. While String is the easiest way to
  * manipulate chars ( search, substrings, etc), it is known to not be the most
  * efficient solution - Strings are designed as imutable and secure objects.
- * 
+ *
  * @author dac@sun.com
  * @author James Todd [gonzo@sun.com]
  * @author Costin Manolache
  * @author Remy Maucherat
  */
-public class CBuffer extends CBucket implements Cloneable,   
+public class CBuffer extends CBucket implements Cloneable,
         Appendable {
 
-    
+
     /**
      * Creates a new, uninitialized CharChunk object.
      */
@@ -56,15 +56,15 @@ public class CBuffer extends CBucket imp
         start = 0;
         end = 0;
     }
-    
+
     /**
-     * Same as String 
+     * Same as String
      */
     public int hashCode() {
         int h = 0;
         int off = start;
         char val[] = value;
-        
+
         for (int i = start; i < end; i++) {
             h = 31*h + val[off++];
         }
@@ -93,18 +93,18 @@ public class CBuffer extends CBucket imp
         this.start = buff.start + off;
         this.end = this.start + srcEnd - off;
     }
-    
-    
+
+
     // ----------- Used for IOWriter / conversion ---------
-    
+
     public char[] array() {
         return value;
     }
-    
+
     public int position() {
         return start;
     }
-    
+
     CharBuffer getAppendCharBuffer() {
         makeSpace(16);
         if (cb == null || cb.array() != value) {
@@ -113,24 +113,24 @@ public class CBuffer extends CBucket imp
             cb.position(end);
             cb.limit(value.length);
         }
-        return cb;        
+        return cb;
     }
 
     void returnNioBuffer(CharBuffer c) {
         dirty();
         start = c.position();
     }
-    
+
     void returnAppendCharBuffer(CharBuffer c) {
         dirty();
         end = c.position();
     }
 
     // -------- Delete / replace ---------------
-    
-    /** 
+
+    /**
      * 'Delete' all chars after offset.
-     * 
+     *
      * @param offset
      */
     public void delete(int offset) {
@@ -148,7 +148,7 @@ public class CBuffer extends CBucket imp
     public CBuffer append(CharSequence csq, int astart, int aend)
             throws IOException {
         makeSpace(aend - astart);
-        
+
         for (int i = astart; i < aend; i++) {
             value[end++] = csq.charAt(i);
         }
@@ -232,8 +232,8 @@ public class CBuffer extends CBucket imp
         append(Integer.toString(i));
         return this;
     }
-    
-    
+
+
     public Appendable append(CharSequence cs) {
         if (cs instanceof CBuffer) {
             CBuffer src = (CBuffer) cs;
@@ -253,7 +253,7 @@ public class CBuffer extends CBucket imp
         return  this;
     }
 
-    
+
     public CBuffer append(BBucket bb) {
         byte[] bbuf = bb.array();
         int start = bb.position();
@@ -270,7 +270,7 @@ public class CBuffer extends CBucket imp
         end += len;
         return this;
     }
-    
+
 
     public void toAscii(BBuffer bb) {
         for (int i = start; i < end; i++) {
@@ -280,7 +280,7 @@ public class CBuffer extends CBucket imp
 
     /**
      *  Append and advance CharBuffer.
-     * 
+     *
      * @param c
      */
     public CBuffer put(CharBuffer c) {
@@ -291,7 +291,7 @@ public class CBuffer extends CBucket imp
 
     // ------------- 'set' methods ---------------
     // equivalent with clean + append
-    
+
     public CBuffer set(CBuffer csq, int off, int len) {
         recycle();
         append(csq.value, csq.start + off, csq.start + off + len);
@@ -303,7 +303,7 @@ public class CBuffer extends CBucket imp
         append(c, off, off + len);
         return this;
     }
-    
+
     public CBuffer set(BBucket bb) {
         recycle();
         byte[] bbuf = bb.array();
@@ -329,12 +329,12 @@ public class CBuffer extends CBucket imp
         append(csq);
         return this;
     }
-    
+
     private void dirty() {
         hash = 0;
         strValue = null;
     }
-    
+
     /**
      * Make space for len chars. If len is small, allocate a reserve space too.
      * Never grow bigger than limit.
@@ -378,10 +378,10 @@ public class CBuffer extends CBucket imp
                 if (BBuffer.isUpper(c)) {
                     value[i] = (char) BBuffer.toLower(c);
                 }
-                
+
             }
         }
     }
 
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/DumpChannel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/DumpChannel.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/DumpChannel.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/DumpChannel.java Sat Oct 22 21:30:59 2011
@@ -12,29 +12,29 @@ import java.io.OutputStream;
  * For debug - will print all bytes that go trough the channel
  */
 public class DumpChannel extends IOChannel {
-    
+
     IOBuffer in = new IOBuffer(this);
     IOBuffer out = new IOBuffer(this);
     static final boolean dumpToFile = false;
     static int idCnt = 0;
-    
+
     DumpChannel(String id) {
         this.id = id + idCnt++;
     }
-    
+
     public static IOChannel wrap(String id, IOChannel net) throws IOException {
-        if (id == null) { 
+        if (id == null) {
             id = "";
         }
         DumpChannel dmp = new DumpChannel(id + idCnt++);
         net.setHead(dmp);
         return dmp;
     }
-    
+
     public String toString() {
         return "Dump-" + id + "-" + net.toString();
     }
-    
+
     @Override
     public void handleReceived(IOChannel ch) throws IOException {
         processInput(ch.getIn());
@@ -71,7 +71,7 @@ public class DumpChannel extends IOChann
                     out("OUT", first, true);
                     net.getOut().close();
                 }
-                
+
                 net.startSending();
                 return;
             }
@@ -80,22 +80,22 @@ public class DumpChannel extends IOChann
             net.getOut().queue(first);
         }
     }
-    
+
     static int did = 0;
-    
+
     protected void out(String dir, BBucket first, boolean closed) {
         // Dump
         if (first != null) {
-            String hd = Hex.getHexDump(first.array(), first.position(), 
+            String hd = Hex.getHexDump(first.array(), first.position(),
                     first.remaining(), true);
             System.err.println("\n" + dir + ": " + id + " " +
                     (closed ? "CLS" : "") +
-                    + first.remaining() + "\n" + 
+                    + first.remaining() + "\n" +
                     hd);
         } else {
             System.err.println("\n" + dir + ": " + id + " " +
                     (closed ? "CLS " : "") +
-                     "END\n"); 
+                     "END\n");
         }
         if (dumpToFile && first != null) {
             try {
@@ -104,10 +104,10 @@ public class DumpChannel extends IOChann
                 os.close();
             } catch (IOException e) {
                 e.printStackTrace();
-            } 
+            }
         }
     }
-    
+
     @Override
     public IOBuffer getIn() {
         return in;

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FastHttpDateFormat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FastHttpDateFormat.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FastHttpDateFormat.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FastHttpDateFormat.java Sat Oct 22 21:30:59 2011
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHa
 
 /**
  * Utility class to generate HTTP dates.
- * 
+ *
  * @author Remy Maucherat
  */
 public final class FastHttpDateFormat {
@@ -36,14 +36,14 @@ public final class FastHttpDateFormat {
     // -------------------------------------------------------------- Variables
 
 
-    protected static final int CACHE_SIZE = 
+    protected static final int CACHE_SIZE =
         Integer.parseInt(System.getProperty("org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE", "1000"));
 
-    
+
     /**
      * HTTP date format.
      */
-    protected static final SimpleDateFormat format = 
+    protected static final SimpleDateFormat format =
         new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
 
 
@@ -89,14 +89,14 @@ public final class FastHttpDateFormat {
     /**
      * Formatter cache.
      */
-    protected static final ConcurrentHashMap<Long, String> formatCache = 
+    protected static final ConcurrentHashMap<Long, String> formatCache =
         new ConcurrentHashMap<Long, String>(CACHE_SIZE);
 
 
     /**
      * Parser cache.
      */
-    protected static final ConcurrentHashMap<String, Long> parseCache = 
+    protected static final ConcurrentHashMap<String, Long> parseCache =
         new ConcurrentHashMap<String, Long>(CACHE_SIZE);
 
 
@@ -154,7 +154,7 @@ public final class FastHttpDateFormat {
     /**
      * Try to parse the given date as a HTTP date.
      */
-    public static final long parseDate(String value, 
+    public static final long parseDate(String value,
                                        DateFormat[] threadLocalformats) {
 
         Long cachedDate = parseCache.get(value);

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnector.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnector.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnector.java Sat Oct 22 21:30:59 2011
@@ -4,12 +4,12 @@ package org.apache.tomcat.lite.io;
 
 
 /**
- * Initial abstraction for non-blocking File access and to 
- * support other abstraction. 
- * 
+ * Initial abstraction for non-blocking File access and to
+ * support other abstraction.
+ *
  * Tomcat uses JNDI - but that's blocking, does lots of data copy,
  * is complex.
- * 
+ *
  * Work in progress..
  */
 public abstract class FileConnector extends IOConnector {
@@ -18,9 +18,9 @@ public abstract class FileConnector exte
         String type;
         int mode;
         long size;
-        
+
     }
-    
+
     public abstract boolean isDirectory(String path);
 
     public abstract boolean isFile(String path);

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnectorJavaIo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnectorJavaIo.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnectorJavaIo.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FileConnectorJavaIo.java Sat Oct 22 21:30:59 2011
@@ -8,15 +8,15 @@ import java.io.IOException;
 
 /**
  * Catalina uses JNDI to abstract filesystem - this is both heavy and
- * a bit complex. 
- * 
- * This is also a bit complex - but hopefully we can implement it as 
+ * a bit complex.
+ *
+ * This is also a bit complex - but hopefully we can implement it as
  * non-blocking and without much copy.
- * 
+ *
  */
 public class FileConnectorJavaIo extends FileConnector {
     File base;
-    
+
     public FileConnectorJavaIo(File file) {
         this.base = file;
     }
@@ -34,11 +34,11 @@ public class FileConnectorJavaIo extends
     }
 
     @Override
-    public void acceptor(ConnectedCallback sc, 
-            CharSequence port, 
+    public void acceptor(ConnectedCallback sc,
+            CharSequence port,
             Object extra) throws IOException {
         // TODO: unix domain socket impl.
-        // Maybe: detect new files in the filesystem ? 
+        // Maybe: detect new files in the filesystem ?
     }
 
     @Override

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FutureCallbacks.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FutureCallbacks.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FutureCallbacks.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/FutureCallbacks.java Sat Oct 22 21:30:59 2011
@@ -15,37 +15,37 @@ import java.util.concurrent.locks.Abstra
 
 /**
  * Support for blocking calls and callbacks.
- * 
- * Unlike FutureTask, it is possible to reuse this and hopefully 
- * easier to extends. Also has callbacks.  
- * 
+ *
+ * Unlike FutureTask, it is possible to reuse this and hopefully
+ * easier to extends. Also has callbacks.
+ *
  * @author Costin Manolache
  */
 public class FutureCallbacks<V> implements Future<V> {
 
-    // Other options: ReentrantLock uses AbstractQueueSynchronizer, 
+    // Other options: ReentrantLock uses AbstractQueueSynchronizer,
     // more complex. Same for CountDownLatch
     // FutureTask - uses Sync as well, ugly interface with
     // Callable, can't be recycled.
     // Mina: simple object lock, doesn't extend java.util.concurent.Future
-    
-    private Sync sync = new Sync(); 
+
+    private Sync sync = new Sync();
 
     private V value;
 
     public static interface Callback<V> {
         public void run(V param);
     }
-    
+
     private List<Callback<V>> callbacks = new ArrayList();
-    
+
     public FutureCallbacks() {
     }
 
-    /** 
+    /**
      * Unlocks the object if it was locked. Should be called
      * when the object is reused.
-     * 
+     *
      * Callbacks will not be invoked.
      */
     public void reset() {
@@ -58,23 +58,23 @@ public class FutureCallbacks<V> implemen
         sync.releaseShared(0);
         sync.reset();
     }
-    
+
     /**
      * Unlocks object and calls the callbacks.
-     * @param v 
-     * 
+     * @param v
+     *
      * @throws IOException
      */
     public void signal(V v) throws IOException {
         sync.releaseShared(0);
         onSignal(v);
     }
-    
+
     protected boolean isSignaled() {
         return true;
     }
-    
-    /** 
+
+    /**
      * Override to call specific callbacks
      */
     protected void onSignal(V v) {
@@ -88,9 +88,9 @@ public class FutureCallbacks<V> implemen
     /**
      * Set the response. Will cause the callback to be called and lock to be
      * released.
-     * 
+     *
      * @param value
-     * @throws IOException 
+     * @throws IOException
      */
     public void setValue(V value) throws IOException {
         synchronized (this) {
@@ -108,7 +108,7 @@ public class FutureCallbacks<V> implemen
             throw new WrappedException(e1);
         } catch (ExecutionException e) {
             throw new WrappedException(e);
-        }                
+        }
     }
 
     @Override
@@ -143,12 +143,12 @@ public class FutureCallbacks<V> implemen
     }
 
     private class Sync extends AbstractQueuedSynchronizer {
-        
+
         static final int DONE = 1;
         static final int BLOCKED = 0;
         Object result;
         Throwable t;
-        
+
         @Override
         protected int tryAcquireShared(int ignore) {
             return getState() == DONE ? 1 : -1;
@@ -157,15 +157,15 @@ public class FutureCallbacks<V> implemen
         @Override
         protected boolean tryReleaseShared(int ignore) {
             setState(DONE);
-            return true; 
+            return true;
         }
 
         public void reset() {
             setState(BLOCKED);
         }
-        
+
         boolean isSignaled() {
             return getState() == DONE;
         }
-    }    
+    }
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/Hex.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/Hex.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/Hex.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/Hex.java Sat Oct 22 21:30:59 2011
@@ -58,9 +58,9 @@ public final class Hex {
     /**
      * Table for DEC to HEX byte translation.
      */
-    public static final byte[] HEX = 
-    { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5', 
-      (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'a', (byte) 'b', 
+    public static final byte[] HEX =
+    { (byte) '0', (byte) '1', (byte) '2', (byte) '3', (byte) '4', (byte) '5',
+      (byte) '6', (byte) '7', (byte) '8', (byte) '9', (byte) 'a', (byte) 'b',
       (byte) 'c', (byte) 'd', (byte) 'e', (byte) 'f' };
 
 
@@ -129,7 +129,7 @@ public final class Hex {
 
     }
 
-    
+
     /**
      * Convert 4 hex digits to an int, and return the number of converted
      * bytes.
@@ -141,7 +141,7 @@ public final class Hex {
      */
     public static int convert2Int( byte[] hex ) {
 	// Code from Ajp11, from Apache's JServ
-    
+
 	// assert b.length==4
 	// assert valid data
 	int len;
@@ -167,7 +167,7 @@ public final class Hex {
 
 
     /**
-     * Provide a mechanism for ensuring this class is loaded. 
+     * Provide a mechanism for ensuring this class is loaded.
      */
     public static void load() {
         // Nothing to do
@@ -192,13 +192,13 @@ public final class Hex {
     /**
      * <code>getHexValue</code> displays a formatted hex
      * representation of the passed byte array.  It also
-     * allows for only a specified offset and length of 
+     * allows for only a specified offset and length of
      * a particular array to be returned.
      *
      * @param bytes <code>byte[]</code> array to process.
      * @param pos offset to begin processing.
      * @param len number of bytes to process.
-     * @return <code>String</code> formatted hex representation of processed 
+     * @return <code>String</code> formatted hex representation of processed
      *         array.
      */
     public static String getHexDump(byte[] bytes, int pos, int len,
@@ -208,11 +208,11 @@ public final class Hex {
         for (int j = 0; j < len; j += 16) {
             hexLine(out, bytes, pos + j, pos + len, displayOffset);
         }
-     
+
         return out.toString();
     }
-    
-    private static void hexLine(StringBuffer out, 
+
+    private static void hexLine(StringBuffer out,
                                 byte[] bytes, int start, int end,
                                 boolean displayOffset) {
 
@@ -229,13 +229,13 @@ public final class Hex {
                 out.append(convertDigit((int) (bytes[i] >> 4)));
                 out.append(convertDigit(bytes[i] & 0x0F));
                 out.append(" ");
-            } else { 
+            } else {
                 out.append("   ");
             }
         }
-        
+
         out.append(" | ");
-        
+
         for (int i = start; i < start + 16 && i < end; i++) {
             if( ! Character.isISOControl( (char)bytes[i] )) {
                 out.append( new Character((char)bytes[i]) );
@@ -243,7 +243,7 @@ public final class Hex {
                 out.append( "." );
             }
         }
-        
+
         out.append("\n");
     }
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/IOBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/IOBuffer.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/IOBuffer.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/io/IOBuffer.java Sat Oct 22 21:30:59 2011
@@ -10,26 +10,26 @@ import java.util.logging.Logger;
 
 
 // TODO: append() will trigger callbacks - do it explicitely !!!
-// TODO: queue() shouldn't modify the buffer 
+// TODO: queue() shouldn't modify the buffer
 
 
-/** 
+/**
  * A list of data buckets.
- * 
+ *
  * @author Costin Manolache
  */
 public class IOBuffer {
     static Logger log = Logger.getLogger("IOBrigade");
-    
+
     static int ALLOC_SIZE = 8192;
     long defaultTimeout = Long.MAX_VALUE;
-    
+
     private LinkedList<BBucket> buffers = new LinkedList<BBucket>();
-    
+
     // close() has been called for out,
     // or EOF/FIN received for in. It may still have data.
-    boolean closeQueued; 
-    
+    boolean closeQueued;
+
     // Will be signalled (open) when there is data in the buffer.
     // also used to sync on.
     FutureCallbacks<IOBuffer> hasDataLock = new FutureCallbacks<IOBuffer>() {
@@ -40,41 +40,41 @@ public class IOBuffer {
 
     // may be null
     protected IOChannel ch;
-    
+
     // Support for appending - needs improvements.
-    // appendable buffer is part of the buffer list if it has 
+    // appendable buffer is part of the buffer list if it has
     // data, and kept here if empty.
     BBuffer appendable;
     boolean appending = false;
     ByteBuffer writeBuffer;
-    
+
 
     public IOBuffer() {
     }
-    
+
     public IOBuffer(IOChannel ch) {
         this.ch = ch;
     }
-    
+
     public IOChannel getChannel() {
         return ch;
     }
-    
+
     // ===== Buffer access =====
-    
-    
+
+
     /**
      * Return first non-empty buffer.
-     * 
+     *
      * The append buffer is part of the buffer list, and is left alone and
      * empty.
-     * 
+     *
      * @return
      */
     public BBucket peekFirst() {
         synchronized (buffers) {
             BBucket o = (buffers.size() == 0) ? null : buffers.getFirst();
-            
+
             while (true) {
                 boolean empty = o == null || isEmpty(o);
                 if (o == null) {
@@ -84,20 +84,20 @@ public class IOBuffer {
                 // o != null
                 if (empty) {
                     buffers.removeFirst();
-                    o = (buffers.size() == 0) ? null : buffers.getFirst();                    
+                    o = (buffers.size() == 0) ? null : buffers.getFirst();
                 } else {
                     return o;
                 }
             }
         }
     }
-    
+
     public BBucket peekBucket(int idx) {
         synchronized (buffers) {
             return buffers.get(idx);
         }
     }
-    
+
 
     public void advance(int len) {
         while (len > 0) {
@@ -109,7 +109,7 @@ public class IOBuffer {
                 len -= first.remaining();
                 first.position(first.limit());
             } else {
-                first.position(first.position() + len);                
+                first.position(first.position() + len);
                 len = 0;
             }
         }
@@ -120,15 +120,15 @@ public class IOBuffer {
         byte[] bytes = s.getBytes("UTF8");
         queueInternal(BBuffer.wrapper(bytes, 0, bytes.length));
     }
-    
+
     public void queue(BBuffer bc) throws IOException {
         queueInternal(bc);
     }
-    
+
     public void queue(Object bb) throws IOException {
         queueInternal(bb);
     }
-    
+
     private void queueInternal(Object bb) throws IOException {
         if (closeQueued) {
             throw new IOException("Closed");
@@ -143,22 +143,22 @@ public class IOBuffer {
             //log.info("QUEUED: " + add.remaining() + " " + this);
             notifyDataAvailable(add);
         }
-        
+
     }
-    
+
     public int getBufferCount() {
         peekFirst();
         synchronized (buffers) {
             return buffers.size();
         }
     }
-    
+
     public void clear() {
         synchronized (buffers) {
             buffers.clear();
         }
     }
-    
+
     public void recycle() {
         closeQueued = false;
         clear();
@@ -168,7 +168,7 @@ public class IOBuffer {
         appending = false;
         appendable = null;
     }
-    
+
     // ===================
     /**
      * Closed for append. It may still have data.
@@ -178,8 +178,8 @@ public class IOBuffer {
         return closeQueued && 0 == getBufferCount();
     }
 
-    
-    /** 
+
+    /**
      * Mark as closed - but will not send data.
      */
     public void close() throws IOException {
@@ -189,16 +189,16 @@ public class IOBuffer {
         closeQueued = true;
         notifyDataAvailable(null);
     }
-    
-    
+
+
     private boolean isEmpty(BBucket o) {
-        if (o instanceof BBucket && 
+        if (o instanceof BBucket &&
                 ((BBucket) o).remaining() == 0) {
             return true;
-        }        
+        }
         return false;
     }
-    
+
     private BBucket wrap(Object src) {
         if (src instanceof byte[]) {
             return BBuffer.wrapper((byte[]) src, 0, ((byte[]) src).length);
@@ -206,26 +206,26 @@ public class IOBuffer {
         if (src instanceof ByteBuffer) {
             //return src;
             ByteBuffer bb = (ByteBuffer) src;
-            return BBuffer.wrapper(bb.array(), bb.position(), 
-                        bb.remaining());            
+            return BBuffer.wrapper(bb.array(), bb.position(),
+                        bb.remaining());
         }
         if (src instanceof byte[]) {
             byte[] bb = (byte[]) src;
-            return BBuffer.wrapper(bb, 0, bb.length); 
+            return BBuffer.wrapper(bb, 0, bb.length);
         }
         return (BBucket) src;
     }
-    
+
     protected void notifyDataAvailable(Object bb) throws IOException {
         synchronized (hasDataLock) {
             hasDataLock.signal(this); // or bb ?
         }
     }
-    
+
     public boolean hasData() {
-        return closeQueued || peekFirst() != null; 
+        return closeQueued || peekFirst() != null;
     }
-    
+
     public void waitData(long timeMs) throws IOException {
         if (timeMs == 0) {
             timeMs = defaultTimeout;
@@ -248,7 +248,7 @@ public class IOBuffer {
 
     /**
      * Non-blocking read.
-     * 
+     *
      * @return -1 if EOF, -2 if no data available, or 0..255 for normal read.
      */
     public int read() throws IOException {
@@ -263,7 +263,7 @@ public class IOBuffer {
         bucket.position(bucket.position() + 1);
         return res & 0xFF;
     }
-    
+
     public int peek() throws IOException {
         BBucket bucket = peekFirst();
         if (bucket == null) {
@@ -272,7 +272,7 @@ public class IOBuffer {
         int res = bucket.array()[bucket.position()];
         return res;
     }
-    
+
     public int find(char c) {
         int pos = 0;
         for (int i = 0; i < buffers.size(); i++) {
@@ -283,20 +283,20 @@ public class IOBuffer {
             int found= BBuffer.findChar(bucket.array(), bucket.position(),
                     bucket.limit(), c);
             if (found >= 0) {
-                return pos + found; 
+                return pos + found;
             }
             pos += bucket.remaining();
         }
         return -1;
     }
-    
+
     public int readLine(BBuffer bc) throws IOException {
         return readToDelim(bc, '\n');
     }
-    
+
     /**
-     * Copy up to and including "delim". 
-     * 
+     * Copy up to and including "delim".
+     *
      * @return number of bytes read, or -1 for end of stream.
      */
     int readToDelim(BBuffer bc, int delim) throws IOException {
@@ -314,7 +314,7 @@ public class IOBuffer {
                 bc.put(chr);
                 if (chr == delim) {
                     bucket.position(i + 1);
-                    len += (i - start + 1); 
+                    len += (i - start + 1);
                     return len;
                 }
             }
@@ -325,8 +325,8 @@ public class IOBuffer {
         }
         return len;
     }
-    
-    
+
+
     public int write(ByteBuffer bb) throws IOException {
         int len = bb.remaining();
         int pos = bb.position();
@@ -337,7 +337,7 @@ public class IOBuffer {
         bb.position(pos + len);
         return len;
     }
-    
+
     public int read(byte[] buf, int off, int len) throws IOException {
         if (isClosedAndEmpty()) {
             return -1;
@@ -349,7 +349,7 @@ public class IOBuffer {
                 return rd;
             }
             int toCopy = Math.min(len, bucket.remaining());
-            System.arraycopy(bucket.array(), bucket.position(), 
+            System.arraycopy(bucket.array(), bucket.position(),
                     buf, off + rd, toCopy);
             bucket.position(bucket.position() + toCopy);
             rd += toCopy;
@@ -358,7 +358,7 @@ public class IOBuffer {
                 return rd;
             }
         }
-        
+
     }
 
     public int read(BBuffer bb, int len) throws IOException {
@@ -370,7 +370,7 @@ public class IOBuffer {
         bb.limit(bb.limit() + rd);
         return rd;
     }
-    
+
     /**
      * Non-blocking read.
      */
@@ -397,9 +397,9 @@ public class IOBuffer {
             iob.position(iob.position() + space);
             iob.release();
             len += space;
-        }        
+        }
     }
-    
+
 
     public BBuffer readAll(BBuffer chunk) throws IOException {
         if (chunk == null) {
@@ -417,13 +417,13 @@ public class IOBuffer {
             chunk.append(iob.array(), iob.position(), iob.remaining());
             iob.position(iob.position() + iob.remaining());
             iob.release();
-    
+
         }
     }
 
     private BBuffer allocate() {
         int size = 0;
-        for (int i = 0; i < getBufferCount(); i++) { 
+        for (int i = 0; i < getBufferCount(); i++) {
             BBucket first = peekBucket(i);
             if (first != null) {
                 size += first.remaining();
@@ -431,12 +431,12 @@ public class IOBuffer {
         }
         return BBuffer.allocate(size);
     }
-    
+
     public BBuffer copyAll(BBuffer chunk) throws IOException {
         if (chunk == null) {
             chunk = allocate();
         }
-        for (int i = 0; i < getBufferCount(); i++) { 
+        for (int i = 0; i < getBufferCount(); i++) {
             BBucket iob = peekBucket(i);
             chunk.append(iob.array(), iob.position(), iob.remaining());
         }
@@ -462,20 +462,20 @@ public class IOBuffer {
     public IOBuffer append(byte[] data) throws IOException {
         return append(data, 0, data.length);
     }
-    
+
     public IOBuffer append(byte[] data, int start, int len) throws IOException {
         if (closeQueued) {
             throw new IOException("Closed");
         }
         ByteBuffer bb = getWriteBuffer();
-        
+
         int i = start;
         int end = start + len;
         while (i < end) {
-            int rem = Math.min(end - i, bb.remaining()); 
+            int rem = Math.min(end - i, bb.remaining());
             // to write
             bb.put(data, i, rem);
-            i += rem; 
+            i += rem;
             if (bb.remaining() < 8) {
                 releaseWriteBuffer(1);
                 bb = getWriteBuffer();
@@ -483,9 +483,9 @@ public class IOBuffer {
         }
 
         releaseWriteBuffer(1);
-        return this;        
+        return this;
     }
-    
+
     public IOBuffer append(int data) throws IOException {
         if (closeQueued) {
             throw new IOException("Closed");
@@ -493,14 +493,14 @@ public class IOBuffer {
         ByteBuffer bb = getWriteBuffer();
         bb.put((byte) data);
         releaseWriteBuffer(1);
-        return this;        
+        return this;
     }
-    
+
     public IOBuffer append(ByteBuffer cs) throws IOException {
-        return append(cs.array(), cs.position() + cs.arrayOffset(), 
+        return append(cs.array(), cs.position() + cs.arrayOffset(),
                 cs.remaining());
     }
-    
+
     /**
      *  Append a buffer. The buffer will not be modified.
      */
@@ -523,7 +523,7 @@ public class IOBuffer {
             append(o);
         }
 
-        return this;        
+        return this;
     }
 
     public IOBuffer append(IOBuffer cs, int len) throws IOException {
@@ -532,9 +532,9 @@ public class IOBuffer {
             append(o);
         }
 
-        return this;        
+        return this;
     }
-    
+
     public IOBuffer append(CharSequence cs) throws IOException {
         byte[] data = cs.toString().getBytes();
         append(data, 0, data.length);
@@ -545,11 +545,11 @@ public class IOBuffer {
         ByteBuffer bb = getWriteBuffer();
         bb.put((byte) c);
         releaseWriteBuffer(1);
-        return this;        
+        return this;
     }
-    
+
     /**
-     * All operations that iterate over buffers must be 
+     * All operations that iterate over buffers must be
      * sync
      * @return
      */
@@ -561,7 +561,7 @@ public class IOBuffer {
         }
         return a;
     }
-    
+
     public String toString() {
         return "IOB:{c:" + getBufferCount() +
           ", b:" + available() +
@@ -578,7 +578,7 @@ public class IOBuffer {
         o.position(o.position() + lenToConsume);
         return sb;
     }
-    
+
     public BBucket popFirst() {
         BBucket o = peekFirst(); // skip empty
         if (o == null) {
@@ -587,9 +587,9 @@ public class IOBuffer {
         if (o == appendable) {
             synchronized (buffers) {
                     // TODO: concurrency ???
-                    BBucket sb = 
+                    BBucket sb =
                         BBuffer.wrapper(appendable.array(),
-                                appendable.position(), 
+                                appendable.position(),
                                 appendable.limit() - appendable.position());
                     appendable.position(appendable.limit());
                     return sb;
@@ -599,22 +599,22 @@ public class IOBuffer {
         }
         return o;
     }
-    
+
 
     public ByteBuffer getWriteBuffer() throws IOException {
         synchronized (buffers) {
             if (closeQueued) {
                 throw new IOException("Closed");
             }
-            BBucket last = (buffers.size() == 0) ? 
+            BBucket last = (buffers.size() == 0) ?
                     null : buffers.getLast();
             if (last == null || last != appendable ||
                     last.array().length - last.limit() < 16) {
                 last = BBuffer.allocate(ALLOC_SIZE);
             }
             appending = true;
-            appendable = (BBuffer) last;            
-            
+            appendable = (BBuffer) last;
+
             if (writeBuffer == null || writeBuffer.array() != appendable.array()) {
                 writeBuffer = ByteBuffer.wrap(appendable.array());
             }
@@ -622,8 +622,8 @@ public class IOBuffer {
             writeBuffer.limit(appendable.array().length);
             return writeBuffer;
         }
-    }        
-    
+    }
+
     public void releaseWriteBuffer(int read) throws IOException {
         synchronized (buffers) {
             if (!appending) {
@@ -633,11 +633,11 @@ public class IOBuffer {
                 if (appendable.limit() != writeBuffer.position()) {
                     appendable.limit(writeBuffer.position());
                     // We have some more data.
-                    if (buffers.size() == 0 || 
+                    if (buffers.size() == 0 ||
                             buffers.getLast() != appendable) {
                         buffers.add(appendable);
                     }
-                    notifyDataAvailable(appendable);                
+                    notifyDataAvailable(appendable);
                 }
             }
             appending = false;
@@ -659,7 +659,7 @@ public class IOBuffer {
 //}
 
 //public final int readToDelimAndLowerCase(ByteBuffer bb,
-//                                         byte delim, 
+//                                         byte delim,
 //                                         boolean lower) {
 //  boolean space = false;
 //  byte chr = 0;
@@ -672,7 +672,7 @@ public class IOBuffer {
 //      space = true;
 //    }
 //    if (lower && (chr >= HttpParser.A) && (chr <= HttpParser.Z)) {
-//      bb.put(bb.position() - 1, 
+//      bb.put(bb.position() - 1,
 //          (byte) (chr - HttpParser.LC_OFFSET));
 //    }
 //  }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message