tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r496190 - in /tomcat: container/tc5.5.x/webapps/docs/ servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/ servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/
Date Sun, 14 Jan 2007 23:21:46 GMT
Author: markt
Date: Sun Jan 14 15:21:45 2007
New Revision: 496190

URL: http://svn.apache.org/viewvc?view=rev&rev=496190
Log:
Fix bug 39572. Improvements to CompressionFilter provided by Eric Hedström. Also cleaned
up unused imports and methods.

Modified:
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
    tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Sun Jan 14 15:21:45 2007
@@ -294,6 +294,10 @@
         language in JSPs. Patch provided by Taras Tielkes. (markt)
       </fix>
       <fix>
+        <bug>39572</bug>: Improvements to CompressionFilter example provided
by
+        Eric Hedström. (markt)
+      </fix>
+      <fix>
         <bug>40581</bug>: Add information on the use of a symbloic link as the
         docBase for a Context to the Context documentation. (markt)
       </fix>

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
Sun Jan 14 15:21:45 2007
@@ -18,7 +18,6 @@
 package compressionFilters;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.Enumeration;
 import javax.servlet.*;
 import javax.servlet.http.*;

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
Sun Jan 14 15:21:45 2007
@@ -82,7 +82,7 @@
     /**
      * The underlying gzip output stream to which we should write data.
      */
-    protected GZIPOutputStream gzipstream = null;
+    protected OutputStream gzipstream = null;
 
     /**
      * Has this stream been closed?
@@ -296,8 +296,14 @@
             if (debug > 1) {
                 System.out.println("new GZIPOutputStream");
             }
-            response.addHeader("Content-Encoding", "gzip");
-            gzipstream = new GZIPOutputStream(output);
+            if (response.isCommitted()) {
+                if (debug > 1)
+                    System.out.print("Response already committed. Using original output stream");
+                gzipstream = output;
+            } else {
+                response.addHeader("Content-Encoding", "gzip");
+                gzipstream = new GZIPOutputStream(output);
+            }
         }
         gzipstream.write(b, off, len);
 

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr152/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
Sun Jan 14 15:21:45 2007
@@ -18,16 +18,9 @@
 package compressionFilters;
 
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.util.Locale;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletResponse;
-import javax.servlet.ServletResponseWrapper;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
@@ -248,31 +241,6 @@
 
 
     public void setContentLength(int length) {
-    }
-
-
-    /**
-     * Returns character from content type. This method was taken from tomcat.
-     * @author rajo
-     */
-    private static String getCharsetFromContentType(String type) {
-
-        if (type == null) {
-            return null;
-        }
-        int semi = type.indexOf(";");
-        if (semi == -1) {
-            return null;
-        }
-        String afterSemi = type.substring(semi + 1);
-        int charsetLocation = afterSemi.indexOf("charset=");
-        if(charsetLocation == -1) {
-            return null;
-        } else {
-            String afterCharset = afterSemi.substring(charsetLocation + 8);
-            String encoding = afterCharset.trim();
-            return encoding;
-        }
     }
 
 }

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionFilterTestServlet.java
Sun Jan 14 15:21:45 2007
@@ -18,7 +18,6 @@
 package compressionFilters;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 import java.util.Enumeration;
 import javax.servlet.*;
 import javax.servlet.http.*;

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionResponseStream.java
Sun Jan 14 15:21:45 2007
@@ -81,7 +81,7 @@
     /**
      * The underlying gzip output stream to which we should write data.
      */
-    protected GZIPOutputStream gzipstream = null;
+    protected OutputStream gzipstream = null;
 
     /**
      * Has this stream been closed?
@@ -295,8 +295,14 @@
             if (debug > 1) {
                 System.out.println("new GZIPOutputStream");
             }
-            response.addHeader("Content-Encoding", "gzip");
-            gzipstream = new GZIPOutputStream(output);
+            if (response.isCommitted()) {
+                if (debug > 1)
+                    System.out.print("Response already committed. Using original output stream");
+                gzipstream = output;
+            } else {
+                response.addHeader("Content-Encoding", "gzip");
+                gzipstream = new GZIPOutputStream(output);
+            }
         }
         gzipstream.write(b, off, len);
 

Modified: tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java?view=diff&rev=496190&r1=496189&r2=496190
==============================================================================
--- tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
(original)
+++ tomcat/servletapi/servlet2.4-jsp2.0-tc5.x/jsr154/examples/WEB-INF/classes/compressionFilters/CompressionServletResponseWrapper.java
Sun Jan 14 15:21:45 2007
@@ -17,16 +17,9 @@
 package compressionFilters;
 
 import java.io.IOException;
-import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
-import java.util.Locale;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletResponse;
-import javax.servlet.ServletResponseWrapper;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
@@ -247,31 +240,6 @@
 
 
     public void setContentLength(int length) {
-    }
-
-
-    /**
-     * Returns character from content type. This method was taken from tomcat.
-     * @author rajo
-     */
-    private static String getCharsetFromContentType(String type) {
-
-        if (type == null) {
-            return null;
-        }
-        int semi = type.indexOf(";");
-        if (semi == -1) {
-            return null;
-        }
-        String afterSemi = type.substring(semi + 1);
-        int charsetLocation = afterSemi.indexOf("charset=");
-        if(charsetLocation == -1) {
-            return null;
-        } else {
-            String afterCharset = afterSemi.substring(charsetLocation + 8);
-            String encoding = afterCharset.trim();
-            return encoding;
-        }
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message