当前位置: 首页>>代码示例>>Java>>正文


Java MessageBytes.indexOf方法代码示例

本文整理汇总了Java中org.apache.tomcat.util.buf.MessageBytes.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBytes.indexOf方法的具体用法?Java MessageBytes.indexOf怎么用?Java MessageBytes.indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tomcat.util.buf.MessageBytes的用法示例。


在下文中一共展示了MessageBytes.indexOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isCompressable

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Check if the resource could be compressed, if the client supports it.
 */
private boolean isCompressable() {

	// Check if content is not already gzipped
	MessageBytes contentEncodingMB = response.getMimeHeaders().getValue("Content-Encoding");

	if ((contentEncodingMB != null) && (contentEncodingMB.indexOf("gzip") != -1)) {
		return false;
	}

	// If force mode, always compress (test purposes only)
	if (compressionLevel == 2) {
		return true;
	}

	// Check if sufficient length to trigger the compression
	long contentLength = response.getContentLengthLong();
	if ((contentLength == -1) || (contentLength > compressionMinSize)) {
		// Check for compatible MIME-TYPE
		if (compressableMimeTypes != null) {
			return (startsWithStringArray(compressableMimeTypes, response.getContentType()));
		}
	}

	return false;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:29,代码来源:AbstractHttp11Processor.java

示例2: isCompressable

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Check if the resource could be compressed, if the client supports it.
 */
private boolean isCompressable() {

    // Check if content is not already gzipped
    MessageBytes contentEncodingMB =
        response.getMimeHeaders().getValue("Content-Encoding");

    if ((contentEncodingMB != null)
        && (contentEncodingMB.indexOf("gzip") != -1)) {
        return false;
    }

    // If force mode, always compress (test purposes only)
    if (compressionLevel == 2) {
        return true;
    }

    // Check if sufficient length to trigger the compression
    long contentLength = response.getContentLengthLong();
    if ((contentLength == -1)
        || (contentLength > compressionMinSize)) {
        // Check for compatible MIME-TYPE
        if (compressableMimeTypes != null) {
            return (startsWithStringArray(compressableMimeTypes,
                                          response.getContentType()));
        }
    }

    return false;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:AbstractHttp11Processor.java

示例3: useCompression

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Check if compression should be used for this resource. Already checked
 * that the resource could be compressed if the client supports it.
 */
private boolean useCompression() {

    // Check if browser support gzip encoding
    MessageBytes acceptEncodingMB =
        request.getMimeHeaders().getValue("accept-encoding");

    if ((acceptEncodingMB == null)
        || (acceptEncodingMB.indexOf("gzip") == -1)) {
        return false;
    }

    // If force mode, always compress (test purposes only)
    if (compressionLevel == 2) {
        return true;
    }

    // Check for incompatible Browser
    if (noCompressionUserAgents != null) {
        MessageBytes userAgentValueMB =
            request.getMimeHeaders().getValue("user-agent");
        if(userAgentValueMB != null) {
            String userAgentValue = userAgentValueMB.toString();

            if (noCompressionUserAgents.matcher(userAgentValue).matches()) {
                return false;
            }
        }
    }

    return true;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:AbstractHttp11Processor.java

示例4: useCompression

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Check if compression should be used for this resource. Already checked
 * that the resource could be compressed if the client supports it.
 */
private boolean useCompression() {

	// Check if browser support gzip encoding
	MessageBytes acceptEncodingMB = request.getMimeHeaders().getValue("accept-encoding");

	if ((acceptEncodingMB == null) || (acceptEncodingMB.indexOf("gzip") == -1)) {
		return false;
	}

	// If force mode, always compress (test purposes only)
	if (compressionLevel == 2) {
		return true;
	}

	// Check for incompatible Browser
	if (noCompressionUserAgents != null) {
		MessageBytes userAgentValueMB = request.getMimeHeaders().getValue("user-agent");
		if (userAgentValueMB != null) {
			String userAgentValue = userAgentValueMB.toString();

			if (noCompressionUserAgents.matcher(userAgentValue).matches()) {
				return false;
			}
		}
	}

	return true;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:33,代码来源:AbstractHttp11Processor.java

示例5: isCompressable

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Check for compression
 */
private boolean isCompressable() {

    // Nope Compression could works in HTTP 1.0 also
    // cf: mod_deflate

    // Compression only since HTTP 1.1
    // if (! http11)
    //    return false;

    // Check if browser support gzip encoding
    MessageBytes acceptEncodingMB =
        request.getMimeHeaders().getValue("accept-encoding");

    if ((acceptEncodingMB == null)
        || (acceptEncodingMB.indexOf("gzip") == -1))
        return false;

    // Check if content is not allready gzipped
    MessageBytes contentEncodingMB =
        response.getMimeHeaders().getValue("Content-Encoding");

    if ((contentEncodingMB != null)
        && (contentEncodingMB.indexOf("gzip") != -1))
        return false;

    // If force mode, allways compress (test purposes only)
    if (compressionLevel == 2)
       return true;

    // Check for incompatible Browser
    if (noCompressionUserAgents != null) {
        MessageBytes userAgentValueMB =
            request.getMimeHeaders().getValue("user-agent");
        if(userAgentValueMB != null) {
            String userAgentValue = userAgentValueMB.toString();

            // If one Regexp rule match, disable compression
            for (int i = 0; i < noCompressionUserAgents.length; i++)
                if (noCompressionUserAgents[i].matcher(userAgentValue).matches())
                    return false;
        }
    }

    // Check if suffisant len to trig the compression
    long contentLength = response.getContentLengthLong();
    if ((contentLength == -1)
        || (contentLength > compressionMinSize)) {
        // Check for compatible MIME-TYPE
        if (compressableMimeTypes != null) {
            return (startsWithStringArray(compressableMimeTypes,
                                          response.getContentType()));
        }
    }

    return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:60,代码来源:Http11AprProcessor.java


注:本文中的org.apache.tomcat.util.buf.MessageBytes.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。