diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index 25f14c9713d..3dfa4d96a2c 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -28,6 +28,8 @@ import org.eclipse.jetty.deploy.bindings.DebugListenerBinding; import org.eclipse.jetty.deploy.providers.WebAppProvider; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.jmx.MBeanContainer; +import org.eclipse.jetty.rewrite.handler.CompactPathRule; +import org.eclipse.jetty.rewrite.handler.RewriteHandler; import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.server.ConnectorStatistics; import org.eclipse.jetty.server.DebugListener; @@ -63,11 +65,17 @@ public class LikeJettyXml // Find jetty home and base directories String homePath = System.getProperty("jetty.home", jettyHomeBuild); - File homeDir = new File(homePath); - if (!homeDir.exists()) + File start_jar = new File(homePath,"start.jar"); + if (!start_jar.exists()) { - throw new FileNotFoundException(homeDir.getAbsolutePath()); + homePath = jettyHomeBuild = "jetty-distribution/target/distribution"; + start_jar = new File(homePath,"start.jar"); + if (!start_jar.exists()) + throw new FileNotFoundException(start_jar.toString()); } + + File homeDir = new File(homePath); + String basePath = System.getProperty("jetty.base", homeDir + "/demo-base"); File baseDir = new File(basePath); if(!baseDir.exists()) @@ -188,6 +196,10 @@ public class LikeJettyXml server.setHandler(stats); ConnectorStatistics.addToAllConnectors(server); + // === Rewrite Handler + RewriteHandler rewrite = new RewriteHandler(); + rewrite.setHandler(server.getHandler()); + server.setHandler(rewrite); // === jetty-requestlog.xml === NCSARequestLog requestLog = new NCSARequestLog(); diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java index 1db6be5a7f3..69526ca9c57 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java @@ -161,9 +161,6 @@ public class RuleContainer extends Rule { boolean original_set=_originalPathAttribute==null; - // TODO why is this always done? - target = URIUtil.compactPath(target); - if (_rules==null) return target; @@ -172,9 +169,6 @@ public class RuleContainer extends Rule String applied=rule.matchAndApply(target,request, response); if (applied!=null) { - // TODO why is this always done? - applied = URIUtil.compactPath(applied); - LOG.debug("applied {}",rule); LOG.debug("rewrote {} to {}",target,applied); if (!original_set)