| 1 package com.quadcap.http.server22; 2 3 40 41 import java.io.BufferedInputStream ; 42 import java.io.InputStream ; 43 import java.io.IOException ; 44 45 import javax.servlet.ServletInputStream ; 46 47 import com.quadcap.net.server.WorkerInputStream; 48 49 import com.quadcap.util.Debug; 50 51 public class HttpInputStream extends ServletInputStream { 52 WorkerInputStream is; 53 int contentLength = -1; 54 55 public void reset(WorkerInputStream is) { 56 this.is = is; 57 this.contentLength = -1; 58 } 59 60 public void setContentLength(int len) { 61 this.contentLength = len; 62 } 63 64 public int read() throws IOException { 65 int c = -1; 66 if (contentLength > 0) { 67 contentLength--; 68 c = is.read(); 69 } else if (contentLength == -1) { 70 c = is.read(); 71 } 72 return c; 73 } 74 75 79 public void close() throws IOException { 80 } 81 82 public void reallyClose() throws IOException { 83 is.close(); 84 } 85 86 public WorkerInputStream getInputStream() { 87 return is; 88 } 89 } 90 | Popular Tags |