You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2003/11/17 10:42:40 UTC
cvs commit: jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters BufferedInputFilter.java
remm 2003/11/17 01:42:40
Modified: http11/src/java/org/apache/coyote/http11
Http11Processor.java Http11Protocol.java
http11/src/java/org/apache/coyote/http11/filters
BufferedInputFilter.java
Log:
- Add maxPostSize support to the SSL buffering feature.
- Don't recycle the buffer if it gets too large (GC savings are then not worth
the memory used).
Revision Changes Path
1.87 +25 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
Index: Http11Processor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- Http11Processor.java 5 Nov 2003 11:38:47 -0000 1.86
+++ Http11Processor.java 17 Nov 2003 09:42:40 -0000 1.87
@@ -284,9 +284,15 @@
/**
+ * Max post size.
+ */
+ protected int maxPostSize = 2 * 1024 * 1024;
+
+
+ /**
* List of user agents to not use gzip with
*/
- protected RE noCompressionUserAgents[] = null;
+ protected RE noCompressionUserAgents[] = null;
/**
* List of MIMES which could be gzipped
@@ -623,6 +629,22 @@
/**
+ * Set the maximum size of a POST which will be buffered in SSL mode.
+ */
+ public void setMaxPostSize(int mps) {
+ maxPostSize = mps;
+ }
+
+
+ /**
+ * Return the maximum size of a POST which will be buffered in SSL mode.
+ */
+ public int getMaxPostSize() {
+ return maxPostSize;
+ }
+
+
+ /**
* Set the SSL information for this HTTP connection.
*/
public void setSSLSupport(SSLSupport sslSupport) {
@@ -1006,6 +1028,8 @@
* interfere with the client's handshake messages
*/
InputFilter[] inputFilters = inputBuffer.getFilters();
+ ((BufferedInputFilter) inputFilters[Constants.BUFFERED_FILTER])
+ .setLimit(maxPostSize);
inputBuffer.addActiveFilter
(inputFilters[Constants.BUFFERED_FILTER]);
try {
1.43 +8 -1 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Protocol.java
Index: Http11Protocol.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Protocol.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- Http11Protocol.java 7 Oct 2003 08:48:50 -0000 1.42
+++ Http11Protocol.java 17 Nov 2003 09:42:40 -0000 1.43
@@ -245,6 +245,7 @@
private int maxKeepAliveRequests=100; // as in Apache HTTPD server
private int timeout = 300000; // 5 minutes as in Apache HTTPD server
+ private int maxPostSize = 2 * 1024 * 1024;
private String reportedname;
private int socketCloseDelay=-1;
private boolean disableUploadTimeout = true;
@@ -334,6 +335,11 @@
setAttribute("compression", valueS);
}
+ public void setMaxPostSize(int valueI) {
+ maxPostSize = valueI;
+ setAttribute("maxPostSize", "" + valueI);
+ }
+
public void setRestrictedUserAgents(String valueS) {
restrictedUserAgents = valueS;
setAttribute("restrictedUserAgents", valueS);
@@ -496,11 +502,12 @@
processor.setTimeout( proto.timeout );
processor.setDisableUploadTimeout( proto.disableUploadTimeout );
processor.setCompression( proto.compression );
- processor.setCompressionMinSize( proto.compressionMinSize);
+ processor.setCompressionMinSize( proto.compressionMinSize);
processor.setNoCompressionUserAgents( proto.noCompressionUserAgents);
processor.setCompressableMimeTypes( proto.compressableMimeTypes);
processor.setRestrictedUserAgents( proto.restrictedUserAgents);
processor.setSocketBuffer( proto.socketBuffer );
+ processor.setMaxPostSize( proto.maxPostSize );
thData[Http11Protocol.THREAD_DATA_PROCESSOR]=processor;
1.2 +22 -2 jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/BufferedInputFilter.java
Index: BufferedInputFilter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/filters/BufferedInputFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BufferedInputFilter.java 17 Oct 2003 18:45:40 -0000 1.1
+++ BufferedInputFilter.java 17 Nov 2003 09:42:40 -0000 1.2
@@ -79,7 +79,7 @@
// ----------------------------------------------------- Instance Variables
- private ByteChunk buffered = new ByteChunk(1024);
+ private ByteChunk buffered = null;
private ByteChunk tempRead = new ByteChunk(1024);
private InputBuffer buffer;
private boolean hasRead = false;
@@ -92,8 +92,24 @@
}
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Set the buffering limit. This should be reset every time the buffer is
+ * used.
+ */
+ public void setLimit(int limit) {
+ if (buffered == null) {
+ buffered = new ByteChunk(4048);
+ buffered.setLimit(limit);
+ }
+ }
+
+
// ---------------------------------------------------- InputBuffer Methods
+
/**
* Reads the request body and buffers it.
*/
@@ -128,7 +144,11 @@
}
public void recycle() {
- buffered.recycle();
+ if (buffered.getBuffer().length > 65536) {
+ buffered = null;
+ } else {
+ buffered.recycle();
+ }
tempRead.recycle();
hasRead = false;
buffer = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org