remm 2003/09/21 12:28:11
Modified: http11/src/java/org/apache/coyote/http11
Http11Processor.java
Log:
- Code cleanup.
- Fix matching of the content types sfor which compression is allowed.
- Submitted by Steve Appling.
Revision Changes Path
1.79 +49 -20
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.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- Http11Processor.java 12 Sep 2003 13:15:36 -0000 1.78
+++ Http11Processor.java 21 Sep 2003 19:28:11 -0000 1.79
@@ -102,6 +102,13 @@
public class Http11Processor implements Processor, ActionHook {
+ /**
+ * Logger.
+ */
+ protected static org.apache.commons.logging.Log log
+ = org.apache.commons.logging.LogFactory.getLog(Http11Processor.class);
+
+
// ----------------------------------------------------------- Constructors
@@ -202,13 +209,6 @@
/**
- * Logger.
- */
- protected static org.apache.commons.logging.Log log
- = org.apache.commons.logging.LogFactory.getLog(Http11Processor.class);
-
-
- /**
* Maximum number of Keep-Alive requests to honor.
*/
protected int maxKeepAliveRequests = -1;
@@ -248,11 +248,12 @@
* The local Host address.
*/
protected String localAddr = null;
-
+
+
/**
- * Maximum timeout on uploads.
+ * Maximum timeout on uploads. 5 minutes as in Apache HTTPD server.
*/
- protected int timeout = 300000; // 5 minutes as in Apache HTTPD server
+ protected int timeout = 300000;
/**
@@ -288,7 +289,8 @@
/**
* List of MIMES which could be gzipped
*/
- protected String[] compressableMimeTypes = { "text/html", "text/xml",
"text/plain" };
+ protected String[] compressableMimeTypes =
+ { "text/html", "text/xml", "text/plain" };
/**
@@ -296,8 +298,13 @@
*/
protected char[] hostNameC = new char[0];
+
+ /**
+ * Associated thread pool.
+ */
protected ThreadPool threadPool;
+
// ------------------------------------------------------------- Properties
@@ -445,6 +452,7 @@
sArray = results;
}
+
/**
* General use method
*
@@ -462,6 +470,24 @@
/**
+ * Checks if any entry in the string array starts with the specified value
+ *
+ * @param sArray the StringArray
+ * @param value string
+ */
+ private boolean startsWithStringArray(String sArray[], String value) {
+ if (value == null)
+ return false;
+ for (int i = 0; i < sArray.length; i++) {
+ if (value.startsWith(sArray[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
* Add restricted user-agent (which will downgrade the connector
* to HTTP/1.0 mode). The user agent String given will be exactly matched
* to the user-agent header submitted by the client.
@@ -1168,12 +1194,12 @@
}
- /*
+
+ /**
* Check for compression
- *
*/
- private boolean isCompressable()
- {
+ private boolean isCompressable() {
+
// Compression only since HTTP 1.1
if (! http11)
return false;
@@ -1213,13 +1239,16 @@
if ((contentLength == -1)
|| (contentLength > compressionMinSize)) {
// Check for compatible MIME-TYPE
- if (compressableMimeTypes != null)
- return (inStringArray(compressableMimeTypes,
response.getContentType()));
+ if (compressableMimeTypes != null) {
+ return (startsWithStringArray(compressableMimeTypes,
+ response.getContentType()));
+ }
}
- return false;
- }
-
+ return false;
+ }
+
+
/**
* When committing the response, we have to validate the set of headers, as
* well as setup the response filters.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]