001// Copyright 2009, 2011, 2012 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007// http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.services;
016
017import org.apache.tapestry5.services.assets.CompressionAnalyzer;
018
019/**
020 * Used to determine if the client supports GZIP compression of the response.
021 *
022 * @see ResponseCompressionAnalyzer
023 * @since 5.1.0.0
024 */
025public interface ResponseCompressionAnalyzer
026{
027    /**
028     * Checks the Accept-Encoding request header for a "gzip" token. Ensures that the protocol is not "HTTP/1.0", which
029     * does not correctly support GZip encoding (in older Internet Explorer browsers).
030     *
031     * @return true if gzip is supported by client
032     */
033    boolean isGZipSupported();
034
035    /**
036     * Checks to see if the indicated content type is compressable. Many formats are already compressed; pushing them
037     * through a GZip filter consumes cycles and makes them larger.
038     * <p/>
039     * Contribute content type strings to the service's configuration to mark them as not compressable.
040     *
041     * @param contentType
042     *         the mime type of the content, such as "text/html" or "image/jpeg".
043     * @return true if compression is worthwhile
044     * @deprecated Deprecated in Tapestry 5.3. This method is to be removed at a later date. The service's configuration
045     *             is no longer used. Instead, contribute to and use {@link CompressionAnalyzer}.
046     */
047    boolean isCompressable(String contentType);
048}