001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005// http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.http.services;
014
015import org.apache.tapestry5.http.ContentType;
016
017/**
018 * Used to determine if the client supports GZip compression of the response.
019 *
020 * @see CompressionAnalyzer
021 * @see org.apache.tapestry5.http.TapestryHttpSymbolConstants#GZIP_COMPRESSION_ENABLED
022 * @since 5.1.0.0
023 */
024public interface ResponseCompressionAnalyzer
025{
026    /**
027     * Checks the Accept-Encoding request header for a "gzip" token. Ensures that the protocol is not "HTTP/1.0", which
028     * does not correctly support GZip encoding (in older Internet Explorer browsers).
029     *
030     * @return true if gzip is supported by client
031     */
032    boolean isGZipSupported();
033
034    /**
035     * Uses {@link CompressionAnalyzer} to determine if the content is compressable, but only if the request
036     * indicates the client supports compression.
037     *
038     * @param contentType
039     * @return true if the content can be compressed for the current request
040     * @since 5.4
041     */
042    boolean isGZipEnabled(ContentType contentType);
043}