/** * Starts a web server. * The port number is specified by the first argument. */ public static void main(String[] args) throws IOException { if (args.length == 1) { Webserver web = new Webserver(args[0]); web.run(); } else System.err.println( "Usage: java javassist.tools.web.Webserver <port number>"); }
&& letUsersSendClassfile(out, filename, len)) return; checkFilename(filename, len); if (htmlfileBase != null) filename = htmlfileBase + filename; sendHeader(out, file.length(), fileType); FileInputStream fin = new FileInputStream(file); byte[] filebuffer = new byte[4096]; sendHeader(out, classfile.length, typeClass); out.write(classfile); fin.close();
final void process(Socket clnt) throws IOException { InputStream in = new BufferedInputStream(clnt.getInputStream()); String cmd = readLine(in); logging(clnt.getInetAddress().getHostName(), new Date().toString(), cmd); while (skipLine(in) > 0){ } OutputStream out = new BufferedOutputStream(clnt.getOutputStream()); try { doReply(in, out, cmd); } catch (BadHttpRequest e) { replyError(out, e); } out.flush(); in.close(); out.close(); clnt.close(); }
private void replyError(OutputStream out, BadHttpRequest e) throws IOException { logging2("bad request: " + e.toString()); out.write("HTTP/1.0 400 Bad Request".getBytes()); out.write(endofline); out.write(endofline); out.write("<H1>Bad Request</H1>".getBytes()); } }
/** * Begins the HTTP service. */ public void run() { super.run(); }
public void run() { try { web.process(sock); } catch (IOException e) { } } }
/** * Processes a request from a web browser (an ObjectImporter). */ public void doReply(InputStream in, OutputStream out, String cmd) throws IOException, BadHttpRequest { if (cmd.startsWith("POST /rmi ")) processRMI(in, out); else if (cmd.startsWith("POST /lookup ")) lookupName(cmd, in, out); else super.doReply(in, out, cmd); }
/** * Begins the HTTP service. */ public void run() { System.err.println("ready to service..."); for (;;) try { ServiceThread th = new ServiceThread(this, socket.accept()); th.start(); } catch (IOException e) { logging(e.toString()); } }
private void replyError(OutputStream out, BadHttpRequest e) throws IOException { logging2("bad request: " + e.toString()); out.write("HTTP/1.0 400 Bad Request".getBytes()); out.write(endofline); out.write(endofline); out.write("<H1>Bad Request</H1>".getBytes()); } }
/** * Begins the HTTP service. */ @Override public void run() { super.run(); }
@Override public void run() { try { web.process(sock); } catch (IOException e) { } } }
/** * Processes a request from a web browser (an ObjectImporter). */ @Override public void doReply(InputStream in, OutputStream out, String cmd) throws IOException, BadHttpRequest { if (cmd.startsWith("POST /rmi ")) processRMI(in, out); else if (cmd.startsWith("POST /lookup ")) lookupName(cmd, in, out); else super.doReply(in, out, cmd); }
/** * Begins the HTTP service. */ public void run() { System.err.println("ready to service..."); for (;;) try { ServiceThread th = new ServiceThread(this, socket.accept()); th.start(); } catch (IOException e) { logging(e.toString()); } }
final void process(Socket clnt) throws IOException { InputStream in = new BufferedInputStream(clnt.getInputStream()); String cmd = readLine(in); logging(clnt.getInetAddress().getHostName(), new Date().toString(), cmd); while (skipLine(in) > 0){ } OutputStream out = new BufferedOutputStream(clnt.getOutputStream()); try { doReply(in, out, cmd); } catch (BadHttpRequest e) { replyError(out, e); } out.flush(); in.close(); out.close(); clnt.close(); }
&& letUsersSendClassfile(out, filename, len)) return; checkFilename(filename, len); if (htmlfileBase != null) filename = htmlfileBase + filename; sendHeader(out, file.length(), fileType); FileInputStream fin = new FileInputStream(file); byte[] filebuffer = new byte[4096]; sendHeader(out, classfile.length, typeClass); out.write(classfile); fin.close();
/** * Starts a web server. * The port number is specified by the first argument. */ public static void main(String[] args) throws IOException { if (args.length == 1) { Webserver web = new Webserver(args[0]); web.run(); } else System.err.println( "Usage: java javassist.tools.web.Webserver <port number>"); }
private void replyError(OutputStream out, BadHttpRequest e) throws IOException { logging2("bad request: " + e.toString()); out.write("HTTP/1.0 400 Bad Request".getBytes()); out.write(endofline); out.write(endofline); out.write("<H1>Bad Request</H1>".getBytes()); } }
/** * Begins the HTTP service. */ public void run() { super.run(); }
public void run() { try { web.process(sock); } catch (IOException e) { } } }
/** * Processes a request from a web browser (an ObjectImporter). */ public void doReply(InputStream in, OutputStream out, String cmd) throws IOException, BadHttpRequest { if (cmd.startsWith("POST /rmi ")) processRMI(in, out); else if (cmd.startsWith("POST /lookup ")) lookupName(cmd, in, out); else super.doReply(in, out, cmd); }