Author: markt
Date: Thu Feb 12 15:57:35 2015
New Revision: 1659293
URL: http://svn.apache.org/r1659293
Log:
Delay closing the connection until maxSwallowSize bytes have been read. This
gives the client a chance to read the response. See
http://httpd.apache.org/docs/2.0/misc/fin_wait_2.html#appendix
Modified:
tomcat/trunk/java/org/apache/coyote/http11/filters/IdentityInputFilter.java
Modified:
tomcat/trunk/java/org/apache/coyote/http11/filters/IdentityInputFilter.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/filters/IdentityInputFilter.java?rev=1659293&r1=1659292&r2=1659293&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/filters/IdentityInputFilter.java
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/filters/IdentityInputFilter.java
Thu Feb 12 15:57:35 2015
@@ -147,21 +147,25 @@ public class IdentityInputFilter impleme
}
- /**
- * End the current request.
- */
@Override
- public long end() throws IOException {
+ public long end() throws IOException {
- if (maxSwallowSize > -1 && remaining > maxSwallowSize) {
- throw new IOException(sm.getString("inputFilter.maxSwallow"));
- }
+ final boolean maxSwallowSizeExceeded = (maxSwallowSize > -1 &&
remaining > maxSwallowSize);
+ long swallowed = 0;
// Consume extra bytes.
while (remaining > 0) {
+
int nread = buffer.doRead(endChunk, null);
if (nread > 0 ) {
+ swallowed += nread;
remaining = remaining - nread;
+ if (maxSwallowSizeExceeded && swallowed > maxSwallowSize) {
+ // Note: We do not fail early so the client has a chance to
+ // read the response before the connection is closed. See:
+ //
http://httpd.apache.org/docs/2.0/misc/fin_wait_2.html#appendix
+ throw new
IOException(sm.getString("inputFilter.maxSwallow"));
+ }
} else { // errors are handled higher up.
remaining = 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]