You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:31:02 UTC

svn commit: r1187812 [3/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...

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpMessage.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpMessage.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpMessage.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpMessage.java Sat Oct 22 21:30:59 2011
@@ -31,11 +31,11 @@ import org.apache.tomcat.lite.io.UrlEnco
 
 /**
  * Basic Http request or response message.
- * 
+ *
  * Because the HttpChannel can be used for both client and
- * server, and to make proxy and other code simpler - the request 
+ * server, and to make proxy and other code simpler - the request
  * and response are represented by the same class.
- * 
+ *
  * @author Costin Manolache
  */
 public abstract class HttpMessage {
@@ -55,12 +55,12 @@ public abstract class HttpMessage {
         BBuffer proto = BBuffer.wrapper();
 
         BBuffer query = BBuffer.wrapper();
-        
+
         List<BBuffer> headerNames = new ArrayList<BBuffer>();
         List<BBuffer> headerValues  = new ArrayList<BBuffer>();
-        
+
         int headerCount;
-        
+
         public BBuffer status() {
             return head1;
         }
@@ -84,16 +84,16 @@ public abstract class HttpMessage {
         public BBuffer message() {
             return head2;
         }
-        
+
         public int addHeader() {
             if (headerCount >= headerNames.size()) {
                 // make space for the new header.
                 headerNames.add(BBuffer.wrapper());
-                headerValues.add(BBuffer.wrapper());                
+                headerValues.add(BBuffer.wrapper());
             }
             return headerCount++;
         }
-        
+
         public BBuffer getHeaderName(int i) {
             if (i >= headerNames.size()) {
                 return null;
@@ -124,18 +124,18 @@ public abstract class HttpMessage {
     protected static final TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
 
     private HttpMessageBytes msgBytes = new HttpMessageBytes();
-    
+
     protected HttpMessage.State state = HttpMessage.State.HEAD;
-    
-    protected HttpChannel httpCh; 
-    
+
+    protected HttpChannel httpCh;
+
     protected MultiMap headers = new MultiMap().insensitive();
 
     protected CBuffer protoMB;
-    
-    // Cookies 
+
+    // Cookies
     protected boolean cookiesParsed = false;
-    
+
     // TODO: cookies parsed when headers are added !
     protected ArrayList<ServerCookie> cookies;
     protected ArrayList<ServerCookie> cookiesCache;
@@ -147,17 +147,17 @@ public abstract class HttpMessage {
     BufferedIOReader bufferedReader;
     HttpWriter writer;
     IOWriter conv;
-    
+
     IOOutputStream out;
-    private IOInputStream in; 
-        
+    private IOInputStream in;
+
     boolean commited;
-    
+
     protected IOBuffer body;
 
     long contentLength = -2;
     boolean chunked;
-    
+
     /**
      * The set of SimpleDateFormat formats to use in getDateHeader().
      *
@@ -166,26 +166,26 @@ public abstract class HttpMessage {
      */
     protected SimpleDateFormat formats[] = null;
 
-    
+
     BBuffer clBuffer = BBuffer.allocate(64);
-    
+
     public HttpMessage(HttpChannel httpCh) {
         this.httpCh = httpCh;
-        
+
         out = new IOOutputStream(httpCh.getOut(), httpCh);
         conv = new IOWriter(httpCh);
         writer = new HttpWriter(this, out, conv);
 
         in = new IOInputStream(httpCh, httpCh.getIOTimeout());
-        
+
         reader = new IOReader(httpCh.getIn());
         bufferedReader = new BufferedIOReader(reader);
-        
-        cookies = new ArrayList<ServerCookie>();    
-        cookiesCache = new ArrayList<ServerCookie>();    
-        protoMB = CBuffer.newInstance();        
+
+        cookies = new ArrayList<ServerCookie>();
+        cookiesCache = new ArrayList<ServerCookie>();
+        protoMB = CBuffer.newInstance();
     }
-    
+
     public void addHeader(String name, String value) {
         getMimeHeaders().addValue(name).set(value);
     }
@@ -206,7 +206,7 @@ public abstract class HttpMessage {
     public MultiMap getMimeHeaders() {
         return headers;
     }
-    
+
     /**
      * Return the value of the specified date header, if any; otherwise
      * return -1.
@@ -231,7 +231,7 @@ public abstract class HttpMessage {
             formats[1].setTimeZone(GMT_ZONE);
             formats[2].setTimeZone(GMT_ZONE);
         }
-        
+
         // Attempt to convert the date header in a variety of formats
         long result = FastHttpDateFormat.parseDate(value, formats);
         if (result != (-1L)) {
@@ -241,7 +241,7 @@ public abstract class HttpMessage {
 
     }
 
-    
+
     public Collection<String> getHeaderNames() {
 
         MultiMap headers = getMimeHeaders();
@@ -252,7 +252,7 @@ public abstract class HttpMessage {
         }
         return result;
     }
-    
+
     public boolean containsHeader(String name) {
         return headers.getHeader(name) != null;
     }
@@ -262,27 +262,27 @@ public abstract class HttpMessage {
         clBuffer.setLong(len);
         setCLHeader();
     }
-    
+
     public void setContentLength(int len) {
         contentLength = len;
         clBuffer.setLong(len);
         setCLHeader();
-    } 
-    
+    }
+
     private void setCLHeader() {
         MultiMap.Entry clB = headers.setEntry("content-length");
-        clB.valueB = clBuffer; 
+        clB.valueB = clBuffer;
     }
 
     public long getContentLengthLong() {
         if (contentLength == -2) {
             CBuffer clB = headers.getHeader("content-length");
-            contentLength = (clB == null) ? 
+            contentLength = (clB == null) ?
                     -1 : clB.getLong();
         }
         return contentLength;
     }
-    
+
     public int getContentLength() {
         long length = getContentLengthLong();
 
@@ -291,7 +291,7 @@ public abstract class HttpMessage {
         }
         return -1;
     }
-    
+
     public String getContentType() {
         CBuffer contentTypeMB = headers.getHeader("content-type");
         if (contentTypeMB == null) {
@@ -299,7 +299,7 @@ public abstract class HttpMessage {
         }
         return contentTypeMB.toString();
     }
-    
+
     public void setContentType(String contentType) {
         CBuffer clB = getMimeHeaders().getHeader("content-type");
         if (clB == null) {
@@ -311,7 +311,7 @@ public abstract class HttpMessage {
 
     /**
      * Get the character encoding used for this request.
-     * Need a field because it can be overriden. Used to construct the 
+     * Need a field because it can be overriden. Used to construct the
      * Reader.
      */
     public String getCharacterEncoding() {
@@ -321,19 +321,19 @@ public abstract class HttpMessage {
         charEncoding = ContentType.getCharsetFromContentType(getContentType());
         return charEncoding;
     }
-    
+
     private static final String DEFAULT_ENCODING = "ISO-8859-1";
-    
+
     public String getEncoding() {
         String charEncoding = getCharacterEncoding();
         if (charEncoding == null) {
-            return DEFAULT_ENCODING; 
+            return DEFAULT_ENCODING;
         } else {
             return charEncoding;
         }
     }
 
-    public void setCharacterEncoding(String enc) 
+    public void setCharacterEncoding(String enc)
             throws UnsupportedEncodingException {
         this.charEncoding = enc;
     }
@@ -349,32 +349,32 @@ public abstract class HttpMessage {
         cookies.clear();
         charEncoding = null;
         bufferedReader.recycle();
-        
+
         writer.recycle();
         conv.recycle();
-        
+
         contentLength = -2;
         chunked = false;
         clBuffer.recycle();
         state = State.HEAD;
         cookiesParsed = false;
         getMsgBytes().recycle();
-        
+
     }
-    
-    
+
+
     public String getProtocol() {
         return protoMB.toString();
     }
-    
+
     public void setProtocol(String proto) {
         protoMB.set(proto);
     }
-    
+
     public CBuffer protocol() {
         return protoMB;
     }
-    
+
     public ServerCookie getCookie(String name) {
         for (ServerCookie sc: getServerCookies()) {
             if (sc.getName().equalsIgnoreCase(name)) {
@@ -383,7 +383,7 @@ public abstract class HttpMessage {
         }
         return null;
     }
-    
+
     public List<ServerCookie> getServerCookies() {
         if (!cookiesParsed) {
             cookiesParsed = true;
@@ -391,11 +391,11 @@ public abstract class HttpMessage {
         }
         return cookies;
     }
-    
+
     public UrlEncoding getURLDecoder() {
         return urlDecoder;
     }
-    
+
     public boolean isCommitted() {
         return commited;
     }
@@ -403,36 +403,36 @@ public abstract class HttpMessage {
     public void setCommitted(boolean b) {
         commited = b;
     }
-    
+
     public HttpChannel getHttpChannel() {
         return httpCh;
     }
-    
+
     public IOBuffer getBody() {
         return body;
     }
-    
+
     void setBody(IOBuffer body) {
         this.body = body;
     }
-    
+
     public void flush() throws IOException {
         httpCh.startSending();
     }
-    
-    // not servlet input stream 
+
+    // not servlet input stream
     public IOInputStream getBodyInputStream() {
         return in;
     }
-    
+
     public InputStream getInputStream() {
         return in;
     }
-    
+
     public IOOutputStream getOutputStream() {
         return out;
     }
-    
+
     public IOOutputStream getBodyOutputStream() {
         return out;
     }
@@ -441,18 +441,18 @@ public abstract class HttpMessage {
         reader.setEncoding(getCharacterEncoding());
         return reader;
     }
-    
+
     public BBuffer readAll(BBuffer chunk, long to) throws IOException {
         return httpCh.readAll(chunk, to);
     }
-    
+
     public BBuffer readAll() throws IOException {
         return httpCh.readAll(null, httpCh.ioTimeout);
     }
-    
-    /** 
+
+    /**
      * We're done with this object, it can be recycled.
-     * Any use after this should throw exception or affect an 
+     * Any use after this should throw exception or affect an
      *  unrelated request.
      */
     public void release() throws IOException {
@@ -462,13 +462,13 @@ public abstract class HttpMessage {
     public void setCompletedCallback(RequestCompleted doneAllCallback) throws IOException {
         httpCh.setCompletedCallback(doneAllCallback);
     }
-    
+
     public void setReadTimeout(long to) {
         reader.setTimeout(to);
     }
-    
-    /** 
-     * Returns a buffered reader. 
+
+    /**
+     * Returns a buffered reader.
      */
     public BufferedReader getReader() throws IOException {
         reader.setEncoding(getCharacterEncoding());
@@ -478,31 +478,31 @@ public abstract class HttpMessage {
     public PrintWriter getWriter() {
         return new PrintWriter(getBodyWriter());
     }
-    
+
     public HttpWriter getBodyWriter() {
         conv.setEncoding(getCharacterEncoding());
         return writer;
     }
-    
-    
+
+
     protected void processMimeHeaders() {
         for (int idx = 0; idx < getMsgBytes().headerCount; idx++) {
             BBuffer nameBuf = getMsgBytes().getHeaderName(idx);
             BBuffer valBuf = getMsgBytes().getHeaderValue(idx);
-            
+
             MultiMap.Entry header = headers.addEntry(nameBuf);
             header.valueB = valBuf;
         }
     }
 
-    
+
     protected abstract void processReceivedHeaders() throws IOException;
-    
+
     public abstract boolean hasBody();
 
     public HttpMessageBytes getMsgBytes() {
         // TODO: serialize if not set
         return msgBytes;
     }
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpRequest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpRequest.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpRequest.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpRequest.java Sat Oct 22 21:30:59 2011
@@ -21,12 +21,12 @@ import org.apache.tomcat.lite.io.UrlEnco
 public class HttpRequest extends HttpMessage {
     public static final String DEFAULT_CHARACTER_ENCODING="ISO-8859-1";
 
-    protected CBuffer schemeMB;    
+    protected CBuffer schemeMB;
     protected CBuffer methodMB;
     protected CBuffer remoteAddrMB;
     protected CBuffer remoteHostMB;
     protected int remotePort;
-    
+
     protected CBuffer localNameMB;
     protected CBuffer localAddrMB;
     protected int localPort = -1;
@@ -34,19 +34,19 @@ public class HttpRequest extends HttpMes
     // Host: header, or default:80
     protected CBuffer serverNameMB;
     protected int serverPort = -1;
-    
-    
+
+
     // ==== Derived fields, computed after request is received ===
-    
+
     protected CBuffer requestURI;
     protected CBuffer queryMB;
-    
+
     protected BBuffer decodedUri = BBuffer.allocate();
     protected CBuffer decodedUriMB;
-    
+
     // Decoded query
     protected MultiMap parameters;
-    
+
     boolean parametersParsed = false;
 
     protected IOWriter charEncoder = new IOWriter(null);
@@ -57,13 +57,13 @@ public class HttpRequest extends HttpMes
     // will not be recycled
     public Object nativeRequest;
     public Object wrapperRequest;
-    
+
     boolean ssl = false;
-    
+
     boolean async = false;
 
     CBuffer requestURL = CBuffer.newInstance();
-    
+
     private Map<String, Object> attributes = new HashMap<String, Object>();
 
     /**
@@ -78,22 +78,22 @@ public class HttpRequest extends HttpMes
         requestURI = CBuffer.newInstance();
         queryMB = CBuffer.newInstance();
         serverNameMB = CBuffer.newInstance();
-        
+
         parameters = new MultiMap();
-        
-        schemeMB = 
+
+        schemeMB =
             CBuffer.newInstance();
         methodMB = CBuffer.newInstance();
         initRemote();
     }
-   
+
     protected void initRemote() {
         remoteAddrMB = CBuffer.newInstance();
         localNameMB = CBuffer.newInstance();
         remoteHostMB = CBuffer.newInstance();
         localAddrMB = CBuffer.newInstance();
     }
-    
+
     public void recycle() {
         super.recycle();
         schemeMB.recycle();
@@ -102,7 +102,7 @@ public class HttpRequest extends HttpMes
         requestURL.recycle();
         queryMB.recycle();
         decodedUriMB.recycle();
-        
+
         parameters.recycle();
         remoteAddrMB.recycle();
         remoteHostMB.recycle();
@@ -111,18 +111,18 @@ public class HttpRequest extends HttpMes
         async = false;
         asyncTimeout = -1;
         charEncoder.recycle();
-        
+
         localPort = -1;
         remotePort = -1;
         localAddrMB.recycle();
         localNameMB.recycle();
-        
+
         serverPort = -1;
         serverNameMB.recycle();
         decodedUri.recycle();
         decodedQuery.recycle();
     }
-    
+
     public Object getAttribute(String name) {
         return attributes.get(name);
     }
@@ -135,7 +135,7 @@ public class HttpRequest extends HttpMes
         }
     }
     // getAttributeNames not supported
-    
+
     public Map<String, Object> attributes() {
         return attributes;
     }
@@ -144,19 +144,19 @@ public class HttpRequest extends HttpMes
     public CBuffer method() {
         return methodMB;
     }
-    
+
     public String getMethod() {
         return methodMB.toString();
     }
-    
+
     public void setMethod(String method) {
         methodMB.set(method);
     }
-    
+
     public CBuffer scheme() {
         return schemeMB;
     }
-    
+
     public String getScheme() {
         String scheme = schemeMB.toString();
         if (scheme == null) {
@@ -164,15 +164,15 @@ public class HttpRequest extends HttpMes
         }
         return scheme;
     }
-    
+
     public void setScheme(String s) {
         schemeMB.set(s);
     }
-    
+
     public MappingData getMappingData() {
         return (mappingData);
     }
-    
+
     /**
      * Return the portion of the request URI used to select the Context
      * of the Request.
@@ -196,28 +196,28 @@ public class HttpRequest extends HttpMes
     public String getServletPath() {
         return (getMappingData().wrapperPath.toString());
     }
-    
-    /** 
-     * Parse query parameters - but not POST body. 
-     * 
-     * If you don't call this method, getParameters() will 
-     * also read the body for POST with x-www-url-encoded 
-     * mime type. 
+
+    /**
+     * Parse query parameters - but not POST body.
+     *
+     * If you don't call this method, getParameters() will
+     * also read the body for POST with x-www-url-encoded
+     * mime type.
      */
     public void parseQueryParameters() {
         parseQuery();
     }
 
     /**
-     * Explicitely parse the body, adding the parameters to 
+     * Explicitely parse the body, adding the parameters to
      * those from the query ( if already parsed ).
-     * 
+     *
      * By default servlet mode ( both query and body ) is used.
      */
     public void parsePostParameters() {
         parseBody();
     }
-    
+
     MultiMap getParameters() {
         if (!parametersParsed) {
             parseQuery();
@@ -225,13 +225,13 @@ public class HttpRequest extends HttpMes
         }
         return parameters;
     }
-    
+
     public Enumeration<String> getParameterNames() {
         return getParameters().names();
     }
-    
-    /** 
-     * Expensive, creates a copy on each call. 
+
+    /**
+     * Expensive, creates a copy on each call.
      * @param name
      * @return
      */
@@ -246,10 +246,10 @@ public class HttpRequest extends HttpMes
         }
         return values;
     }
-    
+
     // Inefficient - we convert from a different representation.
     public Map<String, String[]> getParameterMap() {
-        // we could allow 'locking' - I don't think this is 
+        // we could allow 'locking' - I don't think this is
         // a very useful optimization
         Map<String, String[]> map = new HashMap();
         for (int i = 0; i < getParameters().size(); i++) {
@@ -269,7 +269,7 @@ public class HttpRequest extends HttpMes
         }
         return map;
     }
-    
+
     public String getParameter(String name) {
         CharSequence value = getParameters().get(name);
         if (value == null) {
@@ -277,11 +277,11 @@ public class HttpRequest extends HttpMes
         }
         return value.toString();
     }
-    
+
     public void setParameter(String name, String value) {
         getParameters().set(name, value);
     }
-    
+
     public void addParameter(String name, String values) {
         getParameters().add(name, values);
     }
@@ -309,13 +309,13 @@ public class HttpRequest extends HttpMes
             }
         }
     }
-    
+
     public void setURI(CharSequence encoded) {
         decodedUriMB.recycle();
         decodedUriMB.append(encoded);
         // TODO: generate % encoding ( reverse of decodeRequest )
     }
-    
+
     public CBuffer decodedURI() {
         return decodedUriMB;
     }
@@ -323,11 +323,11 @@ public class HttpRequest extends HttpMes
     public CBuffer requestURI() {
         return requestURI;
     }
-    
+
     public CBuffer requestURL() {
         CBuffer url = requestURL;
         url.recycle();
-        
+
         String scheme = getScheme();
         int port = getServerPort();
         if (port < 0)
@@ -348,7 +348,7 @@ public class HttpRequest extends HttpMes
 
     }
 
-    /** 
+    /**
      * Not decoded - %xx as in original.
      * @return
      */
@@ -368,7 +368,7 @@ public class HttpRequest extends HttpMes
         return header;
     }
 
-    /** 
+    /**
      * Set the Host header of the request.
      * @param target
      */
@@ -376,7 +376,7 @@ public class HttpRequest extends HttpMes
         serverNameMB.recycle();
         getOrAdd("Host").set(target);
     }
-    
+
     // XXX
     public CBuffer serverName() {
         if (serverNameMB.length() == 0) {
@@ -388,16 +388,16 @@ public class HttpRequest extends HttpMes
     public String getServerName() {
         return serverName().toString();
     }
-    
+
     public void setServerName(String name)  {
         serverName().set(name);
     }
-    
+
     public int getServerPort() {
         serverName();
         return serverPort;
     }
-    
+
     public void setServerPort(int serverPort ) {
         this.serverPort=serverPort;
     }
@@ -406,7 +406,7 @@ public class HttpRequest extends HttpMes
         if (remoteAddrMB.length() == 0) {
             HttpChannel asyncHttp = getHttpChannel();
             IOChannel iochannel = asyncHttp.getNet().getFirst();
-            remoteAddrMB.set((String) 
+            remoteAddrMB.set((String)
                     iochannel.getAttribute(IOChannel.ATT_REMOTE_ADDRESS));
         }
         return remoteAddrMB;
@@ -416,7 +416,7 @@ public class HttpRequest extends HttpMes
         if (remoteHostMB.length() == 0) {
             HttpChannel asyncHttp = getHttpChannel();
             IOChannel iochannel = asyncHttp.getNet().getFirst();
-            remoteHostMB.set((String) 
+            remoteHostMB.set((String)
                     iochannel.getAttribute(IOChannel.ATT_REMOTE_HOSTNAME));
         }
         return remoteHostMB;
@@ -424,12 +424,12 @@ public class HttpRequest extends HttpMes
 
     public CBuffer localName() {
         return localNameMB;
-    }    
+    }
 
     public CBuffer localAddr() {
         return localAddrMB;
     }
-    
+
     public int getRemotePort(){
         if (remotePort == -1) {
             HttpChannel asyncHttp = getHttpChannel();
@@ -438,11 +438,11 @@ public class HttpRequest extends HttpMes
         }
         return remotePort;
     }
-        
+
     public void setRemotePort(int port){
         this.remotePort = port;
     }
-    
+
     public int getLocalPort(){
         if (localPort == -1) {
             HttpChannel asyncHttp = getHttpChannel();
@@ -451,11 +451,11 @@ public class HttpRequest extends HttpMes
         }
         return localPort;
     }
-        
+
     public void setLocalPort(int port){
         this.localPort = port;
     }
-    
+
     public HttpResponse waitResponse() throws IOException {
         return waitResponse(httpCh.ioTimeout);
     }
@@ -467,7 +467,7 @@ public class HttpRequest extends HttpMes
 
         httpCh.send();
     }
-    
+
     public void send(HttpService headersCallback) throws IOException {
         send(headersCallback, httpCh.ioTimeout);
     }
@@ -475,20 +475,20 @@ public class HttpRequest extends HttpMes
     public void send() throws IOException {
         send(null, httpCh.ioTimeout);
     }
-    
+
     public HttpResponse waitResponse(long timeout) throws IOException {
         // TODO: close out if post
         httpCh.send();
-        
+
         httpCh.headersReceivedLock.waitSignal(timeout);
-        
+
         return httpCh.getResponse();
     }
 
     /**
      * Parse host.
-     * @param serverNameMB2 
-     * @throws IOException 
+     * @param serverNameMB2
+     * @throws IOException
      */
     boolean parseHost()  {
         MultiMap.Entry hostHF = getMimeHeaders().getEntry("Host");
@@ -507,9 +507,9 @@ public class HttpRequest extends HttpMes
         byte[] valueB = valueBC.array();
         int valueL = valueBC.getLength();
         int valueS = valueBC.getStart();
-        
+
         int colonPos = valueBC.indexOf(':', 0);
-        
+
         serverNameMB.recycle();
 
         boolean ipv6 = (valueB[valueS] == '[');
@@ -525,7 +525,7 @@ public class HttpRequest extends HttpMes
             serverNameMB.append(b);
             if (b == ']') {
                 bracketClosed = true;
-            } 
+            }
         }
 
         if (colonPos < 0) {
@@ -551,7 +551,7 @@ public class HttpRequest extends HttpMes
         }
         return true;
     }
-    
+
     // TODO: this is from coyote - MUST be rewritten !!!
     // - cleaner
     // - chunked encoding for body
@@ -560,11 +560,11 @@ public class HttpRequest extends HttpMes
      * Post data buffer.
      */
     public final static int CACHED_POST_LEN = 8192;
-    
+
     public  byte[] postData = null;
 
     private long asyncTimeout = -1;
-    
+
     /**
      * Parse request parameters.
      */
@@ -595,7 +595,7 @@ public class HttpRequest extends HttpMes
 
     // Copy - will be modified by decoding
     BBuffer decodedQuery = BBuffer.allocate(1024);
-    
+
     CBuffer tmpNameC = CBuffer.newInstance();
     BBuffer tmpName = BBuffer.wrapper();
     BBuffer tmpValue = BBuffer.wrapper();
@@ -603,23 +603,23 @@ public class HttpRequest extends HttpMes
     CBuffer tmpNameCB = CBuffer.newInstance();
     CBuffer tmpValueCB = CBuffer.newInstance();
 
-    /** 
+    /**
      * Process the query string into parameters
      */
     public void handleQueryParameters() {
         if( queryMB.length() == 0) {
             return;
         }
-        
+
         decodedQuery.recycle();
         decodedQuery.append(getMsgBytes().query());
         // TODO: option 'useBodyEncodingForUri' - versus UTF or ASCII
         String queryStringEncoding = getEncoding();
         processParameters( decodedQuery, queryStringEncoding );
     }
-    
+
     public void processParameters( BBuffer bc, String encoding ) {
-        if( bc.isNull()) 
+        if( bc.isNull())
             return;
         if (bc.remaining() ==0) {
             return;
@@ -627,8 +627,8 @@ public class HttpRequest extends HttpMes
         processParameters( bc.array(), bc.getOffset(),
                            bc.getLength(), encoding);
     }
-    
-    public void processParameters( byte bytes[], int start, int len, 
+
+    public void processParameters( byte bytes[], int start, int len,
             String enc ) {
         int end=start+len;
         int pos=start;
@@ -649,7 +649,7 @@ public class HttpRequest extends HttpMes
                 valStart=nameEnd;
                 valEnd=nameEnd;
             }
-            if( nameEnd== -1 ) 
+            if( nameEnd== -1 )
                 nameEnd=end;
 
             if( ! noEq ) {
@@ -664,13 +664,13 @@ public class HttpRequest extends HttpMes
                 // No name eg ...&=xx&... will trigger this
                 continue;
             }
-            
+
             // TODO: use CBuffer, recycle
             tmpName.setBytes( bytes, nameStart, nameEnd-nameStart );
             tmpValue.setBytes( bytes, valStart, valEnd-valStart );
-            
+
             try {
-                parameters.add(urlDecode(tmpName, enc), 
+                parameters.add(urlDecode(tmpName, enc),
                         urlDecode(tmpValue, enc));
             } catch (IOException e) {
                 // ignored
@@ -678,7 +678,7 @@ public class HttpRequest extends HttpMes
         } while( pos<end );
     }
 
-//    public void processParameters(char bytes[], int start, int len, 
+//    public void processParameters(char bytes[], int start, int len,
 //            String enc ) {
 //        int end=start+len;
 //        int pos=start;
@@ -699,7 +699,7 @@ public class HttpRequest extends HttpMes
 //                valStart=nameEnd;
 //                valEnd=nameEnd;
 //            }
-//            if( nameEnd== -1 ) 
+//            if( nameEnd== -1 )
 //                nameEnd=end;
 //
 //            if( ! noEq ) {
@@ -714,37 +714,37 @@ public class HttpRequest extends HttpMes
 //                // No name eg ...&=xx&... will trigger this
 //                continue;
 //            }
-//            
+//
 //            // TODO: use CBuffer, recycle
 //            tmpNameCB.recycle();
 //            tmpValueCB.recycle();
-//            
+//
 //            tmpNameCB.wrap( bytes, nameStart, nameEnd );
 //            tmpValueCB.wrap( bytes, valStart, valEnd );
-//            
+//
 //            //CharChunk name = new CharChunk();
 //            //CharChunk value = new CharChunk();
 //            // TODO:
 //            try {
-//                parameters.add(urlDecode(tmpName, enc), 
+//                parameters.add(urlDecode(tmpName, enc),
 //                        urlDecode(tmpValue, enc));
 //            } catch (IOException e) {
 //                // ignored
 //            }
 //        } while( pos<end );
 //    }
-    
+
     private String urlDecode(BBuffer bc, String enc)
             throws IOException {
         // Replace %xx
         urlDecoder.urlDecode(bc, true);
-        
+
         String result = null;
         if (enc != null) {
             result = bc.toString(enc);
         } else {
             // Ascii
-            
+
             CBuffer cc = tmpNameC;
             cc.recycle();
             int length = bc.getLength();
@@ -760,7 +760,7 @@ public class HttpRequest extends HttpMes
     private void processParameters( byte bytes[], int start, int len ) {
         processParameters(bytes, start, len, getEncoding());
     }
-    
+
     protected void parseBody() {
 
         parametersParsed = true;
@@ -770,7 +770,7 @@ public class HttpRequest extends HttpMes
 //      return;
         if (!getMethod().equalsIgnoreCase("POST"))
             return;
-        
+
         String contentType = getContentType();
         if (contentType == null)
             contentType = "";
@@ -823,10 +823,10 @@ public class HttpRequest extends HttpMes
         return len;
 
     }
-    
-    // Async support - a subset of servlet spec, the fancy stuff is in the 
+
+    // Async support - a subset of servlet spec, the fancy stuff is in the
     // facade.
-    
+
     public boolean isAsyncStarted() {
         return async;
     }
@@ -838,8 +838,8 @@ public class HttpRequest extends HttpMes
     public void setAsyncTimeout(long timeout) {
         this.asyncTimeout  = timeout;
     }
-    
-    /** 
+
+    /**
      * Server mode, request just received.
      */
     protected void processReceivedHeaders() throws IOException {
@@ -849,57 +849,57 @@ public class HttpRequest extends HttpMes
         }
         if (url.get(0) == 'h') {
             int firstSlash = url.indexOf('/', 0);
-            schemeMB.appendAscii(url.array(), 
+            schemeMB.appendAscii(url.array(),
                     url.getStart(), firstSlash + 2);
-            if (!schemeMB.equals("http://") && 
+            if (!schemeMB.equals("http://") &&
                     !schemeMB.equals("https://")) {
                 httpCh.getResponse().setStatus(400);
-                httpCh.abort("Error normalizing url " + 
+                httpCh.abort("Error normalizing url " +
                         getMsgBytes().url());
-                return;                                
+                return;
             }
-            
+
             int urlStart = url.indexOf('/', firstSlash + 2);
             serverNameMB.recycle();
-            serverNameMB.appendAscii(url.array(), 
+            serverNameMB.appendAscii(url.array(),
                     url.getStart() + firstSlash + 2, urlStart - firstSlash - 2);
-            
+
             url.position(url.getStart() + urlStart);
         }
         if (!httpCh.normalize(getMsgBytes().url())) {
             httpCh.getResponse().setStatus(400);
-            httpCh.abort("Error normalizing url " + 
+            httpCh.abort("Error normalizing url " +
                     getMsgBytes().url());
-            return;                
+            return;
         }
-        
-        method().set(getMsgBytes().method()); 
+
+        method().set(getMsgBytes().method());
         requestURI().set(getMsgBytes().url());
         queryString().set(getMsgBytes().query());
         protocol().set(getMsgBytes().protocol());
-        
+
         processMimeHeaders();
 
         // URL decode and normalize
         decodedUri.append(getMsgBytes().url());
-        
-        getURLDecoder().urlDecode(decodedUri, false); 
-        
+
+        getURLDecoder().urlDecode(decodedUri, false);
+
         // Need to normalize again - %decoding may decode /
         if (!httpCh.normalize(decodedUri)) {
             httpCh.getResponse().setStatus(400);
             httpCh.abort("Invalid decoded uri " + decodedUri);
-            return;                
+            return;
         }
         decodedURI().set(decodedUri);
 
         // default response protocol
-        httpCh.getResponse().protocol().set(getMsgBytes().protocol());            
+        httpCh.getResponse().protocol().set(getMsgBytes().protocol());
     }
 
-    
+
     public boolean hasBody() {
-        return chunked || contentLength >= 0; 
+        return chunked || contentLength >= 0;
     }
 
     /**
@@ -925,7 +925,7 @@ public class HttpRequest extends HttpMes
             String name = serverName().toString();
             int port = getServerPort();
 
-            cb.append(scheme);                
+            cb.append(scheme);
             cb.append("://", 0, 3);
             cb.append(name);
             if ((scheme.equals("http") && port != 80)
@@ -951,8 +951,8 @@ public class HttpRequest extends HttpMes
             cb.append(location);
         }
 
-    }    
-    
+    }
+
     /**
      * Determine if a URI string has a <code>scheme</code> component.
      */
@@ -977,7 +977,7 @@ public class HttpRequest extends HttpMes
         return Character.isLetterOrDigit(c) ||
             c == '+' || c == '-' || c == '.';
     }
-    
+
     public IOWriter getCharEncoder() {
         return charEncoder;
     }
@@ -985,11 +985,11 @@ public class HttpRequest extends HttpMes
     public IOReader getCharDecoder() {
         return charDecoder;
     }
-    
+
     public UrlEncoding getUrlEncoding() {
         return urlEncoding;
     }
-    
+
     public BBuffer toBytes(CBuffer cb, BBuffer bb) {
         if (bb == null) {
             bb = BBuffer.allocate(cb.length());
@@ -1007,11 +1007,11 @@ public class HttpRequest extends HttpMes
             return "Invalid request";
         }
     }
-    
+
     public boolean isSecure() {
         return ssl;
     }
-    
+
     public HttpRequest setSecure(boolean ssl) {
         this.ssl = ssl;
         return this;

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpResponse.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpResponse.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpResponse.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpResponse.java Sat Oct 22 21:30:59 2011
@@ -10,7 +10,7 @@ import org.apache.tomcat.lite.io.BBuffer
 import org.apache.tomcat.lite.io.CBuffer;
 
 public class HttpResponse extends HttpMessage {
-    
+
     /*
      * Server status codes; see RFC 2068.
      */
@@ -21,7 +21,7 @@ public class HttpResponse extends HttpMe
 
     public static final int SC_CONTINUE = 100;
 
-    
+
     /**
      * Status code (101) indicating the server is switching protocols
      * according to Upgrade header.
@@ -76,14 +76,14 @@ public class HttpResponse extends HttpMe
      */
 
     public static final int SC_PARTIAL_CONTENT = 206;
-    
+
     /**
      * Used by Webdav.
      */
     public static final int SC_MULTI_STATUS = 207;
     // This one collides with HTTP 1.1
     // "207 Partial Update OK"
-    
+
     /**
      * Status code (300) indicating that the requested resource
      * corresponds to any one of a set of representations, each with
@@ -144,9 +144,9 @@ public class HttpResponse extends HttpMe
     public static final int SC_USE_PROXY = 305;
 
      /**
-     * Status code (307) indicating that the requested resource 
+     * Status code (307) indicating that the requested resource
      * resides temporarily under a different URI. The temporary URI
-     * <em>SHOULD</em> be given by the <code><em>Location</em></code> 
+     * <em>SHOULD</em> be given by the <code><em>Location</em></code>
      * field in the response.
      */
 
@@ -343,7 +343,7 @@ public class HttpResponse extends HttpMe
     public Object nativeResponse;
 
     protected CBuffer message = CBuffer.newInstance();
-    
+
     int status = -1;
 
     HttpResponse(HttpChannel httpCh) {
@@ -355,33 +355,33 @@ public class HttpResponse extends HttpMe
         message.recycle();
         status = -1;
     }
-    
+
     public void setMessage(String s) {
         message.set(filter(s));
     }
-    
+
     public String getMessage() {
         return message.toString();
     }
-    
+
     public CBuffer getMessageBuffer() {
         return message;
     }
-    
+
     byte[] S_200 = new byte[] { '2', '0', '0' };
-    
+
     public void setStatus(int i) {
         status = i;
     }
-    
+
     public void sendError(int status) {
         this.status = status;
     }
-    
+
     public void sendError(int status, String msg) {
         message.set(msg);
     }
-    
+
     public int getStatus() {
         if (status >= 0) {
             return status;
@@ -402,10 +402,10 @@ public class HttpResponse extends HttpMe
     public HttpRequest getRequest() {
         return getHttpChannel().getRequest();
     }
-    
+
     // Http client mode.
     protected void processReceivedHeaders() throws IOException {
-        protocol().set(getMsgBytes().protocol());                
+        protocol().set(getMsgBytes().protocol());
         message.set(getMsgBytes().message());
         processMimeHeaders();
         // TODO: if protocol == 1.0 and we requested 1.1, downgrade getHttpChannel().pro
@@ -417,11 +417,11 @@ public class HttpResponse extends HttpMe
     }
 
     /**
-     * All responses to the HEAD request method MUST NOT include a 
+     * All responses to the HEAD request method MUST NOT include a
      * message-body, even though the presence of entity- header fields might
      *  lead one to believe they do. All 1xx (informational), 204 (no content)
-     *  , and 304 (not modified) responses MUST NOT include a message-body. All 
-     *  other responses do include a message-body, although it MAY be of zero 
+     *  , and 304 (not modified) responses MUST NOT include a message-body. All
+     *  other responses do include a message-body, although it MAY be of zero
      *  length.
      */
     public boolean hasBody() {
@@ -432,13 +432,13 @@ public class HttpResponse extends HttpMe
             return false;
         }
         // what about (status == 205) ?
-        if ((status == 204) 
+        if ((status == 204)
                 || (status == 304)) {
             return false;
         }
         return true;
     }
-    
+
     /** Get the status string associated with a status code.
      *  No I18N - return the messages defined in the HTTP spec.
      *  ( the user isn't supposed to see them, this is the last
@@ -468,11 +468,11 @@ public class HttpResponse extends HttpMe
         }
         return bb;
     }
-    
+
     public static String getStatusText(int code) {
         return getMessage(code).toString();
     }
-    
+
     static BBucket st_unknown = BBuffer.wrapper("No Message");
     static BBucket st_200 = BBuffer.wrapper("OK");
     static BBucket st_302= BBuffer.wrapper("Moved Temporarily");
@@ -483,7 +483,7 @@ public class HttpResponse extends HttpMe
     private static void addStatus(int stat, String msg) {
         stats.put(stat, BBuffer.wrapper(msg));
     }
-    
+
     static {
         addStatus(100, "Continue");
         addStatus(101, "Switching Protocols");
@@ -532,9 +532,9 @@ public class HttpResponse extends HttpMe
         addStatus(507, "Insufficient Storage");
         addStatus(SC_LOCKED, "Locked");
 
-        
+
     }
-    
+
     /**
      * Filter the specified message string for characters that are sensitive
      * in HTML.  This avoids potential attacks caused by including JavaScript
@@ -552,7 +552,7 @@ public class HttpResponse extends HttpMe
                 message.indexOf('"') < 0) {
             return message;
         }
-        
+
         char content[] = new char[message.length()];
         message.getChars(0, message.length(), content, 0);
 
@@ -577,5 +577,5 @@ public class HttpResponse extends HttpMe
         }
         return (result.toString());
     }
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpServer.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpServer.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpServer.java Sat Oct 22 21:30:59 2011
@@ -7,11 +7,11 @@ import org.apache.tomcat.lite.io.SslProv
 import org.apache.tomcat.lite.io.jsse.JsseSslProvider;
 
 /**
- * Main entry point for HTTP server code. 
- * 
- * ( initial draft - will replace statics, add helpers, etc ) 
+ * Main entry point for HTTP server code.
+ *
+ * ( initial draft - will replace statics, add helpers, etc )
  */
-public class HttpServer { 
+public class HttpServer {
     static SslProvider sslConC = new JsseSslProvider();
 
     public synchronized static HttpConnector newServer(int port) {
@@ -24,10 +24,10 @@ public class HttpServer { 
         //      SslConnector.setEnabledCiphers(new String[] {
         //              "TLS_RSA_WITH_3DES_EDE_CBC_SHA"
         //      });
-        // -cipher DES-CBC3-SHA 
-      
+        // -cipher DES-CBC3-SHA
+
         SslProvider sslCon = new JsseSslProvider();
-        
+
         return new HttpConnector(new SocketConnector()).
             withSsl(sslCon).setPort(port).setServerSsl(true);
     }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpWriter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpWriter.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpWriter.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/HttpWriter.java Sat Oct 22 21:30:59 2011
@@ -10,14 +10,14 @@ import org.apache.tomcat.lite.io.IOWrite
 
 /**
  * Implement character translation and buffering.
- * 
- * The actual buffering happens in the IOBuffer - we translate the 
- * chars as soon as we get them. 
- * 
+ *
+ * The actual buffering happens in the IOBuffer - we translate the
+ * chars as soon as we get them.
+ *
  * For servlet compat you can set a buffer size and a flush() will happen
- * when the number of chars have been written. Note that writes at a lower 
- * layer can be done and are not counted. 
- * 
+ * when the number of chars have been written. Note that writes at a lower
+ * layer can be done and are not counted.
+ *
  * @author Costin Manolache
  */
 public class HttpWriter extends Writer {
@@ -34,7 +34,7 @@ public class HttpWriter extends Writer {
     protected IOOutputStream bb;
 
     int bufferSize = DEFAULT_BUFFER_SIZE;
-    
+
     /**
      * Number of chars written.
      */
@@ -47,7 +47,7 @@ public class HttpWriter extends Writer {
     protected boolean closed = false;
 
     /**
-     * Encoding to use. 
+     * Encoding to use.
      * TODO: isn't it redundant ? enc, gotEnc, conv plus the enc in the bb
      */
     protected String enc;
@@ -60,7 +60,7 @@ public class HttpWriter extends Writer {
 
 
     /**
-     * List of encoders. The writer is reused - the encoder mapping 
+     * List of encoders. The writer is reused - the encoder mapping
      * avoids creating expensive objects. In future it'll contain nio.Charsets
      */
     //protected Map<String, C2BConverter> encoders = new HashMap();
@@ -82,7 +82,7 @@ public class HttpWriter extends Writer {
 
     /**
      * Default constructor. Allocate the buffer with the default buffer size.
-     * @param out 
+     * @param out
      */
     public HttpWriter(HttpMessage message, IOOutputStream out,
             IOWriter conv) {
@@ -96,7 +96,7 @@ public class HttpWriter extends Writer {
 
     /**
      * Is the response output suspended ?
-     * 
+     *
      * @return suspended flag value
      */
     public boolean isSuspended() {
@@ -106,7 +106,7 @@ public class HttpWriter extends Writer {
 
     /**
      * Set the suspended flag.
-     * 
+     *
      * @param suspended New suspended flag value
      */
     public void setSuspended(boolean suspended) {
@@ -122,14 +122,14 @@ public class HttpWriter extends Writer {
      */
     public void recycle() {
         wSinceFlush = 0;
-        bb.recycle(); 
+        bb.recycle();
         closed = false;
         suspended = false;
-        
+
 //        if (conv != null) {
 //            conv.recycle();
 //        }
-        
+
         gotEnc = false;
         enc = null;
     }
@@ -144,14 +144,14 @@ public class HttpWriter extends Writer {
 
         push();
         closed = true;
-        
+
         bb.close();
     }
 
 
     /**
      * Flush bytes or chars contained in the buffer.
-     * 
+     *
      * @throws IOException An underlying IOException occurred
      */
     public void flush()
@@ -170,7 +170,7 @@ public class HttpWriter extends Writer {
         if (suspended)
             return;
         getConv().push();
-        
+
     }
 
 
@@ -234,7 +234,7 @@ public class HttpWriter extends Writer {
         if (s==null)
             s="null";
         write(s, 0, s.length());
-    } 
+    }
 
     public void println() throws IOException {
         write("\n");
@@ -249,7 +249,7 @@ public class HttpWriter extends Writer {
         write(s);
     }
 
-    public void checkConverter() 
+    public void checkConverter()
             throws IOException {
 //        if (gotEnc) {
 //            return;
@@ -262,9 +262,9 @@ public class HttpWriter extends Writer {
 //        if (enc == null)
 //            enc = DEFAULT_ENCODING;
 //        conv = (C2BConverter) encoders.get(enc);
-//        
+//
 //        if (conv == null) {
-//            conv = C2BConverter.newConverter(message.getBodyOutputStream(), 
+//            conv = C2BConverter.newConverter(message.getBodyOutputStream(),
 //                    enc);
 //            encoders.put(enc, conv);
 //
@@ -286,7 +286,7 @@ public class HttpWriter extends Writer {
      *  Clear any data that was buffered.
      */
     public void reset() {
-        if (conv != null) { 
+        if (conv != null) {
             conv.recycle();
         }
         wSinceFlush = 0;

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MappingData.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MappingData.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MappingData.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MappingData.java Sat Oct 22 21:30:59 2011
@@ -28,7 +28,7 @@ import org.apache.tomcat.lite.io.CBuffer
 public class MappingData {
 
     public Object context = null; // ServletContextImpl
-    
+
     public BaseMapper.Context contextMap;
 
     public BaseMapper.ServiceMapping service = null;
@@ -43,7 +43,7 @@ public class MappingData {
     // Extension
     CBuffer ext = CBuffer.newInstance();
     CBuffer tmpPrefix = CBuffer.newInstance();
-    
+
     // Excluding context path, with a '/' added if needed
     CBuffer tmpServletPath = CBuffer.newInstance();
 
@@ -51,7 +51,7 @@ public class MappingData {
     CBuffer tmpWelcome = CBuffer.newInstance();
 
     public void recycle() {
-        service = null; 
+        service = null;
         context = null;
         pathInfo.recycle();
         requestPath.recycle();

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MultiMap.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MultiMap.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MultiMap.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/MultiMap.java Sat Oct 22 21:30:59 2011
@@ -29,32 +29,32 @@ import org.apache.tomcat.lite.io.CBucket
 import org.apache.tomcat.lite.io.CBuffer;
 
 /**
- * Map used to represent headers and parameters ( could be used 
+ * Map used to represent headers and parameters ( could be used
  * for cookies too )
- * 
- * It'll avoid garbage collection, like original tomcat classes, 
+ *
+ * It'll avoid garbage collection, like original tomcat classes,
  * by converting to chars and strings late.
- * 
+ *
  * Not thread safe.
  */
 public class MultiMap {
 
     public static class Entry {
         // Wrappers from the head message bytes.
-        BBuffer nameB; 
+        BBuffer nameB;
         BBuffer valueB;
-        
+
         CBuffer key = CBuffer.newInstance();
         private CBuffer value = CBuffer.newInstance();
-        
-        /** 
+
+        /**
          * For the first entry with a given name: list of all
          * other entries, including this one, with same name.
-         * 
+         *
          * For second or more: empty list
          */
-        public List<Entry> values = new ArrayList<Entry>(); 
-    
+        public List<Entry> values = new ArrayList<Entry>();
+
         public void recycle() {
             key.recycle();
             value.recycle();
@@ -63,14 +63,14 @@ public class MultiMap {
             valueB = null;
             values.clear();
         }
-    
+
         public CBuffer getName() {
             if (key.length() == 0 && nameB != null) {
                 key.set(nameB);
             }
             return key;
         }
-    
+
         public CBuffer getValue() {
             if (value.length() == 0 && valueB != null) {
                 value.set(valueB);
@@ -78,13 +78,13 @@ public class MultiMap {
             return value;
         }
 
-        /** Important - used by values iterator, returns strings 
+        /** Important - used by values iterator, returns strings
          * from each entry
          */
         public String toString() {
             return getValue().toString();
         }
-        
+
     }
 
     // active entries
@@ -92,15 +92,15 @@ public class MultiMap {
 
     // The key will be converted to lower case
     boolean toLower = false;
-    
+
     // Some may be inactive - up to count.
     protected List<Entry> entries = new ArrayList<Entry>();
-    
+
     // 2 options: convert all header/param names to String
     // or use a temp CBuffer to map
-    Map<CBuffer, Entry> map = 
+    Map<CBuffer, Entry> map =
         new HashMap<CBuffer, Entry>();
-    
+
     public void recycle() {
         for (int i = 0; i < count; i++) {
             Entry entry = entries.get(i);
@@ -115,7 +115,7 @@ public class MultiMap {
     protected Entry newEntry()  {
         return new Entry();
     }
-    
+
     /**
      * Adds a partially constructed field entry.
      * Updates count - but will not affect the map.
@@ -131,7 +131,7 @@ public class MultiMap {
         count++;
         return entry;
     }
-    
+
 
     /** Create a new named header , return the CBuffer
      *  container for the new value
@@ -154,18 +154,18 @@ public class MultiMap {
        mh.nameB = name;
        if (toLower) {
            mh.getName().toLower();
-       }       
+       }
        updateMap(mh);
-       
+
        return mh;
    }
 
    private void updateMap(Entry mh) {
        Entry topEntry = map.get(mh.getName());
-       
+
        if (topEntry == null) {
            map.put(mh.getName(), mh);
-           mh.values.add(mh);            
+           mh.values.add(mh);
        } else {
            topEntry.values.add(mh);
        }
@@ -178,7 +178,7 @@ public class MultiMap {
         Entry entry = getEntry(ckey);
         if (entry != null) {
             map.remove(ckey);
-            
+
             for (int i = count - 1; i >= 0; i--) {
                 entry = entries.get(i);
                 if (entry.getName().equals(key)) {
@@ -187,12 +187,12 @@ public class MultiMap {
                     count--;
                 }
             }
-        }            
+        }
     }
 
     // --------------- Key-based access --------------
     CBuffer tmpKey = CBuffer.newInstance();
-    
+
     /**
      * Finds and returns a header field with the given name.  If no such
      * field exists, null is returned.  If more than one such field is
@@ -218,10 +218,10 @@ public class MultiMap {
         tmpKey.append(key);
         if (toLower) {
             tmpKey.toLower();
-        }        
+        }
         return tmpKey;
     }
-    
+
     public Entry getEntry(CharSequence key) {
         Entry entry = map.get(key(key));
         return entry;
@@ -235,13 +235,13 @@ public class MultiMap {
 
     public Enumeration<String> names() {
         return new IteratorEnumerator(map.keySet().iterator());
-    }    
+    }
 
     // ----------- Index access --------------
-    
+
     /**
      *  Number of entries ( including those with same key
-     * 
+     *
      * @return
      */
     public int size() {
@@ -278,7 +278,7 @@ public class MultiMap {
         Entry mh = addEntry(key);
         mh.value.append(value);
     }
-    
+
     /** Create a new named header , return the CBuffer
      * container for the new value
      */
@@ -295,7 +295,7 @@ public class MultiMap {
          remove(key);
          add(key, value);
      }
-     
+
      public CBuffer setValue( String name ) {
          remove(name);
          return addValue(name);
@@ -310,30 +310,30 @@ public class MultiMap {
          Entry entry = getEntry(key);
          return (entry == null) ? null : entry.value.toString();
      }
-     
-    
+
+
     // -------------- support classes ----------------
-    
+
     public static class IteratorEnumerator implements Enumeration<String> {
         private final Iterator keyI;
-    
+
         public IteratorEnumerator(Iterator iterator) {
             this.keyI = iterator;
         }
-    
-        
+
+
         public boolean hasMoreElements() {
             return keyI.hasNext();
         }
-    
-        
+
+
         public String nextElement() {
             return keyI.next().toString();
         }
 
     }
 
-    public static final Enumeration<String> EMPTY = 
+    public static final Enumeration<String> EMPTY =
         new Enumeration<String>() {
 
             @Override
@@ -345,7 +345,7 @@ public class MultiMap {
             public String nextElement() {
                 return null;
             }
-        
+
     };
 
     public MultiMap insensitive() {
@@ -353,5 +353,5 @@ public class MultiMap {
         return this;
     }
 
-    
+
 }

Modified: tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/ServerCookie.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/ServerCookie.java?rev=1187812&r1=1187811&r2=1187812&view=diff
==============================================================================
--- tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/ServerCookie.java (original)
+++ tomcat/trunk/modules/tomcat-lite/java/org/apache/tomcat/lite/http/ServerCookie.java Sat Oct 22 21:30:59 2011
@@ -40,18 +40,18 @@ import org.apache.tomcat.lite.io.CBuffer
  *  and the facade will convert it to the external representation.
  */
 public class ServerCookie implements Serializable {
-    
+
     // Version 0 (Netscape) attributes
     private BBuffer name = BBuffer.allocate();
     private BBuffer value = BBuffer.allocate();
-    
+
     private CBuffer nameC = CBuffer.newInstance();
 
     // Expires - Not stored explicitly. Generated from Max-Age (see V1)
     private BBuffer path = BBuffer.allocate();
     private BBuffer domain = BBuffer.allocate();
     private boolean secure;
-    
+
     // Version 1 (RFC2109) attributes
     private BBuffer comment = BBuffer.allocate();
     private int maxAge = -1;
@@ -69,7 +69,7 @@ public class ServerCookie implements Ser
             return df;
         }
     };
-    
+
     private static final String ancientDate;
 
 
@@ -100,7 +100,7 @@ public class ServerCookie implements Ser
     public ServerCookie() {
     }
 
-    public void recycle() {        
+    public void recycle() {
         path.recycle();
         name.recycle();
         value.recycle();
@@ -163,7 +163,7 @@ public class ServerCookie implements Ser
         return "Cookie " + getName() + "=" + getValue() + " ; "
             + getVersion() + " " + getPath() + " " + getDomain();
     }
-    
+
     private static final String tspecials = ",; ";
     private static final String tspecials2 = "()<>@,;:\\\"/[]?={} \t";
     private static final String tspecials2NoSlash = "()<>@,;:\\\"[]?={} \t";
@@ -180,7 +180,7 @@ public class ServerCookie implements Ser
     public static boolean isToken(String value) {
         return isToken(value,null);
     }
-    
+
     public static boolean isToken(String value, String literals) {
         String tspecials = (literals==null?ServerCookie.tspecials:literals);
         if( value==null) return true;
@@ -228,7 +228,7 @@ public class ServerCookie implements Ser
 
     // -------------------- Cookie parsing tools
 
-    
+
     /**
      * Return the header name to set the cookie, based on cookie version.
      */
@@ -246,7 +246,7 @@ public class ServerCookie implements Ser
             // XXX RFC2965 not referenced in Servlet Spec
             // Set-Cookie2 is not supported by Netscape 4, 6, IE 3, 5
             // Set-Cookie2 is supported by Lynx and Opera
-            // Need to check on later IE and FF releases but for now... 
+            // Need to check on later IE and FF releases but for now...
             // RFC2109
             return "Set-Cookie";
             // return "Set-Cookie2";
@@ -273,7 +273,7 @@ public class ServerCookie implements Ser
         buf.append( name );
         buf.append("=");
         // Servlet implementation does not check anything else
-        
+
         version = maybeQuote2(version, buf, value,true);
 
         // Add version 1 specific information
@@ -287,7 +287,7 @@ public class ServerCookie implements Ser
                 maybeQuote2(version, buf, comment);
             }
         }
-        
+
         // Add domain information, if present
         if (domain!=null) {
             buf.append("; Domain=");
@@ -331,7 +331,7 @@ public class ServerCookie implements Ser
         if (isSecure) {
           buf.append ("; Secure");
         }
-        
+
         // HttpOnly
         if (isHttpOnly) {
             buf.append("; HttpOnly");
@@ -343,7 +343,7 @@ public class ServerCookie implements Ser
         if (value==null || value.length()==0) return false;
         return (value.charAt(0)=='\"' && value.charAt(value.length()-1)=='\"');
     }
-    
+
     /**
      * Quotes values using rules that vary depending on Cookie version.
      * @param version
@@ -361,7 +361,7 @@ public class ServerCookie implements Ser
     public static int maybeQuote2 (int version, StringBuffer buf, String value, String literals, boolean allowVersionSwitch) {
         if (value==null || value.length()==0) {
             buf.append("\"\"");
-        }else if (containsCTL(value,version)) 
+        }else if (containsCTL(value,version))
             throw new IllegalArgumentException("Control character in cookie value, consider BASE64 encoding your value");
         else if (alreadyQuoted(value)) {
             buf.append('"');
@@ -433,7 +433,7 @@ public class ServerCookie implements Ser
         int end = bc.getEnd();
         int dest = src;
         byte[] buffer = bc.array();
-        
+
         while (src < end) {
             if (buffer[src] == '\\' && src < end && buffer[src+1]  == '"') {
                 src++;
@@ -444,16 +444,16 @@ public class ServerCookie implements Ser
         }
         bc.setEnd(dest);
     }
-    
+
     /*
     List of Separator Characters (see isSeparator())
-    Excluding the '/' char violates the RFC, but 
+    Excluding the '/' char violates the RFC, but
     it looks like a lot of people put '/'
-    in unquoted values: '/': ; //47 
-    '\t':9 ' ':32 '\"':34 '\'':39 '(':40 ')':41 ',':44 ':':58 ';':59 '<':60 
+    in unquoted values: '/': ; //47
+    '\t':9 ' ':32 '\"':34 '\'':39 '(':40 ')':41 ',':44 ':':58 ';':59 '<':60
     '=':61 '>':62 '?':63 '@':64 '[':91 '\\':92 ']':93 '{':123 '}':125
     */
-    public static final char SEPARATORS[] = { '\t', ' ', '\"', '\'', '(', ')', ',', 
+    public static final char SEPARATORS[] = { '\t', ' ', '\"', '\'', '(', ')', ',',
         ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '{', '}' };
 
     protected static final boolean separators[] = new boolean[128];
@@ -471,7 +471,7 @@ public class ServerCookie implements Ser
     public  static void processCookies(List<ServerCookie> cookies,
             List<ServerCookie> cookiesCache,
             HttpMessage.HttpMessageBytes msgBytes ) {
-        
+
         // process each "cookie" header
         for (int i = 0; i < msgBytes.headerCount; i++) {
             if (msgBytes.getHeaderName(i).equalsIgnoreCase("Cookie")) {
@@ -483,12 +483,12 @@ public class ServerCookie implements Ser
                         bc.array(),
                         bc.getOffset(),
                         bc.getLength());
-                
+
             }
 
         }
     }
-    
+
     /**
      * Returns true if the byte is a separator character as
      * defined in RFC2619. Since this is called often, this
@@ -502,7 +502,7 @@ public class ServerCookie implements Ser
          else
              return false;
     }
-    
+
     /**
      * Returns true if the byte is a whitespace character as
      * defined in RFC2619
@@ -512,7 +512,7 @@ public class ServerCookie implements Ser
         // This switch statement is slightly slower
         // for my vm than the if statement.
         // Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
-        /* 
+        /*
         switch (c) {
         case ' ':;
         case '\t':;
@@ -557,9 +557,9 @@ public class ServerCookie implements Ser
             isQuoted = false;
 
             // Skip whitespace and non-token characters (separators)
-            while (pos < end && 
-                   (isSeparator(bytes[pos]) || isWhiteSpace(bytes[pos]))) 
-                {pos++; } 
+            while (pos < end &&
+                   (isSeparator(bytes[pos]) || isWhiteSpace(bytes[pos])))
+                {pos++; }
 
             if (pos >= end)
                 return;
@@ -570,24 +570,24 @@ public class ServerCookie implements Ser
                 pos++;
             }
 
-            // Get the cookie name. This must be a token            
-            valueEnd = valueStart = nameStart = pos; 
+            // Get the cookie name. This must be a token
+            valueEnd = valueStart = nameStart = pos;
             pos = nameEnd = getTokenEndPosition(bytes,pos,end);
 
             // Skip whitespace
-            while (pos < end && isWhiteSpace(bytes[pos])) {pos++; } 
-         
+            while (pos < end && isWhiteSpace(bytes[pos])) {pos++; }
+
 
             // Check for an '=' -- This could also be a name-only
             // cookie at the end of the cookie header, so if we
             // are past the end of the header, but we have a name
             // skip to the name-only part.
-            if (pos < end && bytes[pos] == '=') {                
+            if (pos < end && bytes[pos] == '=') {
 
                 // Skip whitespace
                 do {
                     pos++;
-                } while (pos < end && isWhiteSpace(bytes[pos])); 
+                } while (pos < end && isWhiteSpace(bytes[pos]));
 
                 if (pos >= end)
                     return;
@@ -598,15 +598,15 @@ public class ServerCookie implements Ser
                 case '"': // Quoted Value
                     isQuoted = true;
                     valueStart=pos + 1; // strip "
-                    // getQuotedValue returns the position before 
+                    // getQuotedValue returns the position before
                     // at the last qoute. This must be dealt with
                     // when the bytes are copied into the cookie
-                    valueEnd=getQuotedValueEndPosition(bytes, 
+                    valueEnd=getQuotedValueEndPosition(bytes,
                                                        valueStart, end);
                     // We need pos to advance
-                    pos = valueEnd; 
-                    // Handles cases where the quoted value is 
-                    // unterminated and at the end of the header, 
+                    pos = valueEnd;
+                    // Handles cases where the quoted value is
+                    // unterminated and at the end of the header,
                     // e.g. [myname="value]
                     if (pos >= end)
                         return;
@@ -632,15 +632,15 @@ public class ServerCookie implements Ser
                         // The starting character of the cookie value was
                         // not valid.
                         //log("Invalid cookie. Value not a token or quoted value");
-                        while (pos < end && bytes[pos] != ';' && 
-                               bytes[pos] != ',') 
+                        while (pos < end && bytes[pos] != ';' &&
+                               bytes[pos] != ',')
                             {pos++; }
                         pos++;
-                        // Make sure no special avpairs can be attributed to 
+                        // Make sure no special avpairs can be attributed to
                         // the previous cookie by setting the current cookie
                         // to null
                         sc = null;
-                        continue;                        
+                        continue;
                     }
                 }
             } else {
@@ -649,21 +649,21 @@ public class ServerCookie implements Ser
                 pos = nameEnd;
 
             }
-          
+
             // We should have an avpair or name-only cookie at this
             // point. Perform some basic checks to make sure we are
             // in a good state.
-  
+
             // Skip whitespace
             while (pos < end && isWhiteSpace(bytes[pos])) {pos++; }
 
 
             // Make sure that after the cookie we have a separator. This
             // is only important if this is not the last cookie pair
-            while (pos < end && bytes[pos] != ';' && bytes[pos] != ',') { 
+            while (pos < end && bytes[pos] != ';' && bytes[pos] != ',') {
                 pos++;
             }
-            
+
             pos++;
 
             /*
@@ -672,10 +672,10 @@ public class ServerCookie implements Ser
                 // of having two ';' characters in a row.
                 // log("Cookie name/value does not conform to RFC 2965");
                 // Advance to next delimiter (ignoring everything else)
-                while (pos < end && bytes[pos] != ';' && bytes[pos] != ',') 
+                while (pos < end && bytes[pos] != ';' && bytes[pos] != ',')
                     { pos++; };
                 pos++;
-                // Make sure no special cookies can be attributed to 
+                // Make sure no special cookies can be attributed to
                 // the previous cookie by setting the current cookie
                 // to null
                 sc = null;
@@ -683,13 +683,13 @@ public class ServerCookie implements Ser
             }
             */
 
-            // All checks passed. Add the cookie, start with the 
+            // All checks passed. Add the cookie, start with the
             // special avpairs first
             if (isSpecial) {
                 isSpecial = false;
                 // $Version must be the first avpair in the cookie header
                 // (sc must be null)
-                if (equals( "Version", bytes, nameStart, nameEnd) && 
+                if (equals( "Version", bytes, nameStart, nameEnd) &&
                     sc == null) {
                     // Set version
                     if( bytes[valueStart] =='1' && valueEnd == (valueStart+1)) {
@@ -698,8 +698,8 @@ public class ServerCookie implements Ser
                         // unknown version (Versioning is not very strict)
                     }
                     continue;
-                } 
-                
+                }
+
                 // We need an active cookie for Path/Port/etc.
                 if (sc == null) {
                     continue;
@@ -711,14 +711,14 @@ public class ServerCookie implements Ser
                                            valueStart,
                                            valueEnd-valueStart);
                     continue;
-                } 
+                }
 
                 if (equals( "Path", bytes, nameStart, nameEnd)) {
                     sc.getPath().setBytes( bytes,
                                            valueStart,
                                            valueEnd-valueStart);
                     continue;
-                } 
+                }
 
 
                 if (equals( "Port", bytes, nameStart, nameEnd)) {
@@ -727,13 +727,13 @@ public class ServerCookie implements Ser
                     //                        valueStart,
                     //                        valueEnd-valueStart );
                     continue;
-                } 
+                }
 
                 // Unknown cookie, complain
                 //log("Unknown Special Cookie");
 
             } else { // Normal Cookie
-                // use a previous value from cache, if any (to avoid GC - tomcat 
+                // use a previous value from cache, if any (to avoid GC - tomcat
                 // legacy )
                 if (cookiesCache.size() > cookies.size()) {
                     sc = cookiesCache.get(cookies.size());
@@ -746,7 +746,7 @@ public class ServerCookie implements Ser
                 sc.setVersion( version );
                 sc.getName().append( bytes, nameStart,
                                        nameEnd-nameStart);
-                
+
                 if (valueStart != -1) { // Normal AVPair
                     sc.getValue().append( bytes, valueStart,
                             valueEnd-valueStart);
@@ -757,7 +757,7 @@ public class ServerCookie implements Ser
                     }
                 } else {
                     // Name Only
-                    sc.getValue().recycle(); 
+                    sc.getValue().recycle();
                 }
                 sc.nameC.recycle();
                 sc.nameC.append(sc.getName());
@@ -774,13 +774,13 @@ public class ServerCookie implements Ser
     private static final int getTokenEndPosition(byte bytes[], int off, int end){
         int pos = off;
         while (pos < end && !isSeparator(bytes[pos])) {pos++; }
-        
+
         if (pos > end)
             return end;
         return pos;
     }
 
-    /** 
+    /**
      * Given a starting position after an initial quote chracter, this gets
      * the position of the end quote. This escapes anything after a '\' char
      * JVK RFC 2616
@@ -789,7 +789,7 @@ public class ServerCookie implements Ser
         int pos = off;
         while (pos < end) {
             if (bytes[pos] == '"') {
-                return pos;                
+                return pos;
             } else if (bytes[pos] == '\\' && pos < (end - 1)) {
                 pos+=2;
             } else {
@@ -799,8 +799,8 @@ public class ServerCookie implements Ser
         // Error, we have reached the end of the header w/o a end quote
         return end;
     }
-    
-    
+
+
     public static boolean equals( String s, byte b[], int start, int end) {
         int blen = end-start;
         if (b == null || blen != s.length()) {
@@ -814,6 +814,6 @@ public class ServerCookie implements Ser
         }
         return true;
     }
-    
+
 }
 



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