This class handles the readin input bytes, as well as the input buffering.
| Method from org.apache.coyote.tomcat4.CoyoteInputStream Detail: |
public int available() throws IOException {
if( pos < end ) return end-pos;
return 0;
}
|
public void close() {
closed = true;
}
Close the stream
Since we re-cycle, we can't allow the call to super.close()
which would permantely disable us. |
public int read() throws IOException {
if (closed)
throw new IOException("Stream closed");
// Read additional bytes if none are available
while (pos >= end) {
if (readBytes() < 0)
return -1;
}
return (readBuffer[pos++] & 0xFF);
}
|
public int read(byte[] b) throws IOException {
return read(b, 0, b.length);
}
|
public int read(byte[] b,
int off,
int len) throws IOException {
if (closed)
throw new IOException("Stream closed");
// Read additional bytes if none are available
while (pos >= end) {
if (readBytes() < 0)
return -1;
}
int n = -1;
if ((end - pos) > len) {
n = len;
} else {
n = end - pos;
}
System.arraycopy(readBuffer, pos, b, off, n);
pos += n;
return n;
}
|
protected int readBytes() throws IOException {
int result = coyoteRequest.doRead(readChunk);
if (result > 0) {
readBuffer = readChunk.getBytes();
end = readChunk.getEnd();
pos = readChunk.getStart();
}
return result;
}
Read bytes to the read chunk buffer. |
public int readLine(byte[] b,
int off,
int len) throws IOException {
return super.readLine(b, off, len);
}
|
void recycle() {
closed = false;
pos = -1;
end = -1;
readBuffer = null;
}
Recycle the input stream. |
void setRequest(Request coyoteRequest) {
// --------------------------------------------------------- Public Methods
this.coyoteRequest = coyoteRequest;
}
|