costin 01/08/06 08:42:36
Modified: src/share/org/apache/tomcat/modules/config
ContextXmlReader.java
Log:
Added missing support for
<Host name="foo">
<Alias name="bar" />
<... >
<Context ... >
This will call ctx.addHostAlias(). Thanks to Larry and Chris for finding this,
I hope it's enough to get the "host wildcard" patch back on track.
I agree with Larry, the "main" host name can't be wildcard, it's also used to
construct the reply ( for example for redirects and to recreate the url ).
Revision Changes Path
1.8 +27 -4
jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ContextXmlReader.java
Index: ContextXmlReader.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/ContextXmlReader.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ContextXmlReader.java 2001/03/08 01:09:50 1.7
+++ ContextXmlReader.java 2001/08/06 15:42:36 1.8
@@ -154,14 +154,37 @@
// Virtual host support - if Context is inside a <Host>
xh.addRule( "Host", xh.setVar( "current_host", "name"));
xh.addRule( "Host", xh.setProperties());
+ xh.addRule( "Alias", new XmlAction() {
+ public void start( SaxContext xctx) throws Exception {
+ Vector aliases=(Vector)xctx.getVariable( "host_aliases" );
+ if( aliases==null ) {
+ aliases=new Vector();
+ xctx.setVariable( "host_aliases", aliases );
+ }
+ String alias=(String)xctx.getCurrentAttributes().getValue("name");
+ if( alias!=null )
+ aliases.addElement( alias );
+ }
+ });
xh.addRule( "Context", new XmlAction() {
- public void end( SaxContext ctx) throws Exception {
- Context tcCtx=(Context)ctx.currentObject();
- String host=(String)ctx.getVariable("current_host");
+ public void end( SaxContext xctx) throws Exception {
+ Context tcCtx=(Context)xctx.currentObject();
+ String host=(String)xctx.getVariable("current_host");
+ Vector aliases=(Vector)xctx.getVariable( "host_aliases" );
- if( host!=null && ! "DEFAULT".equals( host ))
+ if( host!=null && ! "DEFAULT".equals( host )) {
tcCtx.setHost( host );
+ if( aliases!=null ) {
+ Enumeration alE=aliases.elements();
+ while( alE.hasMoreElements() ) {
+ String alias=(String)alE.nextElement();
+ tcCtx.addHostAlias( alias );
+ if( tcCtx.getDebug() > 0 )
+ tcCtx.log( "Alias " + host + " " + alias );
+ }
+ }
+ }
}
});