tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11910] New: - Bugs in example CompressionServletResponseWrapper
Date Wed, 21 Aug 2002 20:36:08 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11910>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11910

Bugs in example CompressionServletResponseWrapper

           Summary: Bugs in example CompressionServletResponseWrapper
           Product: Tomcat 4
           Version: 4.1.9
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Webapps:Examples
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: lolo@elline.sk


1) This example doesn't support other content-types.
PrintWriter in getWriter() method should be created in this way:

String charset = getCharsetFromContentType(contentType);
if (charset == null) charset = {default charset}
writer = new PrintWriter(new OutputStreamWriter(stream, charset));

where getCharsetFromContentType returns charset according to set content-type.

2) There can be problem when somebody sets threshold:

Method should look like this:
    public void write(int b) throws IOException {
        if (closed)
            throw new IOException("Cannot write to a closed output stream");

        if ((bufferCount >= buffer.length) || (count>=compressionThreshold)) {
            compressionThresholdReached = true;
        }

        if (compressionThresholdReached) {
            // rajo - bugfix
            if (bufferCount > 0) {
              writeToGZip(buffer, 0, bufferCount);
              bufferCount = 0;
            }
            writeToGZip(b);
        } else {
            buffer[bufferCount++] = (byte) b;
        }
        count++; // rajo - bugfix
    }

Similary method (byte b[], int off, int len).

Thanks.

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


Mime
View raw message