Made filtering work properly again.

This commit is contained in:
FrozenCow 2012-01-13 21:56:11 +01:00
parent 58f8a34b49
commit 502fbd5829
2 changed files with 13 additions and 18 deletions

View File

@ -424,10 +424,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false); final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false);
int maxconnections = configuration.getInteger("max-sessions", 30); int maxconnections = configuration.getInteger("max-sessions", 30);
if(maxconnections < 2) maxconnections = 2; if(maxconnections < 2) maxconnections = 2;
final ContextHandler context = new ContextHandler() {{ router = new HandlerRouter() {{
this.setContextPath("/");
this.setClassLoader(Thread.currentThread().getContextClassLoader());
this.setHandler(router = new HandlerRouter() {{
this.addHandler("/", new ResourceHandler() {{ this.addHandler("/", new ResourceHandler() {{
this.setAliases(allow_symlinks); this.setAliases(allow_symlinks);
this.setWelcomeFiles(new String[] { "index.html" }); this.setWelcomeFiles(new String[] { "index.html" });
@ -436,10 +433,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
}}); }});
this.addHandler("/tiles/", new ResourceHandler() {{ this.addHandler("/tiles/", new ResourceHandler() {{
this.setAliases(allow_symlinks); this.setAliases(allow_symlinks);
this.setWelcomeFiles(new String[] { });
this.setDirectoriesListed(true); this.setDirectoriesListed(true);
this.setBaseResource(createFileResource(tilesDirectory.toString())); this.setBaseResource(createFileResource(tilesDirectory.toString()));
}}); }});
}});
}}; }};
if(allow_symlinks) if(allow_symlinks)
@ -458,7 +455,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
/* Load customized response headers, if any */ /* Load customized response headers, if any */
filters.add(new CustomHeaderFilter(configuration.getNode("http-response-headers"))); filters.add(new CustomHeaderFilter(configuration.getNode("http-response-headers")));
webServer.setHandler(/*new FilterHandler(*/context/*, filters)*/); webServer.setHandler(new FilterHandler(router, filters));
addServlet("/up/configuration", new org.dynmap.servlet.ClientConfigurationServlet(this)); addServlet("/up/configuration", new org.dynmap.servlet.ClientConfigurationServlet(this));

View File

@ -49,7 +49,6 @@ public class FilterHandler extends AbstractHandler {
public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
final Handler handler = this.getHandler(); final Handler handler = this.getHandler();
final Iterator<FilterHolder> iterator = getFilters().iterator(); final Iterator<FilterHolder> iterator = getFilters().iterator();
Log.info("Filtering..." + request.getPathInfo());
final FilterChain chain = new FilterChain() { final FilterChain chain = new FilterChain() {
@Override @Override
public void doFilter(ServletRequest re, ServletResponse rs) throws IOException, ServletException { public void doFilter(ServletRequest re, ServletResponse rs) throws IOException, ServletException {
@ -57,7 +56,6 @@ public class FilterHandler extends AbstractHandler {
Filter f = iterator.next().getFilter(); Filter f = iterator.next().getFilter();
f.doFilter(request, response, this); f.doFilter(request, response, this);
} else { } else {
Log.info("Handling...");
handler.handle(target, baseRequest, request, response); handler.handle(target, baseRequest, request, response);
} }
} }