本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}