Author: remy.maucherat(a)jboss.com
Date: 2009-04-22 12:31:48 -0400 (Wed, 22 Apr 2009)
New Revision: 1024
Modified:
branches/2.1.x/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
branches/2.1.x/webapps/docs/changelog.xml
trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
trunk/webapps/docs/changelog.xml
Log:
- JBAS-6814: Fixes caused by the event changes for non blocking.
- end(), which will read until the end chunk, cannot get 0 as a doRead result, since
there's no non blocking at that point
(not really useful given the other change, but it is the correct check).
- parseChunkHeader should return false when doRead returns 0 (only possible in non
blocking mode),
but an exception if negative.
Modified: branches/2.1.x/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
---
branches/2.1.x/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2009-04-22
14:31:47 UTC (rev 1023)
+++
branches/2.1.x/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2009-04-22
16:31:48 UTC (rev 1024)
@@ -19,13 +19,12 @@
import java.io.IOException;
-import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.HexUtils;
-
import org.apache.coyote.InputBuffer;
import org.apache.coyote.Request;
import org.apache.coyote.http11.Constants;
import org.apache.coyote.http11.InputFilter;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
/**
* Chunked input filter. Parses chunked data according to
@@ -188,7 +187,7 @@
throws IOException {
// Consume extra bytes : parse the stream until the end chunk is found
- while (doRead(readChunk, null) >= 0) {
+ while (doRead(readChunk, null) > 0) {
}
// Return the number of extra bytes which were consumed
@@ -274,8 +273,12 @@
if (pos >= lastValid) {
// In non blocking mode, no new chunk follows, even if data was present
- if (readBytes() <= 0)
+ int n = readBytes();
+ if (n < 0) {
+ throw new IOException("Invalid chunk header");
+ } else if (n == 0) {
return false;
+ }
}
if (buf[pos] == Constants.CR) {
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-04-22 14:31:47 UTC (rev 1023)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-04-22 16:31:48 UTC (rev 1024)
@@ -36,6 +36,9 @@
<fix>
Remove useless instanceof in the HTTP protocol. (markt)
</fix>
+ <fix>
+ <jboss-jira>JBAS-6814</jboss-jira>: Fix looping when parsing bad end
chunk, caused by the non blocking changes. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
Modified: trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
--- trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2009-04-22
14:31:47 UTC (rev 1023)
+++ trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2009-04-22
16:31:48 UTC (rev 1024)
@@ -19,13 +19,12 @@
import java.io.IOException;
-import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.HexUtils;
-
import org.apache.coyote.InputBuffer;
import org.apache.coyote.Request;
import org.apache.coyote.http11.Constants;
import org.apache.coyote.http11.InputFilter;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
/**
* Chunked input filter. Parses chunked data according to
@@ -188,7 +187,7 @@
throws IOException {
// Consume extra bytes : parse the stream until the end chunk is found
- while (doRead(readChunk, null) >= 0) {
+ while (doRead(readChunk, null) > 0) {
}
// Return the number of extra bytes which were consumed
@@ -274,8 +273,12 @@
if (pos >= lastValid) {
// In non blocking mode, no new chunk follows, even if data was present
- if (readBytes() <= 0)
+ int n = readBytes();
+ if (n < 0) {
+ throw new IOException("Invalid chunk header");
+ } else if (n == 0) {
return false;
+ }
}
if (buf[pos] == Constants.CR) {
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-04-22 14:31:47 UTC (rev 1023)
+++ trunk/webapps/docs/changelog.xml 2009-04-22 16:31:48 UTC (rev 1024)
@@ -125,6 +125,12 @@
</subsection>
<subsection name="Coyote">
<changelog>
+ <fix>
+ Remove useless instanceof in the HTTP protocol. (markt)
+ </fix>
+ <fix>
+ <jboss-jira>JBAS-6814</jboss-jira>: Fix looping when parsing bad end
chunk, caused by the non blocking changes. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
Show replies by date