View | Details | Raw Unified | Return to bug 60852
Collapse All | Expand All

(-)java/org/apache/coyote/http11/AbstractHttp11Protocol.java (-10 / +10 lines)
Lines 243-262 Link Here
243
    }
243
    }
244
244
245
245
246
    private String compressableMimeType = "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript";
246
    private String compressibleMimeType = "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript";
247
    private String[] compressableMimeTypes = null;
247
    private String[] compressibleMimeTypes = null;
248
    public String getCompressableMimeType() { return compressableMimeType; }
248
    public String getCompressibleMimeType() { return compressibleMimeType; }
249
    public void setCompressableMimeType(String valueS) {
249
    public void setCompressibleMimeType(String valueS) {
250
        compressableMimeType = valueS;
250
        compressibleMimeType = valueS;
251
        compressableMimeTypes = null;
251
        compressibleMimeTypes = null;
252
    }
252
    }
253
    public String[] getCompressableMimeTypes() {
253
    public String[] getCompressibleMimeTypes() {
254
        String[] result = compressableMimeTypes;
254
        String[] result = compressibleMimeTypes;
255
        if (result != null) {
255
        if (result != null) {
256
            return result;
256
            return result;
257
        }
257
        }
258
        List<String> values = new ArrayList<>();
258
        List<String> values = new ArrayList<>();
259
        StringTokenizer tokens = new StringTokenizer(compressableMimeType, ",");
259
        StringTokenizer tokens = new StringTokenizer(compressibleMimeType, ",");
260
        while (tokens.hasMoreTokens()) {
260
        while (tokens.hasMoreTokens()) {
261
            String token = tokens.nextToken().trim();
261
            String token = tokens.nextToken().trim();
262
            if (token.length() > 0) {
262
            if (token.length() > 0) {
Lines 264-270 Link Here
264
            }
264
            }
265
        }
265
        }
266
        result = values.toArray(new String[values.size()]);
266
        result = values.toArray(new String[values.size()]);
267
        compressableMimeTypes = result;
267
        compressibleMimeTypes = result;
268
        return result;
268
        return result;
269
    }
269
    }
270
270
(-)java/org/apache/coyote/http11/Http11Processor.java (-9 / +9 lines)
Lines 206-212 Link Here
206
    /**
206
    /**
207
     * Check if the resource could be compressed, if the client supports it.
207
     * Check if the resource could be compressed, if the client supports it.
208
     */
208
     */
209
    private boolean isCompressable() {
209
    private boolean isCompressible() {
210
210
211
        // Check if content is not already gzipped
211
        // Check if content is not already gzipped
212
        MessageBytes contentEncodingMB = response.getMimeHeaders().getValue("Content-Encoding");
212
        MessageBytes contentEncodingMB = response.getMimeHeaders().getValue("Content-Encoding");
Lines 223-232 Link Here
223
        // Check if sufficient length to trigger the compression
223
        // Check if sufficient length to trigger the compression
224
        long contentLength = response.getContentLengthLong();
224
        long contentLength = response.getContentLengthLong();
225
        if ((contentLength == -1) || (contentLength > protocol.getCompressionMinSize())) {
225
        if ((contentLength == -1) || (contentLength > protocol.getCompressionMinSize())) {
226
            // Check for compatible MIME-TYPE
226
            // Check for compatible MIME type
227
            String[] compressableMimeTypes = protocol.getCompressableMimeTypes();
227
            String[] compressibleMimeTypes = protocol.getCompressibleMimeTypes();
228
            if (compressableMimeTypes != null) {
228
            if (compressibleMimeTypes != null) {
229
                return (startsWithStringArray(compressableMimeTypes, response.getContentType()));
229
                return (startsWithStringArray(compressibleMimeTypes, response.getContentType()));
230
            }
230
            }
231
        }
231
        }
232
232
Lines 864-874 Link Here
864
        }
864
        }
865
865
866
        // Check for compression
866
        // Check for compression
867
        boolean isCompressable = false;
867
        boolean isCompressible = false;
868
        boolean useCompression = false;
868
        boolean useCompression = false;
869
        if (entityBody && (protocol.getCompressionLevel() > 0) && !sendingWithSendfile) {
869
        if (entityBody && (protocol.getCompressionLevel() > 0) && !sendingWithSendfile) {
870
            isCompressable = isCompressable();
870
            isCompressible = isCompressible();
871
            if (isCompressable) {
871
            if (isCompressible) {
872
                useCompression = useCompression();
872
                useCompression = useCompression();
873
            }
873
            }
874
            // Change content-length to -1 to force chunking
874
            // Change content-length to -1 to force chunking
Lines 921-927 Link Here
921
            headers.setValue("Content-Encoding").setString("gzip");
921
            headers.setValue("Content-Encoding").setString("gzip");
922
        }
922
        }
923
        // If it might be compressed, set the Vary header
923
        // If it might be compressed, set the Vary header
924
        if (isCompressable) {
924
        if (isCompressible) {
925
            // Make Proxies happy via Vary (from mod_deflate)
925
            // Make Proxies happy via Vary (from mod_deflate)
926
            MessageBytes vary = headers.getValue("Vary");
926
            MessageBytes vary = headers.getValue("Vary");
927
            if (vary == null) {
927
            if (vary == null) {
(-)webapps/docs/config/http.xml (-1 / +1 lines)
Lines 347-353 Link Here
347
      provider will be used.</p>
347
      provider will be used.</p>
348
    </attribute>
348
    </attribute>
349
349
350
    <attribute name="compressableMimeType" required="false">
350
    <attribute name="compressibleMimeType" required="false">
351
      <p>The value is a comma separated list of MIME types for which HTTP
351
      <p>The value is a comma separated list of MIME types for which HTTP
352
      compression may be used.
352
      compression may be used.
353
      The default value is
353
      The default value is

Return to bug 60852