}
} else {
ib.close();
- }
+ }
}
}
import java.util.HashMap;
import org.apache.catalina.security.SecurityUtil;
+import org.apache.coyote.ActionCode;
import org.apache.coyote.Request;
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.ByteChunk;
public int available()
throws IOException {
+ int available = 0;
if (state == BYTE_STATE) {
- return bb.getLength();
+ available = bb.getLength();
} else if (state == CHAR_STATE) {
- return cb.getLength();
- } else {
- return 0;
+ available = cb.getLength();
+ }
+ if (available == 0) {
+ coyoteRequest.action(ActionCode.ACTION_AVAILABLE, null);
+ available = (coyoteRequest.getAvailable() > 0) ? 1 : 0;
}
+ return available;
}
public boolean ready()
throws IOException {
- return (cb.getLength() > 0);
+ return (available() > 0);
}
public static final ActionCode ACTION_COMET_END = new ActionCode(22);
+ /**
+ * Callback for getting the amount of available bytes
+ */
+ public static final ActionCode ACTION_AVAILABLE = new ActionCode(23);
+
+
// ----------------------------------------------------------- Constructors
int code;
private int bytesRead=0;
// Time of the request - usefull to avoid repeated calls to System.currentTime
private long startTime = 0L;
+ private int available = 0;
private RequestInfo reqProcessorMX=new RequestInfo(this);
// ------------------------------------------------------------- Properties
return authType;
}
+ public int getAvailable() {
+ return available;
+ }
+
+ public void setAvailable(int available) {
+ this.available = available;
+ }
+
// -------------------- Input Buffer --------------------
serverPort=-1;
localPort = -1;
remotePort = -1;
+ available = 0;
cookies.recycle();
parameters.recycle();
request.getInputBuffer();
internalBuffer.addActiveFilter(savedBody);
+ } else if (actionCode == ActionCode.ACTION_AVAILABLE) {
+ request.setAvailable(inputBuffer.available());
} else if (actionCode == ActionCode.ACTION_COMET_BEGIN) {
comet = true;
} else if (actionCode == ActionCode.ACTION_COMET_END) {
request.getInputBuffer();
internalBuffer.addActiveFilter(savedBody);
+ } else if (actionCode == ActionCode.ACTION_AVAILABLE) {
+ request.setAvailable(inputBuffer.available());
} else if (actionCode == ActionCode.ACTION_COMET_BEGIN) {
comet = true;
} else if (actionCode == ActionCode.ACTION_COMET_END) {
throws IOException;
+ /**
+ * Amount of bytes still available in a buffer.
+ */
+ public int available();
+
+
}
}
+
+ /**
+ * Available bytes (note that due to encoding, this may not correspond )
+ */
+ public int available() {
+ int result = (lastValid - pos);
+ if ((result == 0) && (lastActiveFilter >= 0)) {
+ for (int i = 0; (result == 0) && (i <= lastActiveFilter); i++) {
+ result = activeFilters[i].available();
+ }
+ }
+ return result;
+ }
+
// ---------------------------------------------------- InputBuffer Methods
}
+ /**
+ * Available bytes (note that due to encoding, this may not correspond )
+ */
+ public int available() {
+ int result = (lastValid - pos);
+ if ((result == 0) && (lastActiveFilter >= 0)) {
+ for (int i = 0; (result == 0) && (i <= lastActiveFilter); i++) {
+ result = activeFilters[i].available();
+ }
+ }
+ return result;
+ }
+
+
// ---------------------------------------------------- InputBuffer Methods
return 0;
}
+ public int available() {
+ return buffered.getLength();
+ }
+
}
/**
+ * Amount of bytes still available in a buffer.
+ */
+ public int available() {
+ return (lastValid - pos);
+ }
+
+
+ /**
* Set the next buffer in the filter pipeline.
*/
public void setBuffer(InputBuffer buffer) {
/**
+ * Amount of bytes still available in a buffer.
+ */
+ public int available() {
+ return 0;
+ }
+
+
+ /**
* Set the next buffer in the filter pipeline.
*/
public void setBuffer(InputBuffer buffer) {
}
/**
+ * Amount of bytes still available in a buffer.
+ */
+ public int available() {
+ return input.getLength();
+ }
+
+ /**
* End the current request (has no effect).
*/
public long end() throws IOException {
}
+ /**
+ * Amount of bytes still available in a buffer.
+ */
+ public int available() {
+ return 0;
+ }
+
}