From: Fredrik Tolf Date: Thu, 29 Oct 2009 03:56:23 +0000 (+0100) Subject: Merge branch 'master' of git.dolda2000.com:/srv/git/r/jsvc X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=commitdiff_plain;h=23440c2f2a49aebc65dad176516887464876f3e5;hp=123ab71b482616cb75f7b22c9d299f340d6a1a82 Merge branch 'master' of git.dolda2000.com:/srv/git/r/jsvc --- diff --git a/samples/bsh/src/dolda/bsvc/Main.java b/samples/bsh/src/dolda/bsvc/Main.java index d6a83d2..9deae0e 100644 --- a/samples/bsh/src/dolda/bsvc/Main.java +++ b/samples/bsh/src/dolda/bsvc/Main.java @@ -7,7 +7,7 @@ public class Main { public static Responder responder() { Multiplexer root = new Multiplexer(); root.file("sh", new PerSession(ShellPage.class)); - root.file("css", new StaticContent(Main.class, "static/base.css", false, "text/css")); + root.file("css", new StaticContent(Main.class, "static/base.css", "text/css")); return(Misc.stdroot(root)); } } diff --git a/src/dolda/jsvc/util/StaticContent.java b/src/dolda/jsvc/util/StaticContent.java index 685669c..6d74e37 100644 --- a/src/dolda/jsvc/util/StaticContent.java +++ b/src/dolda/jsvc/util/StaticContent.java @@ -10,24 +10,22 @@ public class StaticContent implements Responder { private final boolean dir; private final String mimetype; - public StaticContent(Class base, String resname, boolean dir, String mimetype) { + public StaticContent(Class base, String resname, String mimetype) { this.base = base; - this.resname = resname; - this.dir = dir; + this.dir = ((this.resname = resname).charAt(resname.length() - 1) == '/'); this.mimetype = mimetype; } - public StaticContent(String resname, boolean dir, String mimetype) { - this(null, resname, dir, mimetype); + public StaticContent(String resname, String mimetype) { + this(null, resname, mimetype); } public void respond(Request req) { String nm; - if(dir) { - nm = resname + "/" + req.path(); - } else { + if(dir) + nm = resname + req.path(); + else nm = resname; - } InputStream in; if(base == null) { in = StaticContent.class.getClassLoader().getResourceAsStream(nm);