fixed bug 372
[org.ibex.core.git] / src / org / ibex / HTTP.java
index 856eabe..b95c3bc 100644 (file)
@@ -31,6 +31,7 @@ public class HTTP {
 
     public static HTTP stdio = new HTTP("stdio:");
 
+
     // Statics ///////////////////////////////////////////////////////////////////////////////////////////////
 
     static Hash resolvedHosts = new Hash();            ///< cache for resolveAndCheckIfFirewalled()
@@ -87,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);
@@ -580,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);