2003/06/13 09:19:10
[org.ibex.core.git] / src / org / xwt / HTTP.java
index e401f86..d4d2249 100644 (file)
@@ -484,6 +484,20 @@ public class HTTP {
             this.length = length == -1 ? 0 : length;
         }
 
+       public boolean markSupported() { return false; }
+       public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
+       public long skip(long n) throws IOException { return read(null, -1, (int)n); }
+       public int available() throws IOException {
+           if (contentLength == -1) return java.lang.Math.min(super.available(), length);
+           return super.available();
+       }
+
+       public int read() throws IOException {
+           byte[] b = new byte[1];
+           int ret = read(b, 0, 1);
+           return ret == -1 ? -1 : b[0] & 0xff;
+       }
+
         private void readChunk() throws IOException {
             if (chunkedDone) return;
             if (!firstChunk) super.skip(2); // CRLF
@@ -515,7 +529,7 @@ public class HTTP {
                    if (length == 0) { good = true; return -1; }
                }
                 if (len > length) len = length;
-                int ret = super.read(b, off, len);
+                int ret = b == null ? (int)super.skip(len) : super.read(b, off, len);
                if (ret >= 0) {
                    length -= ret;
                    good = true;