X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Futil%2FMisc.java;h=e92b3240270fc4674be6481dc77e04585a64300a;hb=7779099a6c15508f2dd214a7555c66a27f8343ed;hp=c3131834600c98a81e2ab7a34b26587e2eb883ca;hpb=78f5d1201f8d3aecb660b7877b08d9bfbe650911;p=jsvc.git diff --git a/src/dolda/jsvc/util/Misc.java b/src/dolda/jsvc/util/Misc.java index c313183..e92b324 100644 --- a/src/dolda/jsvc/util/Misc.java +++ b/src/dolda/jsvc/util/Misc.java @@ -1,18 +1,55 @@ package dolda.jsvc.util; +import dolda.jsvc.*; import java.util.*; +import java.io.*; public class Misc { private static Map stext = new HashMap(); static { stext.put(200, "OK"); + stext.put(300, "Multiple Choices"); + stext.put(301, "Permanently Moved"); + stext.put(302, "Temporarily Moved"); + stext.put(303, "See Other"); + stext.put(304, "Not Modified"); + stext.put(400, "Bad Request"); + stext.put(401, "Authentication Required"); + stext.put(403, "Access Forbidden"); + stext.put(404, "Resource Not Found"); + stext.put(500, "Server Error"); } public static String statustext(int status) { String text; if((text = stext.get(status)) != null) return(text); - return("Unknown Response"); + return("Server Flimsiness"); + } + + public static String stripslashes(String p, boolean beg, boolean end) { + while(end && (p.length() > 0) && (p.charAt(p.length() - 1) == '/')) + p = p.substring(0, p.length() - 1); + while(beg && (p.length() > 0) && (p.charAt(0) == '/')) + p = p.substring(1); + return(p); + } + + public static void cpstream(InputStream in, OutputStream out) throws IOException { + byte[] buf = new byte[4096]; + while(true) { + int ret = in.read(buf, 0, buf.length); + if(ret < 0) + return; + out.write(buf, 0, ret); + } + } + + public static Responder stdroot(Responder root) { + Responder ret = root; + ret = new Rehandler(ret); + ret = new ErrorHandler(ret); + return(ret); } }