costin 01/02/19 19:14:12 Modified: src/share/org/apache/tomcat/util FastDateFormat.java PrefixMapper.java src/share/org/apache/tomcat/util/collections MultiMap.java MultiMapNamesEnumeration.java MultiMapValuesEnumeration.java src/share/org/apache/tomcat/util/hooks Hooks.java src/share/org/apache/tomcat/util/http AcceptLanguage.java ContentType.java Cookies.java HttpMessages.java Parameters.java ServerCookie.java src/share/org/apache/tomcat/util/log Log.java src/share/org/apache/tomcat/util/net PoolTcpEndpoint.java src/share/org/apache/tomcat/util/test HttpRequest.java src/share/org/apache/tomcat/util/threads TimeStamp.java Added: src/share/org/apache/tomcat/util/collections LRUCache.java src/share/org/apache/tomcat/util/http MimeHeaders.java MimeMap.java Removed: src/share/org/apache/tomcat/util Ascii.java Base64.java ByteChunk.java CharChunk.java DateTool.java FileUtil.java HexUtils.java LRUCache.java MessageBytes.java MimeHeaders.java MimeMap.java RecycleBufferedInputStream.java StringManager.java src/share/org/apache/tomcat/util/http Headers.java Log: Package move. No code change - only import statements ( to match the new packages and to import only what's used ) Revision Changes Path 1.2 +2 -0 jakarta-tomcat/src/share/org/apache/tomcat/util/FastDateFormat.java Index: FastDateFormat.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/FastDateFormat.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FastDateFormat.java 2000/07/11 03:01:57 1.1 +++ FastDateFormat.java 2001/02/20 03:14:09 1.2 @@ -125,6 +125,7 @@ return toAppendTo; } + /* public static void main(String[] args) { String format = "yyyy-MM-dd HH:mm:ss.SSS"; if (args.length > 0) @@ -165,4 +166,5 @@ System.out.println(sdf.format(d)); } } + */ } 1.8 +5 -3 jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java Index: PrefixMapper.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- PrefixMapper.java 2001/01/14 20:39:12 1.7 +++ PrefixMapper.java 2001/02/20 03:14:10 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.7 2001/01/14 20:39:12 larryi Exp $ - * $Revision: 1.7 $ - * $Date: 2001/01/14 20:39:12 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.8 2001/02/20 03:14:10 costin Exp $ + * $Revision: 1.8 $ + * $Date: 2001/02/20 03:14:10 $ * * ==================================================================== * @@ -65,6 +65,8 @@ package org.apache.tomcat.util; import org.apache.tomcat.util.collections.*; +import org.apache.tomcat.util.buf.*; +import org.apache.tomcat.util.io.FileUtil; import java.net.URL; import java.io.File; 1.3 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMap.java Index: MultiMap.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMap.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MultiMap.java 2000/12/02 08:26:53 1.2 +++ MultiMap.java 2001/02/20 03:14:10 1.3 @@ -59,7 +59,7 @@ package org.apache.tomcat.util.collections; -import org.apache.tomcat.util.MessageBytes; +import org.apache.tomcat.util.buf.MessageBytes; import java.io.*; import java.util.*; import java.text.*; 1.2 +1 -2 jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java Index: MultiMapNamesEnumeration.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMapNamesEnumeration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MultiMapNamesEnumeration.java 2000/12/07 18:34:53 1.1 +++ MultiMapNamesEnumeration.java 2001/02/20 03:14:10 1.2 @@ -59,8 +59,7 @@ package org.apache.tomcat.util.collections; -import org.apache.tomcat.util.collections.*; -import org.apache.tomcat.util.MessageBytes; +import org.apache.tomcat.util.buf.MessageBytes; import java.io.*; import java.util.*; 1.2 +1 -2 jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMapValuesEnumeration.java Index: MultiMapValuesEnumeration.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/MultiMapValuesEnumeration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MultiMapValuesEnumeration.java 2000/12/07 18:34:53 1.1 +++ MultiMapValuesEnumeration.java 2001/02/20 03:14:10 1.2 @@ -59,8 +59,7 @@ package org.apache.tomcat.util.collections; -import org.apache.tomcat.util.collections.*; -import org.apache.tomcat.util.MessageBytes; +import org.apache.tomcat.util.buf.MessageBytes; import java.io.*; import java.util.*; 1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/collections/LRUCache.java Index: LRUCache.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/collections/LRUCache.java,v 1.1 2001/02/20 03:14:10 costin Exp $ * $Revision: 1.1 $ * $Date: 2001/02/20 03:14:10 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.collections; import java.util.Hashtable; /** * This class implements a Generic LRU Cache * * * @author Ignacio J. Ortega * */ public class LRUCache { class CacheNode { CacheNode prev; CacheNode next; Object value; Object key; CacheNode() { } } public LRUCache(int i) { currentSize = 0; cacheSize = i; } public Object get(Object key) { if(nodes == null) return null; CacheNode node = (CacheNode)nodes.get(key); if(node != null) { moveToHead(node); return node.value; } else { return null; } } public void put(Object key, Object value) { if(nodes == null) nodes = new Hashtable(cacheSize); CacheNode node = (CacheNode)nodes.get(key); if(node == null) { if(currentSize >= cacheSize) { if(last != null) nodes.remove(last.key); removeLast(); } else { currentSize++; } node = new CacheNode(); } node.value = value; node.key = key; moveToHead(node); nodes.put(key, node); } public void clear() { if(nodes != null) nodes.clear(); first = null; last = null; } private void removeLast() { if(last != null) { if(last.prev != null) last.prev.next = null; else first = null; last = last.prev; } } private void moveToHead(CacheNode node) { if(node == first) return; if(node.prev != null) node.prev.next = node.next; if(node.next != null) node.next.prev = node.prev; if(last == node) last = node.prev; if(first != null) { node.next = first; first.prev = node; } first = node; node.prev = null; if(last == null) last = first; } private int cacheSize; private Hashtable nodes; private int currentSize; private CacheNode first; private CacheNode last; } 1.4 +0 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/hooks/Hooks.java Index: Hooks.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/hooks/Hooks.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Hooks.java 2001/01/01 00:17:24 1.3 +++ Hooks.java 2001/02/20 03:14:11 1.4 @@ -59,7 +59,6 @@ package org.apache.tomcat.util.hooks; -import org.apache.tomcat.util.*; import java.io.*; import java.net.*; import java.util.*; 1.3 +0 -2 jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java Index: AcceptLanguage.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/AcceptLanguage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AcceptLanguage.java 2001/01/20 21:44:39 1.2 +++ AcceptLanguage.java 2001/02/20 03:14:11 1.3 @@ -59,8 +59,6 @@ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.*; - import java.io.*; import java.net.*; import java.util.*; 1.3 +0 -2 jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java Index: ContentType.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ContentType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ContentType.java 2001/01/20 21:44:39 1.2 +++ ContentType.java 2001/02/20 03:14:11 1.3 @@ -59,8 +59,6 @@ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.*; - import java.io.*; import java.net.*; import java.util.*; 1.7 +3 -5 jakarta-tomcat/src/share/org/apache/tomcat/util/http/Cookies.java Index: Cookies.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Cookies.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Cookies.java 2000/12/07 18:34:53 1.6 +++ Cookies.java 2001/02/20 03:14:11 1.7 @@ -59,11 +59,9 @@ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.collections.*; -import org.apache.tomcat.util.MessageBytes; -import org.apache.tomcat.util.ByteChunk; -import org.apache.tomcat.util.MimeHeaders; -import org.apache.tomcat.util.DateTool; +import org.apache.tomcat.util.buf.MessageBytes; +import org.apache.tomcat.util.buf.CharChunk; +import org.apache.tomcat.util.buf.ByteChunk; import java.io.*; import java.util.*; 1.2 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/http/HttpMessages.java Index: HttpMessages.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/HttpMessages.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HttpMessages.java 2000/12/30 07:54:18 1.1 +++ HttpMessages.java 2001/02/20 03:14:11 1.2 @@ -59,7 +59,7 @@ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.StringManager; +import org.apache.tomcat.util.res.StringManager; import java.io.*; import java.net.*; 1.11 +4 -2 jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java Index: Parameters.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/Parameters.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Parameters.java 2001/02/10 23:28:17 1.10 +++ Parameters.java 2001/02/20 03:14:11 1.11 @@ -59,8 +59,10 @@ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.*; -import org.apache.tomcat.util.collections.*; +import org.apache.tomcat.util.buf.MessageBytes; +import org.apache.tomcat.util.buf.CharChunk; +import org.apache.tomcat.util.buf.ByteChunk; +import org.apache.tomcat.util.collections.MultiMap; import java.io.*; import java.util.*; import java.text.*; 1.8 +2 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java Index: ServerCookie.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/http/ServerCookie.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ServerCookie.java 2001/02/02 05:46:45 1.7 +++ ServerCookie.java 2001/02/20 03:14:11 1.8 @@ -55,7 +55,8 @@ */ package org.apache.tomcat.util.http; -import org.apache.tomcat.util.*; +import org.apache.tomcat.util.buf.MessageBytes; +import org.apache.tomcat.util.buf.DateTool; import java.text.*; import java.io.*; import java.util.*; 1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/http/MimeHeaders.java Index: MimeHeaders.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.http; import org.apache.tomcat.util.buf.MessageBytes; import java.io.*; import java.util.*; import java.text.*; /* XXX XXX XXX Need a major rewrite !!!! */ /** * This class is used to contain standard internet message headers, * used for SMTP (RFC822) and HTTP (RFC2068) messages as well as for * MIME (RFC 2045) applications such as transferring typed data and * grouping related items in multipart message bodies. * * <P> Message headers, as specified in RFC822, include a field name * and a field body. Order has no semantic significance, and several * fields with the same name may exist. However, most fields do not * (and should not) exist more than once in a header. * * <P> Many kinds of field body must conform to a specified syntax, * including the standard parenthesized comment syntax. This class * supports only two simple syntaxes, for dates and integers. * * <P> When processing headers, care must be taken to handle the case of * multiple same-name fields correctly. The values of such fields are * only available as strings. They may be accessed by index (treating * the header as an array of fields), or by name (returning an array * of string values). */ /* Headers are first parsed and stored in the order they are received. This is based on the fact that most servlets will not directly access all headers, and most headers are single-valued. ( the alternative - a hash or similar data structure - will add an overhead that is not needed in most cases ) Apache seems to be using a similar method for storing and manipulating headers. Future enhancements: - hash the headers the first time a header is requested ( i.e. if the servlet needs direct access to headers). - scan "common" values ( length, cookies, etc ) during the parse ( addHeader hook ) */ /** * Memory-efficient repository for Mime Headers. When the object is recycled, it * will keep the allocated headers[] and all the MimeHeaderField - no GC is generated. * * For input headers it is possible to use the MessageByte for Fileds - so no GC * will be generated. * * The only garbage is generated when using the String for header names/values - * this can't be avoided when the servlet calls header methods, but is easy * to avoid inside tomcat. The goal is to use _only_ MessageByte-based Fields, * and reduce to 0 the memory overhead of tomcat. * * TODO: * XXX one-buffer parsing - for http ( other protocols don't need that ) * XXX remove unused methods * XXX External enumerations, with 0 GC. * XXX use HeaderName ID * * * @author [EMAIL PROTECTED] * @author James Todd [[EMAIL PROTECTED]] * @author Costin Manolache */ public class MimeHeaders { /** Initial size - should be == average number of headers per request * XXX make it configurable ( fine-tuning of web-apps ) */ public static final int DEFAULT_HEADER_SIZE=8; /** * The header fields. */ private MimeHeaderField[] headers = new MimeHeaderField[DEFAULT_HEADER_SIZE]; /** * The current number of header fields. */ private int count; /** * Creates a new MimeHeaders object using a default buffer size. */ public MimeHeaders() { } /** * Clears all header fields. */ public void clear() { for (int i = 0; i < count; i++) { headers[i].recycle(); } count = 0; } // -------------------- Idx access to headers ---------- /** * Returns the current number of header fields. */ public int size() { return count; } /** * Returns the Nth header name, or null if there is no such header. * This may be used to iterate through all header fields. */ public MessageBytes getName(int n) { return n >= 0 && n < count ? headers[n].getName() : null; } /** * Returns the Nth header value, or null if there is no such header. * This may be used to iterate through all header fields. */ public MessageBytes getValue(int n) { return n >= 0 && n < count ? headers[n].getValue() : null; } /** Find the index of a header with the given name. */ public int findHeader( String name, int starting ) { // We can use a hash - but it's not clear how much // benefit you can get - there is an overhead // and the number of headers is small (4-5 ?) // Another problem is that we'll pay the overhead // of constructing the hashtable // A custom search tree may be better for (int i = starting; i < count; i++) { if (headers[i].getName().equalsIgnoreCase(name)) { return i; } } return -1; } // -------------------- -------------------- /** * Returns an enumeration of strings representing the header field names. * Field names may appear multiple times in this enumeration, indicating * that multiple fields with that name exist in this header. */ public Enumeration names() { return new NamesEnumerator(this); } public Enumeration values(String name) { return new ValuesEnumerator(this, name); } // -------------------- Adding headers -------------------- /** * Adds a partially constructed field to the header. This * field has not had its name or value initialized. */ private MimeHeaderField createHeader() { MimeHeaderField mh; int len = headers.length; if (count >= len) { // expand header list array MimeHeaderField tmp[] = new MimeHeaderField[count * 2]; System.arraycopy(headers, 0, tmp, 0, len); headers = tmp; } if ((mh = headers[count]) == null) { headers[count] = mh = new MimeHeaderField(); } count++; return mh; } /** Create a new named header , return the MessageBytes container for the new value */ public MessageBytes addValue( String name ) { MimeHeaderField mh = createHeader(); mh.getName().setString(name); return mh.getValue(); } /** Create a new named header using un-translated byte[]. The conversion to chars can be delayed until encoding is known. */ public MessageBytes addValue(byte b[], int startN, int endN) { MimeHeaderField mhf=createHeader(); mhf.getName().setBytes(b, startN, endN); return mhf.getValue(); } /** Allow "set" operations - return a MessageBytes container for the header value ( existing header or new if this . */ public MessageBytes setValue( String name ) { MessageBytes value=getValue(name); if( value == null ) { MimeHeaderField mh = createHeader(); mh.getName().setString(name); value=mh.getValue(); } return value; } //-------------------- Getting headers -------------------- /** * 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 * in the header, an arbitrary one is returned. */ public MessageBytes getValue(String name) { for (int i = 0; i < count; i++) { if (headers[i].getName().equalsIgnoreCase(name)) { return headers[i].getValue(); } } return null; } // bad shortcut - it'll convert to string ( too early probably, // encoding is guessed very late ) public String getHeader(String name) { MessageBytes mh = getValue(name); return mh != null ? mh.toString() : null; } // -------------------- Removing -------------------- /** * Removes a header field with the specified name. Does nothing * if such a field could not be found. * @param name the name of the header field to be removed */ public void removeHeader(String name) { // XXX // warning: rather sticky code; heavily tuned for (int i = 0; i < count; i++) { if (headers[i].getName().equalsIgnoreCase(name)) { // reset and swap with last header MimeHeaderField mh = headers[i]; mh.recycle(); headers[i] = headers[count - 1]; headers[count - 1] = mh; count--; i--; } } } } /** Enumerate the distinct header names. Each nextElement() is O(n) ( a comparation is done with all previous elements ). This is less frequesnt than add() - we want to keep add O(1). */ class NamesEnumerator implements Enumeration { int pos; int size; String next; MimeHeaders headers; NamesEnumerator(MimeHeaders headers) { this.headers=headers; pos=0; size = headers.size(); findNext(); } private void findNext() { next=null; for( ; pos< size; pos++ ) { next=headers.getName( pos ).toString(); for( int j=0; j<pos ; j++ ) { if( headers.getName( j ).equalsIgnoreCase( next )) { // duplicate. next=null; break; } } if( next!=null ) { // it's not a duplicate break; } } // next time findNext is called it will try the // next element pos++; } public boolean hasMoreElements() { return next!=null; } public Object nextElement() { String current=next; findNext(); return current; } } /** Enumerate the values for a (possibly ) multiple value element. */ class ValuesEnumerator implements Enumeration { int pos; int size; MessageBytes next; MimeHeaders headers; String name; ValuesEnumerator(MimeHeaders headers, String name) { this.name=name; this.headers=headers; pos=0; size = headers.size(); findNext(); } private void findNext() { next=null; for( ; pos< size; pos++ ) { MessageBytes n1=headers.getName( pos ); if( n1.equalsIgnoreCase( name )) { next=headers.getValue( pos ); break; } } pos++; } public boolean hasMoreElements() { return next!=null; } public Object nextElement() { MessageBytes current=next; findNext(); return current.toString(); } } class MimeHeaderField { // multiple headers with same name - a linked list will // speed up name enumerations and search ( both cpu and // GC) MimeHeaderField next; MimeHeaderField prev; protected final MessageBytes nameB = new MessageBytes(); protected final MessageBytes valueB = new MessageBytes(); /** * Creates a new, uninitialized header field. */ public MimeHeaderField() { } public void recycle() { nameB.recycle(); valueB.recycle(); next=null; } public MessageBytes getName() { return nameB; } public MessageBytes getValue() { return valueB; } } 1.1 jakarta-tomcat/src/share/org/apache/tomcat/util/http/MimeMap.java Index: MimeMap.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.tomcat.util.http; import java.net.*; import java.util.*; /** * A mime type map that implements the java.net.FileNameMap interface. * * @author James Duncan Davidson [[EMAIL PROTECTED]] * @author Jason Hunter [[EMAIL PROTECTED]] */ public class MimeMap implements FileNameMap { // Defaults - all of them are "well-known" types, // you can add using normal web.xml. public static Hashtable defaultMap=new Hashtable(101); static { defaultMap.put("txt", "text/plain"); defaultMap.put("html","text/html"); defaultMap.put("htm", "text/html"); defaultMap.put("gif", "image/gif"); defaultMap.put("jpg", "image/jpeg"); defaultMap.put("jpe", "image/jpeg"); defaultMap.put("jpeg", "image/jpeg"); defaultMap.put("java", "text/plain"); defaultMap.put("body", "text/html"); defaultMap.put("rtx", "text/richtext"); defaultMap.put("tsv", "text/tab-separated-values"); defaultMap.put("etx", "text/x-setext"); defaultMap.put("ps", "application/x-postscript"); defaultMap.put("class", "application/java"); defaultMap.put("csh", "application/x-csh"); defaultMap.put("sh", "application/x-sh"); defaultMap.put("tcl", "application/x-tcl"); defaultMap.put("tex", "application/x-tex"); defaultMap.put("texinfo", "application/x-texinfo"); defaultMap.put("texi", "application/x-texinfo"); defaultMap.put("t", "application/x-troff"); defaultMap.put("tr", "application/x-troff"); defaultMap.put("roff", "application/x-troff"); defaultMap.put("man", "application/x-troff-man"); defaultMap.put("me", "application/x-troff-me"); defaultMap.put("ms", "application/x-wais-source"); defaultMap.put("src", "application/x-wais-source"); defaultMap.put("zip", "application/zip"); defaultMap.put("bcpio", "application/x-bcpio"); defaultMap.put("cpio", "application/x-cpio"); defaultMap.put("gtar", "application/x-gtar"); defaultMap.put("shar", "application/x-shar"); defaultMap.put("sv4cpio", "application/x-sv4cpio"); defaultMap.put("sv4crc", "application/x-sv4crc"); defaultMap.put("tar", "application/x-tar"); defaultMap.put("ustar", "application/x-ustar"); defaultMap.put("dvi", "application/x-dvi"); defaultMap.put("hdf", "application/x-hdf"); defaultMap.put("latex", "application/x-latex"); defaultMap.put("bin", "application/octet-stream"); defaultMap.put("oda", "application/oda"); defaultMap.put("pdf", "application/pdf"); defaultMap.put("ps", "application/postscript"); defaultMap.put("eps", "application/postscript"); defaultMap.put("ai", "application/postscript"); defaultMap.put("rtf", "application/rtf"); defaultMap.put("nc", "application/x-netcdf"); defaultMap.put("cdf", "application/x-netcdf"); defaultMap.put("cer", "application/x-x509-ca-cert"); defaultMap.put("exe", "application/octet-stream"); defaultMap.put("gz", "application/x-gzip"); defaultMap.put("Z", "application/x-compress"); defaultMap.put("z", "application/x-compress"); defaultMap.put("hqx", "application/mac-binhex40"); defaultMap.put("mif", "application/x-mif"); defaultMap.put("ief", "image/ief"); defaultMap.put("tiff", "image/tiff"); defaultMap.put("tif", "image/tiff"); defaultMap.put("ras", "image/x-cmu-raster"); defaultMap.put("pnm", "image/x-portable-anymap"); defaultMap.put("pbm", "image/x-portable-bitmap"); defaultMap.put("pgm", "image/x-portable-graymap"); defaultMap.put("ppm", "image/x-portable-pixmap"); defaultMap.put("rgb", "image/x-rgb"); defaultMap.put("xbm", "image/x-xbitmap"); defaultMap.put("xpm", "image/x-xpixmap"); defaultMap.put("xwd", "image/x-xwindowdump"); defaultMap.put("au", "audio/basic"); defaultMap.put("snd", "audio/basic"); defaultMap.put("aif", "audio/x-aiff"); defaultMap.put("aiff", "audio/x-aiff"); defaultMap.put("aifc", "audio/x-aiff"); defaultMap.put("wav", "audio/x-wav"); defaultMap.put("mpeg", "video/mpeg"); defaultMap.put("mpg", "video/mpeg"); defaultMap.put("mpe", "video/mpeg"); defaultMap.put("qt", "video/quicktime"); defaultMap.put("mov", "video/quicktime"); defaultMap.put("avi", "video/x-msvideo"); defaultMap.put("movie", "video/x-sgi-movie"); defaultMap.put("avx", "video/x-rad-screenplay"); defaultMap.put("wrl", "x-world/x-vrml"); defaultMap.put("mpv2", "video/mpeg2"); } private Hashtable map = new Hashtable(); public void addContentType(String extn, String type) { map.put(extn, type.toLowerCase()); } public Enumeration getExtensions() { return map.keys(); } public String getContentType(String extn) { String type = (String)map.get(extn.toLowerCase()); if( type == null ) type=(String)defaultMap.get( extn ); return type; } public void removeContentType(String extn) { map.remove(extn.toLowerCase()); } /** Get extension of file, without fragment id */ public static String getExtension( String fileName ) { // play it safe and get rid of any fragment id // that might be there int length=fileName.length(); int newEnd = fileName.lastIndexOf('#'); if( newEnd== -1 ) newEnd=length; // Instead of creating a new string. // if (i != -1) { // fileName = fileName.substring(0, i); // } int i = fileName.lastIndexOf('.', newEnd ); if (i != -1) { return fileName.substring(i + 1, newEnd ); } else { // no extension, no content type return null; } } public String getContentTypeFor(String fileName) { String extn=getExtension( fileName ); if (extn!=null) { return getContentType(extn); } else { // no extension, no content type return null; } } } 1.4 +6 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/log/Log.java Index: Log.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/log/Log.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Log.java 2001/02/19 19:49:47 1.3 +++ Log.java 2001/02/20 03:14:12 1.4 @@ -106,7 +106,7 @@ public static final int INFORMATION = 3; public static final int DEBUG = 4; - + // name of the logger ( each logger has a unique name, // used as a key internally ) private String logname; @@ -221,6 +221,11 @@ public void flush() { if( logger!=null ) logger.flush(); + } + + public int getLevel() { + if( logger==null ) return Log.DEBUG; + return logger.getVerbosityLevel(); } // -------------------- Extra configuration stuff -------------------- 1.8 +4 -4 jakarta-tomcat/src/share/org/apache/tomcat/util/net/PoolTcpEndpoint.java Index: PoolTcpEndpoint.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- PoolTcpEndpoint.java 2001/02/17 07:09:02 1.7 +++ PoolTcpEndpoint.java 2001/02/20 03:14:12 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v 1.7 2001/02/17 07:09:02 costin Exp $ - * $Revision: 1.7 $ - * $Date: 2001/02/17 07:09:02 $ + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v 1.8 2001/02/20 03:14:12 costin Exp $ + * $Revision: 1.8 $ + * $Date: 2001/02/20 03:14:12 $ * * ==================================================================== * @@ -64,7 +64,7 @@ package org.apache.tomcat.util.net; -import org.apache.tomcat.util.*; +import org.apache.tomcat.util.res.*; import org.apache.tomcat.util.collections.SimplePool; import org.apache.tomcat.util.threads.*; import org.apache.tomcat.util.log.*; 1.3 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/test/HttpRequest.java Index: HttpRequest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/test/HttpRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HttpRequest.java 2001/02/10 19:17:29 1.2 +++ HttpRequest.java 2001/02/20 03:14:12 1.3 @@ -63,7 +63,7 @@ import java.util.*; import java.net.*; -import org.apache.tomcat.util.Base64; +import org.apache.tomcat.util.buf.Base64; /** * Part of GTest - defines a Http request. This tool gives a lot 1.3 +1 -1 jakarta-tomcat/src/share/org/apache/tomcat/util/threads/TimeStamp.java Index: TimeStamp.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/threads/TimeStamp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TimeStamp.java 2000/11/22 00:10:00 1.2 +++ TimeStamp.java 2001/02/20 03:14:12 1.3 @@ -58,7 +58,7 @@ */ package org.apache.tomcat.util.threads; -import org.apache.tomcat.util.MessageBytes; +import org.apache.tomcat.util.buf.MessageBytes; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]