Author: remy.maucherat(a)jboss.com
Date: 2008-01-04 12:21:51 -0500 (Fri, 04 Jan 2008)
New Revision: 388
Modified:
trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
Log:
- Change input to allow the internal filter chain to return that it read no bytes (this
may happen in very
rare cases in non blocking with chunks). Also experimental, maybe some more changes are
needed.
Modified: trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
===================================================================
--- trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2008-01-04 17:17:44 UTC
(rev 387)
+++ trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2008-01-04 17:21:51 UTC
(rev 388)
@@ -164,8 +164,9 @@
request.getEvent().setEventType(CometEvent.EventType.ERROR);
request.getEvent().setEventSubType(CometEvent.EventSubType.CLIENT_DISCONNECT);
} else {
- request.getEvent().setEventType(CometEvent.EventType.END);
- request.getEvent().setEventSubType(null);
+ // Data was present on the socket, but it did not translate
into actual
+ // entity body bytes
+ return true;
}
}
} else if (status == SocketStatus.OPEN_WRITE) {
Modified: trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
===================================================================
--- trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2008-01-04 17:17:44
UTC (rev 387)
+++ trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java 2008-01-04 17:21:51
UTC (rev 388)
@@ -756,7 +756,7 @@
bbuf.limit(nRead);
bbuf.get(buf, pos, nRead);
lastValid = pos + nRead;
- } else {
+ } else if (nRead < 0) {
if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) {
throw new
SocketTimeoutException(sm.getString("iib.failedread"));
} else {
Modified: trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
--- trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2008-01-04
17:17:44 UTC (rev 387)
+++ trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2008-01-04
17:21:51 UTC (rev 388)
@@ -123,14 +123,14 @@
if (endChunk)
return -1;
- if(needCRLFParse) {
+ if (needCRLFParse) {
needCRLFParse = false;
parseCRLF();
}
if (remaining <= 0) {
if (!parseChunkHeader()) {
- throw new IOException("Invalid chunk header");
+ return 0;
}
if (endChunk) {
parseEndChunk();
@@ -263,6 +263,7 @@
while (!eol) {
if (pos >= lastValid) {
+ // In non blocking mode, no new chunk follows, even if data was present
if (readBytes() <= 0)
return false;
}
@@ -281,7 +282,7 @@
} else {
//we shouldn't allow invalid, non hex characters
//in the chunked header
- return false;
+ throw new IOException("Invalid chunk header");
}
}
@@ -289,15 +290,13 @@
}
- if (!readDigit)
- return false;
+ if (!readDigit || (result < 0))
+ throw new IOException("Invalid chunk header");
if (result == 0)
endChunk = true;
remaining = result;
- if (remaining < 0)
- return false;
return true;
Show replies by date