Click
  1. Click
  2. CLK-5

Gzip compression can cause blank pages in browsers

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Click gzip compression of HTML can result in blank pages being displayed in some browser.

      This issue became apparent when the click-examples application was deployed with the global header set:

      <header name="Content-Encoding" value="gzip"/>

      This was first observed by Jake Robwood, and subsequently observed by some others. This was problem was not reproducable by all users. No particular browser or OS was identified as being solely associated with this issue.

      The Click compression functionality does not set the response header "Content-Length" which could be the cause of this issue. Click's compression is performed by the ClickServlet.renderTemplate() method:

      protected void renderTemplate(Page page) throws Exception {
      ..

      final HttpServletResponse response = page.getContext().getResponse();

      response.setContentType(page.getContentType());

      OutputStream output = response.getOutputStream();

      // If Page has a "Content-Encoding" "gzip" header then we can look to
      // compressing the output stream
      if (hasContentEncodingGzipHeader(page)) {

      // If client accepts gzip encoding compress output stream
      String acceptEncoding = request.getHeader("Accept-Encoding");
      if (acceptEncoding != null) {
      if (acceptEncoding.toLowerCase().indexOf("gzip") > -1)

      { output = new GZIPOutputStream(output, 4 * 1024); response.setHeader("Content-Encoding", "gzip"); }

      }
      }

      ..
      }

        Activity

        Malcolm Edgar created issue -
        Hide
        Malcolm Edgar added a comment -

        Note GZIP compression bugs in JDK may make using application based compression, rather than using Apache mod_deflate, a bad practice:

        http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=5072161

        Show
        Malcolm Edgar added a comment - Note GZIP compression bugs in JDK may make using application based compression, rather than using Apache mod_deflate, a bad practice: http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=5072161
        Hide
        Malcolm Edgar added a comment -

        Looking at some compression ServletFilters I see that they are setting the Content-Length request header. I suspect this is what is causing failures in some browsers.

        To fix this would mean storing the gzip rendered output in a temporary byte array and then setting content-length header and then ouputing the bytearray to the servlet response.

        I am wondering the gzip compression feature should be removed from the ClickServlet. People can then use Apache mod_deflate for compression (recommended) or a ServletFilter is they really want (this could be added to Click Extras)

        Show
        Malcolm Edgar added a comment - Looking at some compression ServletFilters I see that they are setting the Content-Length request header. I suspect this is what is causing failures in some browsers. To fix this would mean storing the gzip rendered output in a temporary byte array and then setting content-length header and then ouputing the bytearray to the servlet response. I am wondering the gzip compression feature should be removed from the ClickServlet. People can then use Apache mod_deflate for compression (recommended) or a ServletFilter is they really want (this could be added to Click Extras)
        Hide
        Malcolm Edgar added a comment -

        Will remove "gzip" compression feature from Click in next release, unless I hear loud protests to the contry.

        If users want compression done by the ServletContainer we can add a CompressionFilter to Click Extras.

        Any comments?

        Show
        Malcolm Edgar added a comment - Will remove "gzip" compression feature from Click in next release, unless I hear loud protests to the contry. If users want compression done by the ServletContainer we can add a CompressionFilter to Click Extras. Any comments?
        Malcolm Edgar made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Ahmed Mohombe added a comment -

        I also made some tests regarding this gzip problem (AFAIK Jake seems to have some exams).

        If I use the GZip ServletFilter from AppFuse, than everything works.
        It seems to me that Filters are a better choice and they are pretty standard for such a functionality.

        So indeed the solution is to use filters for this problem (and maybe other similar problems: eg. decoration with SiteMesh, insted of reflection thru' a Border Page). The one from AppFuse seems pretty comlete, and many people test it, so ... .

        Ahmed.

        Show
        Ahmed Mohombe added a comment - I also made some tests regarding this gzip problem (AFAIK Jake seems to have some exams). If I use the GZip ServletFilter from AppFuse, than everything works. It seems to me that Filters are a better choice and they are pretty standard for such a functionality. So indeed the solution is to use filters for this problem (and maybe other similar problems: eg. decoration with SiteMesh, insted of reflection thru' a Border Page). The one from AppFuse seems pretty comlete, and many people test it, so ... . Ahmed.
        Hide
        Malcolm Edgar added a comment -

        Click embedded gzip compression feature removed from ClickServlet.

        Optional CompressionFilter derived from Jakarta Tomcat example filters has been added to Click Extras.

        Show
        Malcolm Edgar added a comment - Click embedded gzip compression feature removed from ClickServlet. Optional CompressionFilter derived from Jakarta Tomcat example filters has been added to Click Extras.
        Malcolm Edgar made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Hide
        Malcolm Edgar added a comment -

        Available in release 0.11

        Show
        Malcolm Edgar added a comment - Available in release 0.11
        Malcolm Edgar made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Henri Yandell made changes -
        Project Import Fri Mar 20 14:11:32 PDT 2009 [ 1237583492744 ]

          People

          • Assignee:
            Malcolm Edgar
            Reporter:
            Malcolm Edgar
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development