costin 01/05/01 14:27:36
Modified: src/share/org/apache/tomcat/util Tag: tomcat_32
PrefixMapper.java
Log:
Fix for case sensitive host lookup: the hostname is insensitive.
We use a small trick to avoid string creation in the common case
( domain names are lower case most of the time, so we use lower case )
The fix is backported from 3.3
Revision Changes Path
No revision
No revision
1.3.2.3 +12 -5
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.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- PrefixMapper.java 2001/01/12 18:04:20 1.3.2.2
+++ PrefixMapper.java 2001/05/01 21:27:35 1.3.2.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.3.2.2
2001/01/12 18:04:20 larryi Exp $
- * $Revision: 1.3.2.2 $
- * $Date: 2001/01/12 18:04:20 $
+ * $Header:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/PrefixMapper.java,v 1.3.2.3
2001/05/01 21:27:35 costin Exp $
+ * $Revision: 1.3.2.3 $
+ * $Date: 2001/05/01 21:27:35 $
*
* ====================================================================
*
@@ -76,7 +76,7 @@
* XXX make sure the code is useable as a general path mapper - or at least a
bridge
* can be created between SimpleMapper and a patern matcher like the one in XPath
*
- * @author [EMAIL PROTECTED]
+ * @author Costin Manolache
*/
public class PrefixMapper {
// host -> PrefixMapper for virtual hosts
@@ -123,6 +123,7 @@
public void removeAllMappings( String host, String path ) {
PrefixMapper vmap=this;
if( host!=null ) {
+ host=host.toLowerCase();
vmap=(PrefixMapper)vhostMaps.get(host);
}
@@ -163,6 +164,7 @@
if( host == null )
prefixMappedServlets.put( path, target);
else {
+ host=host.toLowerCasse();
PrefixMapper vmap=(PrefixMapper)vhostMaps.get( host );
if( vmap == null ) {
vmap=new PrefixMapper();
@@ -179,6 +181,7 @@
if( host==null )
exactMappedServlets.put( path, target);
else {
+ host=host.toLowerCase();
PrefixMapper vmap=(PrefixMapper)vhostMaps.get( host );
if( vmap == null ) {
vmap=new PrefixMapper();
@@ -198,8 +201,12 @@
String s = path;
PrefixMapper myMap=null;
- if( host!=null )
+ if( host!=null ) {
myMap=(PrefixMapper)vhostMaps.get( host );
+ if( myMap==null ) {
+ myMap=(PrefixMapper)vhostMaps.get( host.toLowerCase() );
+ }
+ }
if( myMap==null ) myMap = this; // default server