tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1187812 [2/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/Http11Connection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/Http11Connection.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/Http11Connection.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/Http11Connection.java Sat Oct 22 21:30:59 2011
@@ -21,43 +21,43 @@ import org.apache.tomcat.lite.io.IOBuffe
 import org.apache.tomcat.lite.io.IOChannel;
 import org.apache.tomcat.lite.io.IOConnector;
 
-public class Http11Connection extends HttpConnection 
+public class Http11Connection extends HttpConnection
         implements IOConnector.ConnectedCallback {
     public static final String CHUNKED = "chunked";
-    
-    public static final String CLOSE = "close"; 
-    
+
+    public static final String CLOSE = "close";
+
     public static final String KEEPALIVE_S = "keep-alive";
 
     public static final String CONNECTION = "connection";
-    
+
     public static final String TRANSFERENCODING = "transfer-encoding";
-    
+
 
     protected static Logger log = Logger.getLogger("Http11Connection");
     static final byte COLON = (byte) ':';
 
-    // super.net is the socket 
-    
+    // super.net is the socket
+
     boolean debug;
-    BBuffer line = BBuffer.wrapper(); 
+    BBuffer line = BBuffer.wrapper();
     boolean endSent = false;
-    
+
     BodyState receiveBodyState = new BodyState();
     BodyState sendBodyState = new BodyState();
-    
+
     BBuffer headW = BBuffer.wrapper();
-    
+
     boolean headersReceived = false;
     boolean bodyReceived = false;
 
-    /** 
-     * Close connection when done writting, no content-length/chunked, 
+    /**
+     * Close connection when done writting, no content-length/chunked,
      * or no keep-alive ( http/1.0 ) or error.
-     * 
+     *
      * ServerMode: set if HTTP/0.9 &1.0 || !keep-alive
      * ClientMode: not currently used
-     */    
+     */
     boolean keepAlive = true;
 
     protected boolean http11 = true;
@@ -70,7 +70,7 @@ public class Http11Connection extends Ht
 
     // dataReceived and endSendReceive
     private Object readLock = new Object();
-    
+
     public Http11Connection(HttpConnector httpConnector) {
         this.httpConnector = httpConnector;
         if (httpConnector != null) {
@@ -94,12 +94,12 @@ public class Http11Connection extends Ht
         headersReceived = false;
         bodyReceived = false;
     }
-    
+
     public Http11Connection serverMode() {
         serverMode = true;
         return this;
     }
-       
+
     private boolean readHead() throws IOException {
         while (true) {
             int read;
@@ -113,10 +113,10 @@ public class Http11Connection extends Ht
                     return false; // need more
                 }
                 // we have at least 4 bytes
-                if (headRecvBuf.get(0) == 0x80 && 
+                if (headRecvBuf.get(0) == 0x80 &&
                         headRecvBuf.get(1) == 0x01) {
                     // SPDY signature ( experimental )
-                    switchedProtocol = new SpdyConnection(httpConnector, 
+                    switchedProtocol = new SpdyConnection(httpConnector,
                             remoteHost);
                     if (serverMode) {
                         switchedProtocol.serverMode = true;
@@ -126,9 +126,9 @@ public class Http11Connection extends Ht
                     switchedProtocol.setSink(net);
                     return false;
                 }
-                
+
             }
-            
+
             // we know we have one
             read = net.getIn().readLine(headRecvBuf);
             // Remove starting empty lines.
@@ -145,14 +145,14 @@ public class Http11Connection extends Ht
                 return closeInHead();
             }
         }
-        
-        
+
+
         return true;
     }
-    
+
     private boolean closeInHead() throws IOException {
         if (debug) {
-            trace("CLOSE while reading HEAD");    
+            trace("CLOSE while reading HEAD");
         }
         // too early - we don't have the head
         abort("Close in head");
@@ -187,13 +187,13 @@ public class Http11Connection extends Ht
         if (!checkKeepAliveClient()) {
             return; // we were in client keep alive mode
         }
-        // endSendReceived uses same lock - it will call this 
+        // endSendReceived uses same lock - it will call this
         // to check outstanding bytes
         synchronized (readLock) {
             if (bodyReceived) {
                 return; // leave data in net buffer, for next req
             }
-            
+
             if (!headersReceived) {
                 if (!readHead()) {
                     return;
@@ -216,19 +216,19 @@ public class Http11Connection extends Ht
                 if (switchedProtocol != null) {
                     return;
                 }
-                
+
                 if (serverMode && activeHttp.httpReq.decodedUri.remaining() == 0) {
                     abort(activeHttp, "Invalid url");
                 }
 
                 headersReceived = true;
-                // Send header callbacks - we process any incoming data 
+                // Send header callbacks - we process any incoming data
                 // first, so callbacks have more info
                 trace("Send headers received callback " + activeHttp.httpService);
                 activeHttp.handleHeadersReceived(activeHttp.inMessage);
             }
 
-            // any remaining data will be processed as part of the 
+            // any remaining data will be processed as part of the
             // body - or left in the channel until endSendReceive()
 
             if (!bodyReceived) {
@@ -250,13 +250,13 @@ public class Http11Connection extends Ht
                 // If not already closed.
                 closeStreamOnEnd("closed after body");
             }
-        
+
         }
     }
 
     /**
-     * We got data while in client keep alive ( no activeHttp ) 
-     * 
+     * We got data while in client keep alive ( no activeHttp )
+     *
      * @return false if there is an error
      */
     private boolean checkKeepAliveClient() throws IOException {
@@ -270,7 +270,7 @@ public class Http11Connection extends Ht
             if (net.getIn().available() == 0) {
                 return true;
             }
-            log.warning("Unexpected message from server in client keep alive " 
+            log.warning("Unexpected message from server in client keep alive "
                     + net.getIn() + ": " + net.getIn().readAll(null));
             if (net.isOpen()) {
                 net.close();
@@ -279,12 +279,12 @@ public class Http11Connection extends Ht
         }
         return true;
     }
-    
+
     private void processProtocol(CBuffer protocolMB) throws IOException {
         http11 = false;
         http09 = false;
         http10 = false;
-        
+
         if (protocolMB.equals(HttpChannel.HTTP_11)) {
             http11 = true;
         } else if (protocolMB.equals(HttpChannel.HTTP_10)) {
@@ -292,7 +292,7 @@ public class Http11Connection extends Ht
         } else if (protocolMB.equals("")) {
             http09 = true;
         } else {
-            http11 = true; // hopefully will be backward compat 
+            http11 = true; // hopefully will be backward compat
         }
     }
 
@@ -349,13 +349,13 @@ public class Http11Connection extends Ht
             handleReceived(net); // will attempt to read next req
         }
     }
-    
+
     private void trace(String s) {
         if(debug) {
             log.info(this.toString() + " " + activeHttp + " " + s);
         }
     }
-    
+
     private boolean isDone(BodyState bodys, IOBuffer body) {
         if (bodys.noBody) {
             return true;
@@ -369,12 +369,12 @@ public class Http11Connection extends Ht
         }
         return false;
     }
-    
+
     void parseMessage(HttpChannel http, BBuffer headB) throws IOException {
         //Parse the response
         line.recycle();
         headB.readLine(line);
-        
+
         HttpMessageBytes msgBytes;
 
         if (serverMode) {
@@ -385,19 +385,19 @@ public class Http11Connection extends Ht
                     msgBytes.protocol());
         } else {
             msgBytes = http.httpRes.getMsgBytes();
-            parseResponseLine(line, msgBytes.protocol(), 
+            parseResponseLine(line, msgBytes.protocol(),
                     msgBytes.status(), msgBytes.message());
         }
-        
+
         parseHeaders(http, msgBytes, headB);
 
         http.inMessage.state = HttpMessage.State.BODY_DATA;
-        
+
         http.inMessage.processReceivedHeaders();
-        
+
         // TODO: hook to allow specific charsets ( can be done later )
         processProtocol(http.inMessage.protocol());
-        
+
         if (serverMode) {
             // requested connection:close/keepAlive and proto
             updateKeepAlive(http.getRequest().getMimeHeaders(), true);
@@ -405,9 +405,9 @@ public class Http11Connection extends Ht
             processExpectation(http);
 
             processContentDelimitation(receiveBodyState, http.getRequest());
-            // Spec: 
-            // The presence of a message-body in a request is signaled by the 
-            // inclusion of a Content-Length or Transfer-Encoding header field in 
+            // Spec:
+            // The presence of a message-body in a request is signaled by the
+            // inclusion of a Content-Length or Transfer-Encoding header field in
             // the request's message-headers
             // Server should read - but ignore ..
             receiveBodyState.noBody = !receiveBodyState.isContentDelimited();
@@ -415,29 +415,29 @@ public class Http11Connection extends Ht
             updateCloseOnEnd(receiveBodyState, http, http.receiveBody);
 
             /*
-             * The presence of a message-body in a request is signaled by the 
-             * inclusion of a Content-Length or Transfer-Encoding header field in 
-             * the request's message-headers. A message-body MUST NOT be included 
-             * in a request if the specification of the request method 
-             * (section 5.1.1) does not allow sending an entity-body in requests. 
+             * The presence of a message-body in a request is signaled by the
+             * inclusion of a Content-Length or Transfer-Encoding header field in
+             * the request's message-headers. A message-body MUST NOT be included
+             * in a request if the specification of the request method
+             * (section 5.1.1) does not allow sending an entity-body in requests.
              * A server SHOULD read and forward a message-body on any request; if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.
              */
             if (!receiveBodyState.isContentDelimited()) {
                 // No body
                 http.getIn().close();
-            } 
+            }
 
         } else {
             receiveBodyState.noBody = !http.getResponse().hasBody();
-            
+
             updateKeepAlive(http.getResponse().getMimeHeaders(), false);
-            
+
             if (statusDropsConnection(http.getResponse().getStatus())) {
                 closeStreamOnEnd("response status drops connection");
             }
             IOBuffer body = http.receiveBody;
             processContentDelimitation(receiveBodyState, http.getResponse());
-            
+
             if (isDone(receiveBodyState, body)) {
                 body.close();
             }
@@ -446,9 +446,9 @@ public class Http11Connection extends Ht
                 closeStreamOnEnd("not content delimited");
             }
         }
-    
+
     }
-    
+
     private void processExpectation(HttpChannel http) throws IOException {
         http.expectation = false;
         MultiMap headers = http.getRequest().getMimeHeaders();
@@ -458,7 +458,7 @@ public class Http11Connection extends Ht
                 && (expect.indexOf("100-continue") != -1)) {
             http.expectation = true;
 
-            // TODO: configure, use the callback or the servlet 'read'. 
+            // TODO: configure, use the callback or the servlet 'read'.
             net.getOut().append("HTTP/1.1 100 Continue\r\n\r\n");
             net.startSending();
         }
@@ -466,17 +466,17 @@ public class Http11Connection extends Ht
 
 
     /**
-     * Updates chunked, contentLength, remaining - based 
+     * Updates chunked, contentLength, remaining - based
      * on headers
      */
-    private void processContentDelimitation(BodyState bodys, 
+    private void processContentDelimitation(BodyState bodys,
             HttpMessage httpMsg) {
 
         bodys.contentLength = httpMsg.getContentLength();
         if (bodys.contentLength >= 0) {
             bodys.remaining = bodys.contentLength;
-        }        
-        
+        }
+
         // TODO: multiple transfer encoding headers, only process the last
         String transferEncodingValue = httpMsg.getHeader(TRANSFERENCODING);
         if (transferEncodingValue != null) {
@@ -499,7 +499,7 @@ public class Http11Connection extends Ht
                 httpMsg.chunked = true;
             } else {
                 System.err.println("TODO: ABORT 501");
-                //return 501; // Currently only chunked is supported for 
+                //return 501; // Currently only chunked is supported for
                 // transfer encoding.
             }
         }
@@ -507,18 +507,18 @@ public class Http11Connection extends Ht
         if (bodys.chunked) {
             bodys.remaining = 0;
         }
-    }    
-        
+    }
+
     /**
-     * Read the request line. This function is meant to be used during the 
-     * HTTP request header parsing. Do NOT attempt to read the request body 
+     * Read the request line. This function is meant to be used during the
+     * HTTP request header parsing. Do NOT attempt to read the request body
      * using it.
      *
      * @throws IOException If an exception occurs during the underlying socket
      * read operations, or if the given buffer is not big enough to accomodate
      * the whole line.
      */
-    boolean parseRequestLine(BBuffer line, 
+    boolean parseRequestLine(BBuffer line,
             BBuffer methodMB, BBuffer requestURIMB,
             BBuffer queryMB,
             BBuffer protoMB)
@@ -526,7 +526,7 @@ public class Http11Connection extends Ht
 
         line.readToSpace(methodMB);
         line.skipSpace();
-        
+
         line.readToDelimOrSpace(HttpChannel.QUESTION, requestURIMB);
         if (line.remaining() > 0 && line.get(0) == HttpChannel.QUESTION) {
             // Has query
@@ -539,7 +539,7 @@ public class Http11Connection extends Ht
         line.skipSpace();
 
         line.readToSpace(protoMB);
-        
+
         // proto is optional ( for 0.9 )
         return requestURIMB.remaining() > 0;
     }
@@ -554,30 +554,30 @@ public class Http11Connection extends Ht
         line.readToSpace(statusCode);
         line.skipSpace();
         line.wrapTo(status);
-        
+
         // message may be empty
         return statusCode.remaining() > 0;
     }
 
     List<String> connectionHeaders = new ArrayList<String>();
-    
+
     private void parseHeaders(HttpChannel http, HttpMessageBytes msgBytes,
-            BBuffer head) 
+            BBuffer head)
                 throws IOException {
-        
+
         head.readLine(line);
-        
+
         int idx = 0;
-        
+
         BBuffer upgrade = null;
-        
+
         while(line.remaining() > 0) {
             // not empty..
             idx = msgBytes.addHeader();
             BBuffer nameBuf = msgBytes.getHeaderName(idx);
             BBuffer valBuf = msgBytes.getHeaderValue(idx);
             parseHeader(http, head, line, nameBuf, valBuf);
-            
+
             // TODO: process 'interesting' headers here.
             if (nameBuf.equalsIgnoreCase("connection")) {
                 // TODO: save and remove if not recognized
@@ -586,29 +586,29 @@ public class Http11Connection extends Ht
                 upgrade = valBuf;
             }
         }
-        
+
         if (upgrade != null) {
             if (upgrade.equalsIgnoreCase("WebSocket")) {
-                
+
             } else if (upgrade.equalsIgnoreCase("SPDY/1.0")) {
-                
+
             }
         }
-        
-        // TODO: process connection headers 
+
+        // TODO: process connection headers
     }
 
     /**
-     * Parse one header. 
+     * Parse one header.
      * Line must be populated. On return line will be populated
      * with the next header:
-     * 
+     *
      * @param line current header line, not empty.
      */
-    int parseHeader(HttpChannel http, BBuffer head, 
+    int parseHeader(HttpChannel http, BBuffer head,
             BBuffer line, BBuffer name, BBuffer value)
           throws IOException {
-        
+
         int newPos = line.readToDelimOrSpace(COLON, name);
         line.skipSpace();
         if (line.readByte() != COLON) {
@@ -616,7 +616,7 @@ public class Http11Connection extends Ht
         }
         line.skipSpace();
         line.read(value); // remaining of the line
-        
+
         while (true) {
             head.readLine(line);
             if (line.remaining() == 0) {
@@ -635,34 +635,34 @@ public class Http11Connection extends Ht
         http.normalizeHeader(value);
         return 1;
     }
-    
+
     private int receiveDone(HttpChannel http, IOBuffer body, boolean frameError) throws IOException {
         // Content-length case, we're done reading
         body.close();
-        
+
         http.error = frameError;
         if (frameError) {
             closeStreamOnEnd("frame error");
         }
 
-        return DONE;        
+        return DONE;
     }
 
-    /** 
+    /**
      * Called when raw body data is received.
      * Callback should not consume past the end of the body.
-     * @param rawReceiveBuffers 
-     *  
+     * @param rawReceiveBuffers
+     *
      */
-    private void rawDataReceived(HttpChannel http, IOBuffer body, 
+    private void rawDataReceived(HttpChannel http, IOBuffer body,
             IOBuffer rawReceiveBuffers) throws IOException {
         // TODO: Make sure we don't process more than we need ( eat next req ).
         // If we read too much: leave it in readBuf, the finalzation code
         // should skip KeepAlive and start processing it.
-        // we need to read at least something - to detect -1 ( we could 
+        // we need to read at least something - to detect -1 ( we could
         // suspend right away, but seems safer
         BodyState bodys = receiveBodyState;
-        
+
         while (http.inMessage.state == HttpMessage.State.BODY_DATA) {
             if (receiveBodyState.noBody) {
                 receiveDone(http, body, false);
@@ -674,20 +674,20 @@ public class Http11Connection extends Ht
                         receiveDone(http, body, false);
                     } else {
                         // End of input - other side closed, no more data
-                        //log.info("CLOSE while reading " + this);    
+                        //log.info("CLOSE while reading " + this);
                         // they're not supposed to close !
                         receiveDone(http, body, true);
                     }
                 } else {
                     receiveDone(http, body, false); // ok
                 }
-                // input connection closed ? 
+                // input connection closed ?
                 closeStreamOnEnd("Closed input");
                 return;
             }
             BBucket rawBuf = rawReceiveBuffers.peekFirst();
             if (rawBuf == null) {
-                return;  // need more data                 
+                return;  // need more data
             }
 
             if (!bodys.isContentDelimited()) {
@@ -700,7 +700,7 @@ public class Http11Connection extends Ht
                     }
                 }
             } else {
-                
+
                 if (bodys.contentLength >= 0 && bodys.remaining == 0) {
                     receiveDone(http, body, false);
                     return;
@@ -729,9 +729,9 @@ public class Http11Connection extends Ht
 
                 rawBuf = (BBucket) rawReceiveBuffers.peekFirst();
                 if (rawBuf == null) {
-                    return;  // need more data                 
+                    return;  // need more data
                 }
-                
+
 
                 if (bodys.remaining < rawBuf.remaining()) {
                     // To buffer has more data than we need.
@@ -759,8 +759,8 @@ public class Http11Connection extends Ht
         body.queue(bb);
     }
 
-    
-    protected void sendRequest(HttpChannel http) 
+
+    protected void sendRequest(HttpChannel http)
             throws IOException {
         if (switchedProtocol != null) {
             switchedProtocol.sendRequest(http);
@@ -779,13 +779,13 @@ public class Http11Connection extends Ht
             }
             CBuffer hostH = http.getRequest().getMimeHeaders().addValue("Host");
             if (target.endsWith(":80")) {
-                hostH.set(target.substring(0, target.length() - 3));                
+                hostH.set(target.substring(0, target.length() - 3));
             } else {
-                hostH.set(target);                
+                hostH.set(target);
             }
         }
-        
-        processContentDelimitation(sendBodyState, 
+
+        processContentDelimitation(sendBodyState,
                 http.getRequest());
 
 
@@ -794,13 +794,13 @@ public class Http11Connection extends Ht
             // TODO: add the others
             sendBodyState.noBody = true;
         }
-        
-        // 1.0: The presence of an entity body in a request is signaled by 
-        // the inclusion of a Content-Length header field in the request 
-        // message headers. HTTP/1.0 requests containing an entity body 
+
+        // 1.0: The presence of an entity body in a request is signaled by
+        // the inclusion of a Content-Length header field in the request
+        // message headers. HTTP/1.0 requests containing an entity body
         // must include a valid Content-Length header field.
         if (http10 && !sendBodyState.isContentDelimited()) {
-            // Will not close connection - just flush and mark the body 
+            // Will not close connection - just flush and mark the body
             // as sent
             sendBodyState.noBody = true;
         }
@@ -810,7 +810,7 @@ public class Http11Connection extends Ht
             http.getRequest().getMimeHeaders().remove(TRANSFERENCODING);
             http.getOut().close();
         } else {
-            long contentLength = 
+            long contentLength =
                 http.getRequest().getContentLength();
             if (contentLength < 0) {
                 http.getRequest().getMimeHeaders().addValue("Transfer-Encoding").
@@ -831,7 +831,7 @@ public class Http11Connection extends Ht
             }
 
 
-            // TODO: add any body and flush. More body can be added later - 
+            // TODO: add any body and flush. More body can be added later -
             // including 'end'.
 
             http.startSending();
@@ -841,8 +841,8 @@ public class Http11Connection extends Ht
         }
 
     }
-    
-    
+
+
     /**
      * Determine if we must drop the connection because of the HTTP status
      * code.  Use the same list of codes as Apache/httpd.
@@ -857,8 +857,8 @@ public class Http11Connection extends Ht
         status == 503 /* SC_SERVICE_UNAVAILABLE */ ||
         status == 501 /* SC_NOT_IMPLEMENTED */;
     }
-    
-    protected void sendResponseHeaders(HttpChannel http) 
+
+    protected void sendResponseHeaders(HttpChannel http)
             throws IOException {
         if (switchedProtocol != null) {
             switchedProtocol.sendResponseHeaders(http);
@@ -872,10 +872,10 @@ public class Http11Connection extends Ht
         IOBuffer sendBody = http.sendBody;
         HttpResponse res = http.getResponse();
         if (res.isCommitted()) {
-            return; 
+            return;
         }
         res.setCommitted(true);
-        
+
         sendBodyState.noBody = !res.hasBody();
 
         if (statusDropsConnection(res.getStatus())) {
@@ -902,7 +902,7 @@ public class Http11Connection extends Ht
             int cl = res.getContentLength();
 
             if (http10) {
-                if (cl < 0 && !sendBodyState.noBody && 
+                if (cl < 0 && !sendBodyState.noBody &&
                         sendBody.isAppendClosed()) {
                     // We can generate content-lenght
                     cl = sendBody.available();
@@ -910,8 +910,8 @@ public class Http11Connection extends Ht
                 }
                 if (cl < 0 && !sendBodyState.noBody) {
                     closeStreamOnEnd("HTTP/1.0 without content length");
-                } else { 
-                    headers.setValue(CONNECTION).set(KEEPALIVE_S);                
+                } else {
+                    headers.setValue(CONNECTION).set(KEEPALIVE_S);
                 }
             } else { // http11
                 if (!sendBodyState.noBody) {
@@ -922,40 +922,40 @@ public class Http11Connection extends Ht
             }
         } else {
             headers.setValue(CONNECTION).set(CLOSE);
-            // since we close the connection - don't bother with 
+            // since we close the connection - don't bother with
             // transfer encoding
             headers.remove(TRANSFERENCODING);
         }
-        
+
         // Update our internal state based on headers we just set.
         processContentDelimitation(sendBodyState, res);
         updateCloseOnEnd(sendBodyState, http, sendBody);
-                
-    
+
+
         if (http.debug) {
             http.trace("Send response headers " + net);
         }
         if (net != null) {
             serialize(res, net.getOut());
         }
-        
+
         if (http.outMessage.state == HttpMessage.State.HEAD) {
             http.outMessage.state = HttpMessage.State.BODY_DATA;
         }
-        
+
         if (isDone(sendBodyState, sendBody)) {
             http.getOut().close();
         }
 
         if (net != null) {
             net.startSending();
-        }        
+        }
     }
 
     private void abort(String t) throws IOException {
         abort(activeHttp, t);
     }
-    
+
     private void updateCloseOnEnd(BodyState bodys, HttpChannel http, IOBuffer body) {
         if (!bodys.isContentDelimited() && !bodys.noBody) {
             closeStreamOnEnd("not content delimited");
@@ -992,7 +992,7 @@ public class Http11Connection extends Ht
             closeStreamOnEnd("http 0.9");
             return;
         }
-        
+
         // TODO: also need to remove headers matching connection
         // ( like 'upgrade')
 
@@ -1010,7 +1010,7 @@ public class Http11Connection extends Ht
             }
             // we have connection: keepalive, good
         } else {
-            // no connection header - for 1.1 default is keepAlive, 
+            // no connection header - for 1.1 default is keepAlive,
             // for 10 it's close
             if (http10) {
                 closeStreamOnEnd("http1.0 no connection header");
@@ -1026,7 +1026,7 @@ public class Http11Connection extends Ht
         }
 
     }
-    
+
     @Override
     public void startSending(HttpChannel http) throws IOException {
         if (switchedProtocol != null) {
@@ -1047,7 +1047,7 @@ public class Http11Connection extends Ht
         }
 
     }
-    
+
     protected void outClosed(HttpChannel http) throws IOException {
         if (switchedProtocol != null) {
             switchedProtocol.outClosed(http);
@@ -1055,14 +1055,14 @@ public class Http11Connection extends Ht
         }
         // TODO: move it ?
         if (sendBodyState.isContentDelimited() && !http.error) {
-            if (!sendBodyState.chunked && 
+            if (!sendBodyState.chunked &&
                     sendBodyState.remaining - http.getOut().available() > 0) {
                 http.abort("CLOSE CALLED WITHOUT FULL LEN");
             }
         }
-        
+
     }
-    
+
     @Override
     public void handleFlushed(IOChannel net) throws IOException {
         if (switchedProtocol != null) {
@@ -1080,23 +1080,23 @@ public class Http11Connection extends Ht
 
 
     private void flushToNext(IOBuffer body, IOBuffer out) throws IOException {
-        
+
         synchronized (this) {
-            // TODO: better head support 
+            // TODO: better head support
             if (sendBodyState.noBody) {
                 for (int i = 0; i < body.getBufferCount(); i++) {
                     Object bc = body.peekBucket(i);
                     if (bc instanceof BBucket) {
                         ((BBucket) bc).release();
                     }
-                }                    
+                }
                 body.clear();
                 return;
             }
-            
+
             // TODO: only send < remainingWrite, if buffer
             // keeps changing after startWrite() is called (shouldn't)
-            
+
             if (sendBodyState.chunked) {
                 sendChunked(sendBodyState, body, out);
             } else if (sendBodyState.contentLength >= 0) {
@@ -1107,7 +1107,7 @@ public class Http11Connection extends Ht
             }
         }
     }
-    
+
     private void sendCloseDelimited(IOBuffer body, IOBuffer out) throws IOException {
         // Close delimitation
         while (true) {
@@ -1121,8 +1121,8 @@ public class Http11Connection extends Ht
             out.close(); // no content-delimitation
         }
     }
-    
-    /** 
+
+    /**
      * Convert the request to bytes, ready to send.
      */
     public static void serialize(HttpRequest req, IOBuffer rawSendBuffers2) throws IOException {
@@ -1139,17 +1139,17 @@ public class Http11Connection extends Ht
         rawSendBuffers2.append(BBuffer.SP);
         rawSendBuffers2.append(req.protocol());
         rawSendBuffers2.append(BBuffer.CRLF_BYTES);
-        
+
         serializeHeaders(req.getMimeHeaders(), rawSendBuffers2);
     }
 
-    /** 
+    /**
      * Convert the response to bytes, ready to send.
      */
     public static void serialize(HttpResponse res, IOBuffer rawSendBuffers2) throws IOException {
-        
+
         rawSendBuffers2.append(res.protocol()).append(' ');
-        String status = Integer.toString(res.getStatus());   
+        String status = Integer.toString(res.getStatus());
         rawSendBuffers2.append(status).append(' ');
         if (res.getMessageBuffer().length() > 0) {
             rawSendBuffers2.append(res.getMessage());
@@ -1176,7 +1176,7 @@ public class Http11Connection extends Ht
         }
         rawSendBuffers2.append(BBuffer.CRLF_BYTES);
     }
-    
+
 
     private boolean sendContentLen(BodyState bodys, IOBuffer body, IOBuffer out) throws IOException {
         while (true) {
@@ -1194,7 +1194,7 @@ public class Http11Connection extends Ht
                 log.severe("write more than Content-Length");
                 len = (int) bodys.remaining;
                 // data between position and limit
-                bucket = body.popLen((int) bodys.remaining); 
+                bucket = body.popLen((int) bodys.remaining);
                 out.queue(bucket);
                 while (bucket != null) {
                     bucket = body.popFirst();
@@ -1202,7 +1202,7 @@ public class Http11Connection extends Ht
                         bucket.release();
                     }
                 }
-                
+
                 // forced close
                 //close();
                 bodys.remaining = 0;
@@ -1219,12 +1219,12 @@ public class Http11Connection extends Ht
         }
         return false;
     }
-    
+
     private boolean sendChunked(BodyState bodys, IOBuffer body, IOBuffer out) throws IOException {
         int len = body.available();
 
         if (len > 0) {
-            ByteBuffer sendChunkBuffer = chunk.prepareChunkHeader(len); 
+            ByteBuffer sendChunkBuffer = chunk.prepareChunkHeader(len);
             bodys.remaining = len;
             out.queue(sendChunkBuffer);
             while (bodys.remaining > 0) {
@@ -1257,17 +1257,17 @@ public class Http11Connection extends Ht
 
     static class ChunkState {
         static byte[] END_CHUNK_BYTES = {
-            (byte) '\r', (byte) '\n', 
-            (byte) '0', 
-            (byte) '\r', (byte) '\n', 
+            (byte) '\r', (byte) '\n',
+            (byte) '0',
+            (byte) '\r', (byte) '\n',
             (byte) '\r', (byte) '\n'};
-            
+
 
         int partialChunkLen;
         boolean readDigit = false;
         boolean trailer = false;
         protected boolean needChunkCrlf = false;
-        
+
         // Buffer used for chunk length conversion.
         protected byte[] sendChunkLength = new byte[10];
 
@@ -1276,9 +1276,9 @@ public class Http11Connection extends Ht
 
         public ChunkState() {
             sendChunkLength[8] = (byte) '\r';
-            sendChunkLength[9] = (byte) '\n';            
+            sendChunkLength[9] = (byte) '\n';
         }
-        
+
         void recycle() {
             partialChunkLen = 0;
             readDigit = false;
@@ -1286,13 +1286,13 @@ public class Http11Connection extends Ht
             needChunkCrlf = false;
             endSendBuffer.recycle();
         }
-        
+
         /**
          * Parse the header of a chunk.
-         * A chunk header can look like 
+         * A chunk header can look like
          * A10CRLF
          * F23;chunk-extension to be ignoredCRLF
-         * The letters before CRLF but after the trailer mark, must be valid hex digits, 
+         * The letters before CRLF but after the trailer mark, must be valid hex digits,
          * we should not parse F23IAMGONNAMESSTHISUP34CRLF as a valid header
          * according to spec
          */
@@ -1361,7 +1361,7 @@ public class Http11Connection extends Ht
             readDigit = false;
             return result;
         }
-        
+
 
         ByteBuffer prepareChunkHeader(int current) {
             int pos = 7; // 8, 9 are CRLF
@@ -1384,12 +1384,12 @@ public class Http11Connection extends Ht
         }
 
         public BBuffer endChunk() {
-            if (! needChunkCrlf) { 
-                endSendBuffer.setBytes(END_CHUNK_BYTES, 2, 
+            if (! needChunkCrlf) {
+                endSendBuffer.setBytes(END_CHUNK_BYTES, 2,
                         END_CHUNK_BYTES.length - 2); // CRLF
             } else { // 0
-                endSendBuffer.setBytes(END_CHUNK_BYTES, 0, 
-                        END_CHUNK_BYTES.length);                
+                endSendBuffer.setBytes(END_CHUNK_BYTES, 0,
+                        END_CHUNK_BYTES.length);
             }
             return endSendBuffer;
         }
@@ -1407,7 +1407,7 @@ public class Http11Connection extends Ht
 
         public void recycle() {
             chunked = false;
-            remaining = 0; 
+            remaining = 0;
             contentLength = -1;
             noBody = false;
         }
@@ -1426,12 +1426,12 @@ public class Http11Connection extends Ht
         (keepAlive() ? " KA " : "") +
         (headersReceived ? " HEAD " : "") +
         (bodyReceived ? " BODY " : "")
-        ;  
+        ;
     }
 
     @Override
     public void handleConnected(IOChannel net) throws IOException {
-        HttpChannel httpCh = activeHttp; 
+        HttpChannel httpCh = activeHttp;
 
         if (!net.isOpen()) {
             httpCh.abort(net.lastException());
@@ -1441,8 +1441,8 @@ public class Http11Connection extends Ht
         boolean ssl = httpCh.getRequest().isSecure();
         if (ssl) {
             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;
@@ -1450,9 +1450,9 @@ public class Http11Connection extends Ht
         if (httpConnector.debugHttp) {
             net = DumpChannel.wrap("Http-Client-", net);
         }
-        
+
         setSink(net);
-        
+
         sendRequest(httpCh);
     }
 

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpChannel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpChannel.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpChannel.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpChannel.java Sat Oct 22 21:30:59 2011
@@ -29,13 +29,13 @@ import org.apache.tomcat.lite.io.IOConne
 
 /**
  * HTTP async client and server, based on tomcat NIO/APR connectors
- * 
- * 'Input', 'read', 'Recv' refers to information we get from the remote side - 
+ *
+ * 'Input', 'read', 'Recv' refers to information we get from the remote side -
  * the request body for server-mode or response body for client.
- * 
- * 'Output', 'write', 'Send' is for info we send - the post in client mode 
+ *
+ * 'Output', 'write', 'Send' is for info we send - the post in client mode
  * and the response body for server mode.
- * 
+ *
  * @author Costin Manolache
  */
 public class HttpChannel extends IOChannel {
@@ -47,85 +47,85 @@ public class HttpChannel extends IOChann
     public static final String CONTENT_LENGTH= "Content-Length";
 
     public static final String HTTP_10 = "HTTP/1.0";
-    
+
     public static final String HTTP_11 = "HTTP/1.1";
-    
+
     /**
      * SEMI_COLON.
      */
     public static final byte SEMI_COLON = (byte) ';';
-    
+
     public static final byte QUESTION = (byte) '?';
-    
-    
+
+
     protected static Logger log = Logger.getLogger("HttpChannel");
 
-    
+
     boolean debug = false;
-    
-    // ---- Callbacks and locks 
-    
+
+    // ---- Callbacks and locks
+
     FutureCallbacks<HttpChannel> doneLock = new FutureCallbacks<HttpChannel>();
-    FutureCallbacks<HttpChannel> headersReceivedLock = 
+    FutureCallbacks<HttpChannel> headersReceivedLock =
             new FutureCallbacks<HttpChannel>();
     /**
      * Called when the incoming headers have been received.
      * ( response for client mode, request for server mode )
-     * @throws IOException 
+     * @throws IOException
      */
     protected HttpService httpService;
-    /** 
+    /**
      * Called when:
      *  - body sent
      *  - body received
-     *  - release() called - either service() done or client done with the 
-     *  buffers. 
-     *  
+     *  - release() called - either service() done or client done with the
+     *  buffers.
+     *
      *  After this callback:
      *  - socket closed if closeOnEndSend, or put in keep-alive
      *  - AsyncHttp.recycle()
      *  - returned to the pool.
      */
     private RequestCompleted doneAllCallback;
-    protected boolean sendReceiveDone = false; 
-    
-    // Will be signalled (open) when the buffer is empty. 
+    protected boolean sendReceiveDone = false;
+
+    // Will be signalled (open) when the buffer is empty.
     FutureCallbacks<IOChannel> flushLock = new FutureCallbacks<IOChannel>();
-    
+
     FutureCallbacks<HttpChannel> doneFuture;
     boolean doneCallbackCalled = false;
 
 
-    // ---------- 
-    
+    // ----------
+
     // Set if Exect: 100-continue was set on reqest.
     // If this is the case - body won't be sent until
     // server responds ( client ) and server will only
-    // read body after ack() - or skip to next request 
+    // read body after ack() - or skip to next request
     // without swallowing the body.
     protected boolean expectation = false;
-    
+
     /** Ready for recycle, if send/receive are done */
     protected boolean release = false;
-    
-    // ----------- 
-    
+
+    // -----------
+
     protected boolean headersDone = false;
     protected boolean error = false;
     protected boolean abortDone = false;
-    
-    
+
+
     protected int ser; // id - for jmx registration and logs
     protected int channelId;
 
-    /** 
+    /**
      * Null after endSendReceive and before sending the request
      */
     HttpConnection conn;
 
     HttpConnector httpConnector;
 
-    // Different ways to point to request response (server/client) 
+    // Different ways to point to request response (server/client)
     HttpRequest httpReq;
     HttpResponse httpRes;
     HttpMessage inMessage;
@@ -141,16 +141,16 @@ public class HttpChannel extends IOChann
             }
             super.close();
             outClosed();
-        }        
+        }
     };
-    
 
-    // Server side only 
+
+    // Server side only
     protected String serverHeader = "TomcatLite";
-    
-    long ioTimeout = 30 * 60000; // 30 min seems high enough 
 
-        
+    long ioTimeout = 30 * 60000; // 30 min seems high enough
+
+
     public HttpChannel() {
         ser = serCnt.incrementAndGet();
         httpReq = new HttpRequest(this);
@@ -158,19 +158,19 @@ public class HttpChannel extends IOChann
         init();
         serverMode(false);
     }
-    
-    /** 
-     * Close the connection, return to pool. Called if a 
+
+    /**
+     * Close the connection, return to pool. Called if a
      * framing error happens, or if we want to force the connection
      * to close, without waiting for all data to be sent/received.
-     * @param t 
-     * 
+     * @param t
+     *
      * @throws IOException
      */
     public void abort(Throwable t) {
         abort(t.toString());
     }
-    
+
     public void abort(String t)  {
         synchronized (this) {
             if (abortDone) {
@@ -193,7 +193,7 @@ public class HttpChannel extends IOChann
             log.severe("Exception in abort " + ex);
         }
     }
-    
+
     /**
      * If release was called - throw exception, you shouldn't use
      * the object again.
@@ -202,9 +202,9 @@ public class HttpChannel extends IOChann
     private void checkRelease() throws IOException {
         if (release && sendReceiveDone) {
             throw new IOException("Object released");
-        }        
+        }
     }
-    
+
     public IOChannel getSink() {
         if (conn == null) {
             return null;
@@ -212,15 +212,15 @@ public class HttpChannel extends IOChann
         return conn.getSink();
     }
 
-    
+
     /**
      * Called when the request is done. Need to send remaining byte.
-     * 
+     *
      */
     public void complete() throws IOException {
         checkRelease();
         if (!getOut().isAppendClosed()) {
-            getOut().close();            
+            getOut().close();
         }
         if (!getIn().isAppendClosed()) {
             getIn().close();
@@ -228,7 +228,7 @@ public class HttpChannel extends IOChann
 
         startSending();
    }
-    
+
     public int doRead(BBuffer chunk)
             throws IOException {
         checkRelease();
@@ -243,13 +243,13 @@ public class HttpChannel extends IOChann
             } else {
                 System.err.println("Spurious waitData signal, no data");
             }
-        } 
+        }
         chunk.append(next.array(), next.position(), next.remaining());
         int read =  next.remaining();
         next.release();
         return read;
     }
-    
+
     public HttpConnector getConnector() {
         return httpConnector;
     }
@@ -257,9 +257,9 @@ public class HttpChannel extends IOChann
     public boolean getError() {
         return error;
     }
-    
-    // ---------------- Writting ------------------------------- 
-    
+
+    // ---------------- Writting -------------------------------
+
     public String getId() {
         return Integer.toString(ser);
     }
@@ -267,8 +267,8 @@ public class HttpChannel extends IOChann
     public IOBuffer getIn() {
         return receiveBody;
     }
-    
-    
+
+
     public long getIOTimeout() {
         return ioTimeout;
     }
@@ -280,8 +280,8 @@ public class HttpChannel extends IOChann
         }
         return conn.getSink();
     }
-    
-    
+
+
     public IOBuffer getOut() {
         return sendBody;
     }
@@ -289,23 +289,23 @@ public class HttpChannel extends IOChann
     public HttpRequest getRequest() {
         return httpReq;
     }
-    
-    
+
+
     public HttpResponse getResponse() {
         return httpRes;
     }
-    
-      
+
+
     public String getState() {
         return
-            conn + 
-            "RCV=[" + inMessage.state.toString() + " " + 
-            receiveBody.toString()  
-            + "] SND=[" + outMessage.state.toString() 
+            conn +
+            "RCV=[" + inMessage.state.toString() + " " +
+            receiveBody.toString()
+            + "] SND=[" + outMessage.state.toString()
             + " " + sendBody.toString() + "]";
     }
 
-    
+
     public String getStatus() {
         return getResponse().getStatus() + " " + getResponse().getMessage();
     }
@@ -313,16 +313,16 @@ public class HttpChannel extends IOChann
 
     public String getTarget() {
         if (target == null) {
-            return ":0"; // server mode ? 
+            return ":0"; // server mode ?
         }
         return target.toString();
     }
 
 
     /**
-     * Called from IO thread, after the request body 
+     * Called from IO thread, after the request body
      * is completed ( or if there is no req body )
-     * @throws IOException 
+     * @throws IOException
      */
     protected void handleEndReceive() throws IOException {
         if (inMessage.state == HttpMessage.State.DONE) {
@@ -340,54 +340,54 @@ public class HttpChannel extends IOChann
     /*
      * Called when sending, receiving and processing is done.
      * Can be called:
-     *  - from IO thread, if this is a result of a read/write event that 
+     *  - from IO thread, if this is a result of a read/write event that
      *  finished the send/recev pair.
      *  - from an arbitrary thread, if read was complete and the last write
      *  was a success and done in that thread ( write is not bound to IO thr)
-     * 
+     *
      */
     protected void handleEndSendReceive() throws IOException {
         // make sure the callback was called ( needed for abort )
         handleHeadersReceived(inMessage);
-        
+
         this.doneLock.signal(this);
         synchronized (this) {
             if (doneCallbackCalled) {
                 return;
             }
-            if (outMessage.state != HttpMessage.State.DONE || 
+            if (outMessage.state != HttpMessage.State.DONE ||
                     inMessage.state != HttpMessage.State.DONE) {
                 return;
             }
             doneCallbackCalled = true;
         }
-        
+
         getIn().close();
-        
+
         if (doneAllCallback != null) {
             doneAllCallback.handle(this, error ? new Throwable() : null);
         }
-        
+
         if (conn != null) {
             conn.endSendReceive(this);
         }
-        
+
         conn = null;
-        
+
         if (debug) {
-            trace("END_SEND_RECEIVE" 
+            trace("END_SEND_RECEIVE"
                     + (release ? " REL" : ""));
         }
-            
+
         synchronized(this) {
             sendReceiveDone = true;
             maybeRelease();
         }
     }
-    
-    /** 
+
+    /**
      * called from IO thread OR servlet thread when last block has been sent.
-     * If not using the socket ( net.getOut().flushCallback ) - this must 
+     * If not using the socket ( net.getOut().flushCallback ) - this must
      * be called explicitely after flushing the body.
      */
     void handleEndSent() throws IOException {
@@ -401,14 +401,14 @@ public class HttpChannel extends IOChann
         outMessage.state = HttpMessage.State.DONE;
 
         getOut().close();
-        
+
         // Make sure the send/receive callback is called once
         if (debug) {
             trace("END_SEND");
         }
         handleEndSendReceive();
     }
-    
+
     // ----- End Selector thread callbacks ----
     public void handleError(String type) {
         System.err.println("Error " + type + " " + outMessage.state);
@@ -427,49 +427,49 @@ public class HttpChannel extends IOChann
                 }
             }
         }
-    }   
+    }
 
 
     private void init() {
         headersDone = false;
         sendReceiveDone = false;
-        
+
         receiveBody.recycle();
         sendBody.recycle();
         expectation = false;
-        
+
         error = false;
         abortDone = false;
-       
-        
+
+
         getRequest().recycle();
         getResponse().recycle();
         target = null;
-        
+
         doneLock.recycle();
         headersReceivedLock.recycle();
         flushLock.recycle();
-        
+
         doneCallbackCalled = false;
         // Will be set again after pool
         setHttpService(null);
         doneAllCallback = null;
         release = false;
     }
-    
+
     public boolean isDone() {
         return outMessage.state == HttpMessage.State.DONE && inMessage.state == HttpMessage.State.DONE;
     }
-    
+
     /**
      * Called when all done:
      *  - service finished ( endService was called )
      *  - output written
      *  - input read
-     *  
-     * or by abort(). 
-     *  
-     * @throws IOException 
+     *
+     * or by abort().
+     *
+     * @throws IOException
      */
     private void maybeRelease() throws IOException {
         synchronized (this) {
@@ -488,20 +488,20 @@ public class HttpChannel extends IOChann
 
 
     /*
-    The field-content does not include any leading or trailing LWS: 
-    linear white space occurring before the first non-whitespace 
+    The field-content does not include any leading or trailing LWS:
+    linear white space occurring before the first non-whitespace
     character of the field-value or after the last non-whitespace
-     character of the field-value. Such leading or trailing LWS MAY 
-     be removed without changing the semantics of the field value. 
-     Any LWS that occurs between field-content MAY be replaced with 
-     a single Http11Parser.SP before interpreting the field value or forwarding 
+     character of the field-value. Such leading or trailing LWS MAY
+     be removed without changing the semantics of the field value.
+     Any LWS that occurs between field-content MAY be replaced with
+     a single Http11Parser.SP before interpreting the field value or forwarding
      the message downstream.
      */
     int normalizeHeader(BBuffer value) {
         byte[] buf = value.array();
         int cstart = value.position();
         int end = value.limit();
-        
+
         int realPos = cstart;
         int lastChar = cstart;
         byte chr = 0;
@@ -527,32 +527,32 @@ public class HttpChannel extends IOChann
             }
         }
         realPos = lastChar;
-        
+
         // so buffer is clean
         for (int i = realPos; i < end; i++) {
             buf[i] = BBuffer.SP;
         }
         value.setEnd(realPos);
         return realPos;
-    }  
-    
-    
+    }
+
+
     protected void recycle() {
-        if (debug) { 
+        if (debug) {
             trace("RECYCLE");
         }
         init();
     }
 
-    /** 
-     * Finalize sending and receiving. 
+    /**
+     * Finalize sending and receiving.
      * Indicates client is no longer interested, some IO may still be in flight.
      * If in a POST and you're not interested in the body - it may be
      * better to call abort().
-     *  
+     *
      * MUST be called to allow connection reuse and pooling.
-     * 
-     * @throws IOException 
+     *
+     * @throws IOException
      */
     public void release() throws IOException {
         synchronized(this) {
@@ -569,22 +569,22 @@ public class HttpChannel extends IOChann
     public void send() throws IOException {
         checkRelease();
         if (httpReq == inMessage) {
-            conn.sendResponseHeaders(this);   
+            conn.sendResponseHeaders(this);
         } else {
             if (getRequest().isCommitted()) {
                 return;
             }
             getRequest().setCommitted(true);
-            
+
             outMessage.state = HttpMessage.State.HEAD;
-            
+
             getConnector().connectAndSend(this);
         }
     }
-    
+
     /** Called when the outgoing stream is closed:
      * - by an explicit call to close()
-     * - when all content has been sent. 
+     * - when all content has been sent.
      */
     protected void outClosed() throws IOException {
         if (conn != null) {
@@ -608,8 +608,8 @@ public class HttpChannel extends IOChann
         }
         return this;
     }
-    
-    public void setCompletedCallback(RequestCompleted doneAllCallback) 
+
+    public void setCompletedCallback(RequestCompleted doneAllCallback)
             throws IOException {
         this.doneAllCallback = doneAllCallback;
         synchronized (this) {
@@ -638,18 +638,18 @@ public class HttpChannel extends IOChann
         ioTimeout = timeout;
     }
 
-    
+
     public void setTarget(String host) {
         this.target = host;
     }
-    
+
     public void startSending() throws IOException {
         checkRelease();
         if (conn != null) {
             conn.startSending(this);
         }
     }
-    
+
     public String toString() {
         StringBuffer sb = new StringBuffer();
         sb.append("id=").append(ser)
@@ -657,14 +657,14 @@ public class HttpChannel extends IOChann
             .append(")");
         return sb.toString();
     }
-    
+
 
     void trace(String msg) {
         if(debug) {
             log.info(this.toString() + " " + msg + " done=" + doneCallbackCalled);
         }
     }
- 
+
     @Override
     public void waitFlush(long timeMs) throws IOException {
         if (getOut().getBufferCount() == 0) {
@@ -672,19 +672,19 @@ public class HttpChannel extends IOChann
         }
         flushLock.waitSignal(timeMs);
     }
- 
+
     public HttpChannel setConnection(HttpConnection conn) {
         this.conn = conn;
         return this;
     }
-    
+
     /**
      * Normalize URI.
      * <p>
      * This method normalizes "\", "//", "/./" and "/../". This method will
      * return false when trying to go above the root, or if the URI contains
      * a null byte.
-     * 
+     *
      * @param uriMB URI to be normalized, will be modified
      */
     public static boolean normalize(BBuffer uriBC) {
@@ -701,7 +701,7 @@ public class HttpChannel extends IOChann
             // TODO: http://.... URLs
             return true;
         }
-        
+
         int pos = 0;
         int index = 0;
 
@@ -733,8 +733,8 @@ public class HttpChannel extends IOChann
         // Note: It is possible to extend the URI by 1 without any side effect
         // as the next character is a non-significant WS.
         if (((end - start) >= 2) && (b[end - 1] == (byte) '.')) {
-            if ((b[end - 2] == (byte) '/') 
-                    || ((b[end - 2] == (byte) '.') 
+            if ((b[end - 2] == (byte) '/')
+                    || ((b[end - 2] == (byte) '.')
                             && (b[end - 3] == (byte) '/'))) {
                 b[end] = (byte) '/';
                 end++;
@@ -750,7 +750,7 @@ public class HttpChannel extends IOChann
             index = uriBC.indexOf("/./", 0, 3, index);
             if (index < 0)
                 break;
-            copyBytes(b, start + index, start + index + 2, 
+            copyBytes(b, start + index, start + index + 2,
                     end - start - index - 2);
             end = end - 2;
             uriBC.setEnd(end);
@@ -786,7 +786,7 @@ public class HttpChannel extends IOChann
     }
 
     /**
-     * Copy an array of bytes to a different position. Used during 
+     * Copy an array of bytes to a different position. Used during
      * normalization.
      */
     private static void copyBytes(byte[] b, int dest, int src, int len) {
@@ -794,26 +794,26 @@ public class HttpChannel extends IOChann
             b[pos + dest] = b[pos + src];
         }
     }
-    
-    
+
+
     /**
-     * This method will be called when the http headers have been received - 
-     * the body may or may not be available. 
-     * 
-     * In server mode this is equivalent with a servlet request. 
+     * This method will be called when the http headers have been received -
+     * the body may or may not be available.
+     *
+     * In server mode this is equivalent with a servlet request.
      * This is also called for http client, when the response headers
-     * are received. 
-     *  
+     * are received.
+     *
      * TODO: rename it to HttMessageReceived or something similar.
      */
     public static interface HttpService {
         void service(HttpRequest httpReq, HttpResponse httpRes) throws IOException;
     }
-    
-    /** 
+
+    /**
      * Called when both request and response bodies have been sent/
      * received. After this call the HttpChannel will be disconnected
-     * from the http connection, which can be used for other requests. 
+     * from the http connection, which can be used for other requests.
      */
     public static interface RequestCompleted {
         void handle(HttpChannel data, Object extraData) throws IOException;
@@ -825,6 +825,6 @@ public class HttpChannel extends IOChann
             getConnector().getDispatcher().runService(HttpChannel.this);
         }
     };
-    
+
 
 }
\ No newline at end of file

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpClient.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpClient.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpClient.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpClient.java Sat Oct 22 21:30:59 2011
@@ -6,13 +6,13 @@ import org.apache.tomcat.lite.io.SocketC
 import org.apache.tomcat.lite.io.SslProvider;
 import org.apache.tomcat.lite.io.jsse.JsseSslProvider;
 
-/** 
+/**
  * Entry point for http client code.
  *
- * ( initial version after removing 'integration', will add settings, 
+ * ( initial version after removing 'integration', will add settings,
  * defaults, helpers )
  */
-public class HttpClient { 
+public class HttpClient {
     static SslProvider sslConC = new JsseSslProvider();
 
     public synchronized static HttpConnector newClient() {

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnectionPool.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnectionPool.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnectionPool.java Sat Oct 22 21:30:59 2011
@@ -20,52 +20,52 @@ import org.apache.tomcat.lite.io.IOConne
 
 /**
  * - Holds references to all active and kept-alive connections.
- * - makes decisions on accepting more connections, closing old 
+ * - makes decisions on accepting more connections, closing old
  * connections, etc
- * 
+ *
  */
 public class HttpConnectionPool {
-    // TODO: add timeouts, limits per host/total, expire old entries 
-   
+    // TODO: add timeouts, limits per host/total, expire old entries
+
     public static interface HttpConnectionPoolEvents {
         public void newTarget(RemoteServer host);
 
         public void targetRemoved(RemoteServer host);
-        
+
         public void newConnection(RemoteServer host, HttpConnection con);
         public void closedConnection(RemoteServer host, HttpConnection con);
     }
-    
-    /** 
+
+    /**
      * Connections for one remote host.
      * This should't be restricted by IP:port or even hostname,
-     * for example if a server has multiple IPs or LB replicas - any would work.   
+     * for example if a server has multiple IPs or LB replicas - any would work.
      */
     public static class RemoteServer {
         // all access sync on RemoteServer
         private SpdyConnection spdy;
-        
+
         // all access sync on RemoteServer
-        private ArrayList<Http11Connection> connections 
+        private ArrayList<Http11Connection> connections
             = new ArrayList<Http11Connection>();
-        
+
         Queue<HttpChannel> pending = new LinkedList<HttpChannel>();
-        
-        
+
+
         // TODO: setter, default from connector
         private int maxConnections = 20;
-        
+
         AtomicInteger activeRequests = new AtomicInteger();
         AtomicInteger totalRequests = new AtomicInteger();
         private volatile long lastActivity;
 
         public String target;
-        
-        public synchronized List<HttpConnector.HttpConnection> getConnections() 
+
+        public synchronized List<HttpConnector.HttpConnection> getConnections()
         {
             return new ArrayList<HttpConnection>(connections);
         }
-        
+
         public synchronized Collection<HttpChannel> getActives() {
             ArrayList<HttpChannel> actives = new ArrayList();
             for (Http11Connection con: connections) {
@@ -76,7 +76,7 @@ public class HttpConnectionPool {
             if (spdy != null) {
                 actives.addAll(spdy.getActives());
             }
-            
+
             return actives;
         }
 
@@ -86,14 +86,14 @@ public class HttpConnectionPool {
     }
 
     private HttpConnectionPoolEvents poolEvents;
-    
+
     private static Logger log = Logger.getLogger("HttpConnector");
 
-    // visible for debugging - will be made private, with accessor 
+    // visible for debugging - will be made private, with accessor
     /**
      * Map from client names to socket pools.
      */
-    public Map<CharSequence, HttpConnectionPool.RemoteServer> hosts = new HashMap<CharSequence, 
+    public Map<CharSequence, HttpConnectionPool.RemoteServer> hosts = new HashMap<CharSequence,
         HttpConnectionPool.RemoteServer>();
 
     // Statistics
@@ -103,12 +103,12 @@ public class HttpConnectionPool {
     public AtomicInteger hits = new AtomicInteger();
     public AtomicInteger misses = new AtomicInteger();
     public AtomicInteger queued = new AtomicInteger();
-    
+
     public AtomicInteger activeRequests = new AtomicInteger();
-    
+
     private static boolean debug = false;
     HttpConnector httpConnector;
-    
+
     public HttpConnectionPool(HttpConnector httpConnector) {
         this.httpConnector = httpConnector;
     }
@@ -128,7 +128,7 @@ public class HttpConnectionPool {
     public Set<CharSequence> getKeepAliveTargets() {
         return hosts.keySet();
     }
-    
+
     public List<RemoteServer> getServers() {
         return new ArrayList<RemoteServer>(hosts.values());
     }
@@ -136,7 +136,7 @@ public class HttpConnectionPool {
     public void setEvents(HttpConnectionPoolEvents events) {
         this.poolEvents = events;
     }
-    /** 
+    /**
      * Stop all cached connections.
      */
     public void clear() throws IOException {
@@ -161,16 +161,16 @@ public class HttpConnectionPool {
                         }
                     }
                     if (hostActive != rs.activeRequests.get()) {
-                        log.warning("Active missmatch " + rs.target + " " + 
-                                hostActive + " " 
+                        log.warning("Active missmatch " + rs.target + " " +
+                                hostActive + " "
                                 + rs.activeRequests.get());
-                        rs.activeRequests.set(hostActive);                        
+                        rs.activeRequests.set(hostActive);
                     }
                     active += hostActive;
                 }
             }
             if (active != this.activeRequests.get()) {
-                log.warning("Active missmatch " + active + " " 
+                log.warning("Active missmatch " + active + " "
                         + activeRequests.get());
                 activeRequests.set(active);
             }
@@ -179,28 +179,28 @@ public class HttpConnectionPool {
 
     /**
      * Stop all active and cached connections
-     * @throws IOException 
+     * @throws IOException
      */
     public void abort() throws IOException {
         // TODO
         clear();
         hosts.clear();
     }
-    
-    /** 
+
+    /**
      * @param key host:port, or some other key if multiple hosts:ips
-     * are connected to equivalent servers ( LB ) 
-     * @param httpCh 
-     * @throws IOException 
+     * are connected to equivalent servers ( LB )
+     * @param httpCh
+     * @throws IOException
      */
-    public void send(HttpChannel httpCh) 
+    public void send(HttpChannel httpCh)
             throws IOException {
         String target = httpCh.getTarget();
         HttpConnection con = null;
-        // TODO: check ssl on connection - now if a second request 
+        // TODO: check ssl on connection - now if a second request
         // is received on a ssl connection - we just send it
         boolean ssl = httpCh.getRequest().isSecure();
-        
+
         HttpConnectionPool.RemoteServer remoteServer = null;
         synchronized (hosts) {
             remoteServer = hosts.get(target);
@@ -210,20 +210,20 @@ public class HttpConnectionPool {
                 hosts.put(target, remoteServer);
             }
         }
-        
+
         // TODO: remove old servers and connections
 
         // Temp magic - until a better negotiation is defined
-        boolean forceSpdy = "SPDY/1.0".equals(httpCh.getRequest().getProtocol()); 
+        boolean forceSpdy = "SPDY/1.0".equals(httpCh.getRequest().getProtocol());
         if (forceSpdy) {
             // switch back the protocol
             httpCh.getRequest().setProtocol("HTTP/1.1");
         }
-        
+
         activeRequests.incrementAndGet();
         remoteServer.activeRequests.incrementAndGet();
-        
-        // if we already have a spdy connection or explicitely 
+
+        // if we already have a spdy connection or explicitely
         // requested.
         if (forceSpdy || remoteServer.spdy != null) {
             synchronized (remoteServer) {
@@ -233,8 +233,8 @@ public class HttpConnectionPool {
                 }
                 con = remoteServer.spdy;
             }
-            
-            // Will be queued - multiple threads may try to send 
+
+            // Will be queued - multiple threads may try to send
             // at the same time, and we need to queue anyways.
             con.sendRequest(httpCh);
         } else {
@@ -244,7 +244,7 @@ public class HttpConnectionPool {
                     hcon = (Http11Connection) remoteServer.connections.get(i);
                     if (hcon != null && hcon.activeHttp == null) {
                         hcon.beforeRequest(); // recycle
-                        
+
                         hcon.activeHttp = httpCh;
                         con = hcon;
                         break;
@@ -271,7 +271,7 @@ public class HttpConnectionPool {
 
             // we got a connection - make sure we're connected
             http11ConnectOrSend(httpCh, target, con, ssl);
-        }        
+        }
     }
 
     private void http11ConnectOrSend(HttpChannel httpCh, String target,
@@ -289,12 +289,12 @@ public class HttpConnectionPool {
             if (debug) {
                 log.info("HTTP_CONNECT: Start connection " + target + " " + this);
             }
-            httpConnect(httpCh, target, ssl, 
+            httpConnect(httpCh, target, ssl,
                     (Http11Connection) con);
         }
     }
 
-    void httpConnect(HttpChannel httpCh, String target, 
+    void httpConnect(HttpChannel httpCh, String target,
             boolean ssl, IOConnector.ConnectedCallback cb)
             throws IOException {
         if (debug) {
@@ -311,7 +311,7 @@ public class HttpConnectionPool {
                 cb);
     }
 
-    public void afterRequest(HttpChannel http, HttpConnection con, 
+    public void afterRequest(HttpChannel http, HttpConnection con,
             boolean keepAlive)
                 throws IOException {
         activeRequests.decrementAndGet();
@@ -325,16 +325,16 @@ public class HttpConnectionPool {
             afterClientRequest(con);
         }
     }
-    
-    private void afterClientRequest(HttpConnection con) 
+
+    private void afterClientRequest(HttpConnection con)
             throws IOException {
         RemoteServer remoteServer = con.remoteHost;
         HttpChannel req = null;
-        
+
         // If we have pending requests ( because too many active limit ), pick
-        // one and send it. 
+        // one and send it.
         synchronized (remoteServer) {
-            // If closed - we can remove the object - or 
+            // If closed - we can remove the object - or
             // let a background thread do it, in case it's needed
             // again.
             if (remoteServer.pending.size() == 0) {
@@ -347,14 +347,14 @@ public class HttpConnectionPool {
                 log.info("After request: send pending " + remoteServer.pending.size());
             }
         }
-        
-        http11ConnectOrSend(req, con.getTarget().toString(), 
+
+        http11ConnectOrSend(req, con.getTarget().toString(),
                 con, req.getRequest().isSecure());
     }
 
     RemoteServer serverPool = new RemoteServer();
-    
-    public void afterServerRequest(HttpConnection con, boolean keepAlive) 
+
+    public void afterServerRequest(HttpConnection con, boolean keepAlive)
             throws IOException {
         con.activeHttp = null;
         if (!keepAlive) {
@@ -363,8 +363,8 @@ public class HttpConnectionPool {
                 serverPool.connections.remove(con);
             }
         }
-    }   
-    
+    }
+
     public HttpConnection accepted(IOChannel accepted) {
         Http11Connection con = new Http11Connection(httpConnector);
         con.remoteHost = serverPool;
@@ -374,7 +374,7 @@ public class HttpConnectionPool {
         return con;
     }
 
-    
+
     // Called by handleClosed
     void stopKeepAlive(IOChannel schannel) {
         CharSequence target = schannel.getTarget();
@@ -386,7 +386,7 @@ public class HttpConnectionPool {
             }
         }
         synchronized (remoteServer) {
-            if (remoteServer.connections.remove(schannel)) {      
+            if (remoteServer.connections.remove(schannel)) {
                 waitingSockets.decrementAndGet();
                 if (remoteServer.connections.size() == 0) {
                     hosts.remove(target);

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnector.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnector.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpConnector.java Sat Oct 22 21:30:59 2011
@@ -21,56 +21,56 @@ import org.apache.tomcat.lite.io.IOConne
 
 /**
  * Manages HttpChannels and associated socket pool.
- * 
- * 
+ *
+ *
  * @author Costin Manolache
  */
 public class HttpConnector {
-    
+
     public static interface HttpChannelEvents {
         /** HttpChannel object created. It'll be used many times.
-         * @throws IOException 
+         * @throws IOException
          */
         public void onCreate(HttpChannel ch, HttpConnector con) throws IOException;
-        
-        /** 
+
+        /**
          * HttpChannel object no longer needed, out of pool.
-         * @throws IOException 
+         * @throws IOException
          */
         public void onDestroy(HttpChannel ch, HttpConnector con) throws IOException;
     }
-    
+
     private static Logger log = Logger.getLogger("HttpConnector");
-    
-    /** 
+
+    /**
      * Cache HttpChannel/request/buffers
      */
     private int maxHttpPoolSize = 50;
-    
-    /** 
-     * Max number of connections to keep alive. 
+
+    /**
+     * Max number of connections to keep alive.
      * Each connection holds a header buffer and the socket.
      * ( we could skip the header buffer )
      */
     private int maxSocketPoolSize = 500; // 10000;
-    
+
     private int keepAliveTimeMs = 300000;
-    
+
     private List<HttpChannel> httpChannelPool = new ArrayList<HttpChannel>();
 
     protected IOConnector ioConnector;
-    
+
     // for https connections
     protected SslProvider sslProvider;
-    
+
     boolean debugHttp = false;
     boolean debug = false;
-    
+
     boolean clientKeepAlive = true;
     boolean serverKeepAlive = true;
 
     HttpChannelEvents httpEvents;
-    
+
     public AtomicInteger inUse = new AtomicInteger();
     public AtomicInteger newHttpChannel = new AtomicInteger();
     public AtomicInteger totalHttpChannel = new AtomicInteger();
@@ -79,7 +79,7 @@ public class HttpConnector {
     public AtomicInteger reusedChannels = new AtomicInteger();
 
     public HttpConnectionPool cpool = new HttpConnectionPool(this);
-        
+
     // Host + context mapper.
     Dispatcher dispatcher;
     protected HttpService defaultService;
@@ -88,11 +88,11 @@ public class HttpConnector {
     private Timer timer;
 
     boolean compression = true;
-    
+
     boolean serverSSL = false;
 
     private static Timer defaultTimer = new Timer(true);
-    
+
     public HttpConnector(IOConnector ioConnector) {
         this.ioConnector = ioConnector;
         dispatcher = new Dispatcher();
@@ -108,20 +108,20 @@ public class HttpConnector {
     protected HttpConnector() {
         this(null);
     }
-    
+
     public Dispatcher getDispatcher() {
         return dispatcher;
     }
-    
+
     public HttpConnectionPool getConnectionPool() {
         return cpool;
     }
-    
+
     public HttpConnector withIOConnector(IOConnector selectors) {
         ioConnector = selectors;
         return this;
     }
-    
+
     public void setDebug(boolean b) {
         this.debug = b;
     }
@@ -129,22 +129,22 @@ public class HttpConnector {
     public void setDebugHttp(boolean b) {
         this.debugHttp  = b;
     }
-    
+
     public HttpConnector withSsl(SslProvider ssl) {
         sslProvider = ssl;
         return this;
     }
-    
+
     HttpConnector setServerSsl(boolean b) {
         serverSSL = b;
         return this;
     }
-    
+
     public SslProvider getSslProvider() {
         return sslProvider;
     }
-    
-    /** 
+
+    /**
      * Allow or disable compression for this connector.
      * Compression is enabled by default.
      */
@@ -160,7 +160,7 @@ public class HttpConnector {
     public void setServerKeepAlive(boolean b) {
         this.serverKeepAlive = b;
     }
-    
+
     public boolean isDebug() {
         return debug;
     }
@@ -180,7 +180,7 @@ public class HttpConnector {
     public int getMaxHttpPoolSize() {
         return maxHttpPoolSize;
     }
-    
+
     public void setMaxHttpPoolSize(int maxHttpPoolSize) {
         this.maxHttpPoolSize = maxHttpPoolSize;
     }
@@ -188,12 +188,12 @@ public class HttpConnector {
     public void setOnCreate(HttpChannelEvents callback) {
         httpEvents = callback;
     }
-    
+
     /**
      *  Override to create customized client/server connections.
-     * 
+     *
      * @return
-     * @throws IOException 
+     * @throws IOException
      */
     protected HttpChannel create() throws IOException {
         HttpChannel res = new HttpChannel();
@@ -213,7 +213,7 @@ public class HttpConnector {
         http.setTarget(host + ":" + port);
         return http;
     }
-    
+
     public HttpChannel getServer() {
         try {
             return get(true);
@@ -228,25 +228,25 @@ public class HttpConnector {
         HttpChannel http = get(false);
         http.setTarget(host + ":" + port);
         return http.getRequest();
-        
+
     }
 
     public HttpRequest request(CharSequence urlString) throws IOException {
         return get(urlString).getRequest();
     }
-    
+
     /**
-     * Get an existing AsyncHttp object. Since it uses many buffers and 
-     * objects - it's more efficient to pool it. 
-     * 
+     * Get an existing AsyncHttp object. Since it uses many buffers and
+     * objects - it's more efficient to pool it.
+     *
      * release will return the object to the pool.
-     * @throws IOException 
+     * @throws IOException
      */
     public HttpChannel get(CharSequence urlString) throws IOException {
         URL url = new URL(urlString.toString());
         String host = url.getHost();
         int port = url.getPort();
-        boolean secure = "http".equals(url.getAuthority()); 
+        boolean secure = "http".equals(url.getAuthority());
         if (port == -1) {
             port = secure ? 443: 80;
         }
@@ -258,7 +258,7 @@ public class HttpConnector {
         http.getRequest().requestURI().set(path);
         return http;
     }
-    
+
     protected HttpChannel get(boolean server) throws IOException {
         HttpChannel processor = null;
         synchronized (httpChannelPool) {
@@ -283,11 +283,11 @@ public class HttpConnector {
         if (debug) {
             log.info((reuse ? "REUSE ": "Create ") +
                     (server? " S" : "")
-                    + " id=" + processor.ser + 
+                    + " id=" + processor.ser +
                     " " + processor +
                     " size=" + httpChannelPool.size());
         }
-        
+
         processor.setConnector(this);
         inUse.incrementAndGet();
         return processor;
@@ -298,11 +298,11 @@ public class HttpConnector {
         recycledChannels.incrementAndGet();
         int size = 0;
         boolean pool = false;
-        
+
         http.recycle();
         http.setConnection(null);
         http.setConnector(null);
-        
+
         // No more data - release the object
         synchronized (httpChannelPool) {
             size = httpChannelPool.size();
@@ -313,7 +313,7 @@ public class HttpConnector {
                 pool = true;
             }
         }
-        
+
         if (!pool && httpEvents != null) {
             httpEvents.onDestroy(http, this);
         }
@@ -323,40 +323,40 @@ public class HttpConnector {
                     http + " size=" + size);
         }
     }
-    
-    
+
+
     public IOConnector getIOConnector() {
         return ioConnector;
     }
-    
-    
+
+
     public void setHttpService(HttpService s) {
         defaultService = s;
     }
-    
+
     public void start() throws IOException {
         if (ioConnector != null) {
-            ioConnector.acceptor(new AcceptorCallback(), 
+            ioConnector.acceptor(new AcceptorCallback(),
                     Integer.toString(port), null);
         }
     }
-    
-    /** 
-     * 
-     * TODO: only clean our state and sockets we listen on. 
-     *  
+
+    /**
+     *
+     * TODO: only clean our state and sockets we listen on.
+     *
      */
     public void stop() {
         if (ioConnector != null) {
             ioConnector.stop();
         }
     }
-    
+
     protected void connectAndSend(HttpChannel httpCh) throws IOException {
         cpool.send(httpCh);
 
     }
-    
+
     private class AcceptorCallback implements IOConnector.ConnectedCallback {
         @Override
         public void handleConnected(IOChannel accepted) throws IOException {
@@ -368,10 +368,10 @@ public class HttpConnector {
         // TODO: reuse
         HttpConnection shttp = cpool.accepted(accepted);
         shttp.serverMode = true;
-        
+
         IOChannel head = accepted;
         IOChannel ch;
-        
+
         String id = null;
         if (debugHttp) {
             id = port + "-" + accepted.getFirst().getAttribute(IOChannel.ATT_REMOTE_PORT);
@@ -384,14 +384,14 @@ public class HttpConnector {
             ch = sslProvider.serverChannel(head);
             head.setHead(ch);
             head = ch;
-            
+
             if (debugHttp) {
                 head = DumpChannel.wrap("CLEAR-" + id, head);
             }
         }
-        
+
         shttp.setSink(head);
-        
+
         // Will read any data in the channel, notify data available up
         accepted.handleReceived(accepted);
         return shttp;
@@ -401,10 +401,10 @@ public class HttpConnector {
         this.port = port2;
         return this;
     }
-    
+
     /**
-     * Actual HTTP/1.1 wire protocol. 
-     *  
+     * Actual HTTP/1.1 wire protocol.
+     *
      */
     public static abstract class HttpConnection extends IOChannel
         implements DataReceivedCallback
@@ -414,9 +414,9 @@ public class HttpConnector {
 
         protected BBuffer headRecvBuf = BBuffer.allocate(8192);
         protected CompressFilter compress = new CompressFilter();
-        
+
         protected boolean secure = false;
-        
+
         protected HttpConnectionPool.RemoteServer remoteHost;
         // If set, the connection is in use ( active )
         // null == keep alive. Changes synchronized on remoteHost
@@ -432,9 +432,9 @@ public class HttpConnector {
         protected HttpChannel checkHttpChannel() throws IOException {
             return null;
         }
-        
-        /** 
-         * Called before a new request is sent, on a channel that is 
+
+        /**
+         * Called before a new request is sent, on a channel that is
          * reused.
          */
         public void beforeRequest() {
@@ -449,22 +449,22 @@ public class HttpConnector {
         }
 
 
-        /** 
+        /**
          * Incoming data.
          */
         public abstract void dataReceived(IOBuffer iob) throws IOException;
-        
-        /** 
+
+        /**
          * Framing error, client interrupt, etc.
          */
         public void abort(HttpChannel http, String t) throws IOException {
         }
-        
-        protected void sendRequest(HttpChannel http) 
+
+        protected void sendRequest(HttpChannel http)
             throws IOException {
         }
-        
-        protected void sendResponseHeaders(HttpChannel http) 
+
+        protected void sendResponseHeaders(HttpChannel http)
             throws IOException {
         }
 
@@ -484,31 +484,31 @@ public class HttpConnector {
         @Override
         public void startSending() throws IOException {
         }
-        
+
         /** Called when the outgoing stream is closed:
          * - by an explicit call to close()
-         * - when all content has been sent. 
+         * - when all content has been sent.
          */
         protected void outClosed(HttpChannel http) throws IOException {
         }
 
         /**
-         * Called by HttpChannel when both input and output are fully 
+         * Called by HttpChannel when both input and output are fully
          * sent/received. When this happens the request is no longer associated
-         * with the Connection, and the connection can be re-used. 
-         * 
+         * with the Connection, and the connection can be re-used.
+         *
          * The channel can still be used to access the retrieved data that may
          * still be buffered until HttpChannel.release() is called.
-         * 
+         *
          * This method will be called only once, for both succesful and aborted
-         * requests. 
+         * requests.
          */
         protected abstract void endSendReceive(HttpChannel httpChannel) throws IOException;
 
         public void withExtraBuffer(BBuffer received) {
             return;
         }
-        
+
     }
 
 }



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


Mime
View raw message