X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Futil%2FStaticContent.java;h=0ef227da8422e46a35e8fa667884516f4760b681;hb=4126b9f4cd5367a198678f08508880b4a38aad1f;hp=685669c09df6077c9df55a8a91793e15c68e6511;hpb=60ef28853e4aca8b227f533c4b95c03de6574e02;p=jsvc.git diff --git a/src/dolda/jsvc/util/StaticContent.java b/src/dolda/jsvc/util/StaticContent.java index 685669c..0ef227d 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); @@ -35,7 +33,7 @@ public class StaticContent implements Responder { in = base.getResourceAsStream(nm); } if(in == null) - throw(Restarts.stdresponse(404)); + throw(new StdResponse(404)); Cache.checkmtime(req, req.ctx().starttime()); try { try {