X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FHTTP.java;h=2aed806f8fb56487bcf2955120b22de8e381457c;hb=c28ed126fbc51fb5794bb367f51a8755dc20140e;hp=3dbc4cda98bd9eaf1169285bcf2595ab91ee2621;hpb=e4a8b8cbccc958639f4552d94c5a7c84d09f0ebc;p=org.ibex.core.git diff --git a/src/org/ibex/HTTP.java b/src/org/ibex/HTTP.java index 3dbc4cd..2aed806 100644 --- a/src/org/ibex/HTTP.java +++ b/src/org/ibex/HTTP.java @@ -29,6 +29,8 @@ public class HTTP { public static class HTTPException extends IOException { public HTTPException(String s) { super(s); } } + public static HTTP stdio = new HTTP("stdio:"); + // Statics /////////////////////////////////////////////////////////////////////////////////////////////// @@ -86,7 +88,7 @@ public class HTTP { // previous call wrecked the socket connection, but we already sent our request, so we can't just retry -- // this could cause the server to receive the request twice, which could be bad (think of the case where the // server call causes Amazon.com to ship you an item with one-click purchasing). - if (sock == null) + if (in == null) throw new HTTPException("a previous pipelined call messed up the socket"); Hashtable h = in == null ? null : parseHeaders(in); @@ -354,7 +356,7 @@ public class HTTP { PrintWriter pw = new PrintWriter(new OutputStreamWriter(originalUrl.equals("stdio:") ? System.out : sock.getOutputStream())); if (content != null) { - pw.print("POST " + path + " HTTP/1.1\r\n"); + pw.print("POST " + path + " HTTP/1.0\r\n"); // FIXME chunked encoding int contentLength = content.substring(0, 2).equals("\r\n") ? content.length() - 2 : (content.length() - content.indexOf("\r\n\r\n") - 4); @@ -579,6 +581,8 @@ public class HTTP { if (buflen >= 4 && buf[buflen - 4] == '\r' && buf[buflen - 3] == '\n' && buf[buflen - 2] == '\r' && buf[buflen - 1] == '\n') break; + if (buflen >=2 && buf[buflen - 1] == '\n' && buf[buflen - 2] == '\n') + break; // nice for people using stdio if (buflen == buf.length) { byte[] newbuf = new byte[buf.length * 2]; System.arraycopy(buf, 0, newbuf, 0, buflen); @@ -778,7 +782,9 @@ public class HTTP { Scheduler.add(new Scheduler.Task() { public void perform() throws IOException, JSExn { Box b = new Box(); - Template t = Template.buildTemplate(Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null)); + Template t = null; + // FIXME + //Template.buildTemplate("org/ibex/builtin/proxy_authorization.ibex", Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), new Ibex(null)); t.apply(b); b.put("realm", realm); b.put("proxyIP", proxyIP);