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


Java MessageBytes.getByteChunk方法代码示例

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


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

示例1: appendBytes

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Write a MessageBytes out at the current write position.
 * A null MessageBytes is encoded as a string with length 0.  
 */
public void appendBytes(MessageBytes mb) {
    if (mb == null) {
        log.error(sm.getString("ajpmessage.null"), 
                new NullPointerException());
        appendInt(0);
        appendByte(0);
        return;
    }
    if (mb.getType() == MessageBytes.T_BYTES) {
        ByteChunk bc = mb.getByteChunk();
        appendByteChunk(bc);
    } else if (mb.getType() == MessageBytes.T_CHARS) {
        CharChunk cc = mb.getCharChunk();
        appendCharChunk(cc);
    } else {
        appendString(mb.toString());
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:AjpMessage.java

示例2: convertMB

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Character conversion of the a US-ASCII MessageBytes.
 */
protected void convertMB(MessageBytes mb) {

    // This is of course only meaningful for bytes
    if (mb.getType() != MessageBytes.T_BYTES)
        return;
    
    ByteChunk bc = mb.getByteChunk();
    CharChunk cc = mb.getCharChunk();
    int length = bc.getLength();
    cc.allocate(length, -1);

    // Default encoding: fast conversion
    byte[] bbuf = bc.getBuffer();
    char[] cbuf = cc.getBuffer();
    int start = bc.getStart();
    for (int i = 0; i < length; i++) {
        cbuf[i] = (char) (bbuf[i + start] & 0xff);
    }
    mb.setChars(cbuf, 0, length);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:CoyoteAdapter.java

示例3: appendBytes

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Write a MessageBytes out at the current write position. A null
 * MessageBytes is encoded as a string with length 0.
 */
public void appendBytes(MessageBytes mb) {
	if (mb == null) {
		log.error(sm.getString("ajpmessage.null"), new NullPointerException());
		appendInt(0);
		appendByte(0);
		return;
	}
	if (mb.getType() == MessageBytes.T_BYTES) {
		ByteChunk bc = mb.getByteChunk();
		appendByteChunk(bc);
	} else if (mb.getType() == MessageBytes.T_CHARS) {
		CharChunk cc = mb.getCharChunk();
		appendCharChunk(cc);
	} else {
		appendString(mb.toString());
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:AjpMessage.java

示例4: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters(MessageBytes data, String encoding) {
	if (data == null || data.isNull() || data.getLength() <= 0) {
		return;
	}

	if (data.getType() != MessageBytes.T_BYTES) {
		data.toBytes();
	}
	ByteChunk bc = data.getByteChunk();
	processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(), getCharset(encoding));
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:Parameters.java

示例5: write

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specified message bytes 
 * buffer to the output stream, without filtering. This method is meant to
 * be used to write the response header.
 * 
 * @param mb data to be written
 */
protected void write(MessageBytes mb) {

    if (mb.getType() == MessageBytes.T_BYTES) {
        ByteChunk bc = mb.getByteChunk();
        write(bc);
    } else if (mb.getType() == MessageBytes.T_CHARS) {
        CharChunk cc = mb.getCharChunk();
        write(cc);
    } else {
        write(mb.toString());
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:AbstractOutputBuffer.java

示例6: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters( MessageBytes data, String encoding ) {
    if( data==null || data.isNull() || data.getLength() <= 0 ) {
        return;
    }

    if( data.getType() != MessageBytes.T_BYTES ) {
        data.toBytes();
    }
    ByteChunk bc=data.getByteChunk();
    processParameters( bc.getBytes(), bc.getOffset(),
                       bc.getLength(), getCharset(encoding));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:Parameters.java

示例7: write

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * This method will write the contents of the specyfied message bytes 
 * buffer to the output stream, without filtering. This method is meant to
 * be used to write the response header.
 * 
 * @param mb data to be written
 */
protected void write(MessageBytes mb) {

    if (mb.getType() == MessageBytes.T_BYTES) {
        ByteChunk bc = mb.getByteChunk();
        write(bc);
    } else if (mb.getType() == MessageBytes.T_CHARS) {
        CharChunk cc = mb.getCharChunk();
        write(cc);
    } else {
        write(mb.toString());
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:InternalOutputBuffer.java

示例8: processParameters

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public void processParameters(MessageBytes data, String encoding) {
    if (data == null || data.isNull() || data.getLength() <= 0)
        return;

    if (data.getType() != MessageBytes.T_BYTES) {
        data.toBytes();
    }
    ByteChunk bc = data.getByteChunk();
    processParameters(bc.getBytes(), bc.getOffset(), bc.getLength(),
            encoding);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:Parameters.java

示例9: parseHost

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Parse host.
 */
protected void parseHost(MessageBytes valueMB) {

    if (valueMB == null || valueMB.isNull()) {
        // HTTP/1.0
        // If no host header, use the port info from the endpoint
        // The host will be obtained lazily from the socket if required
        // using ActionCode#REQ_LOCAL_NAME_ATTRIBUTE
        request.setServerPort(endpoint.getPort());
        return;
    }

    ByteChunk valueBC = valueMB.getByteChunk();
    byte[] valueB = valueBC.getBytes();
    int valueL = valueBC.getLength();
    int valueS = valueBC.getStart();
    int colonPos = -1;
    if (hostNameC.length < valueL) {
        hostNameC = new char[valueL];
    }

    boolean ipv6 = (valueB[valueS] == '[');
    boolean bracketClosed = false;
    for (int i = 0; i < valueL; i++) {
        char b = (char) valueB[i + valueS];
        hostNameC[i] = b;
        if (b == ']') {
            bracketClosed = true;
        } else if (b == ':') {
            if (!ipv6 || bracketClosed) {
                colonPos = i;
                break;
            }
        }
    }

    if (colonPos < 0) {
        if (!endpoint.isSSLEnabled()) {
            // 80 - Default HTTP port
            request.setServerPort(80);
        } else {
            // 443 - Default HTTPS port
            request.setServerPort(443);
        }
        request.serverName().setChars(hostNameC, 0, valueL);
    } else {
        request.serverName().setChars(hostNameC, 0, colonPos);

        int port = 0;
        int mult = 1;
        for (int i = valueL - 1; i > colonPos; i--) {
            int charValue = HexUtils.getDec(valueB[i + valueS]);
            if (charValue == -1 || charValue > 9) {
                // Invalid character
                // 400 - Bad request
                response.setStatus(400);
                setErrorState(ErrorState.CLOSE_CLEAN, null);
                break;
            }
            port = port + (charValue * mult);
            mult = 10 * mult;
        }
        request.setServerPort(port);
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:69,代码来源:AbstractHttp11Processor.java

示例10: processCookies

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Add all Cookie found in the headers of a request.
 */
public void processCookies(MimeHeaders headers) {
	if (headers == null) {
		return;// nothing to process
	}
	// process each "cookie" header
	int pos = 0;
	while (pos >= 0) {
		// Cookie2: version ? not needed
		pos = headers.findHeader("Cookie", pos);
		// no more cookie headers headers
		if (pos < 0) {
			break;
		}

		MessageBytes cookieValue = headers.getValue(pos);
		if (cookieValue == null || cookieValue.isNull()) {
			pos++;
			continue;
		}

		if (cookieValue.getType() != MessageBytes.T_BYTES) {
			Exception e = new Exception();
			log.warn("Cookies: Parsing cookie as String. Expected bytes.", e);
			cookieValue.toBytes();
		}
		if (log.isDebugEnabled()) {
			log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
		}
		ByteChunk bc = cookieValue.getByteChunk();
		if (CookieSupport.PRESERVE_COOKIE_HEADER) {
			int len = bc.getLength();
			if (len > 0) {
				byte[] buf = new byte[len];
				System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
				processCookieHeader(buf, 0, len);
			}
		} else {
			processCookieHeader(bc.getBytes(), bc.getOffset(), bc.getLength());
		}
		pos++;// search from the next position
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:Cookies.java

示例11: processCookies

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/** Add all Cookie found in the headers of a request.
 */
public  void processCookies( MimeHeaders headers ) {
    if( headers==null ) {
        return;// nothing to process
    }
    // process each "cookie" header
    int pos=0;
    while( pos>=0 ) {
        // Cookie2: version ? not needed
        pos=headers.findHeader( "Cookie", pos );
        // no more cookie headers headers
        if( pos<0 ) {
            break;
        }

        MessageBytes cookieValue=headers.getValue( pos );
        if( cookieValue==null || cookieValue.isNull() ) {
            pos++;
            continue;
        }

        if( cookieValue.getType() != MessageBytes.T_BYTES ) {
            Exception e = new Exception();
            log.warn("Cookies: Parsing cookie as String. Expected bytes.",
                    e);
            cookieValue.toBytes();
        }
        if(log.isDebugEnabled()) {
            log.debug("Cookies: Parsing b[]: " + cookieValue.toString());
        }
        ByteChunk bc=cookieValue.getByteChunk();
        if (CookieSupport.PRESERVE_COOKIE_HEADER) {
            int len = bc.getLength();
            if (len > 0) {
                byte[] buf = new byte[len];
                System.arraycopy(bc.getBytes(), bc.getOffset(), buf, 0, len);
                processCookieHeader(buf, 0, len);
            }
        } else {
            processCookieHeader( bc.getBytes(),
                    bc.getOffset(),
                    bc.getLength());
        }
        pos++;// search from the next position
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:48,代码来源:Cookies.java

示例12: parseHost

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Parse host.
 */
public void parseHost(MessageBytes valueMB) {

    if (valueMB == null || (valueMB != null && valueMB.isNull()) ) {
        // HTTP/1.0
        request.setServerPort(request.getLocalPort());
        try {
            request.serverName().duplicate(request.localName());
        } catch (IOException e) {
            response.setStatus(400);
            error = true;
        }
        return;
    }

    ByteChunk valueBC = valueMB.getByteChunk();
    byte[] valueB = valueBC.getBytes();
    int valueL = valueBC.getLength();
    int valueS = valueBC.getStart();
    int colonPos = -1;
    if (hostNameC.length < valueL) {
        hostNameC = new char[valueL];
    }

    boolean ipv6 = (valueB[valueS] == '[');
    boolean bracketClosed = false;
    for (int i = 0; i < valueL; i++) {
        char b = (char) valueB[i + valueS];
        hostNameC[i] = b;
        if (b == ']') {
            bracketClosed = true;
        } else if (b == ':') {
            if (!ipv6 || bracketClosed) {
                colonPos = i;
                break;
            }
        }
    }

    if (colonPos < 0) {
        if (request.scheme().equalsIgnoreCase("https")) {
            // 443 - Default HTTPS port
            request.setServerPort(443);
        } else {
            // 80 - Default HTTTP port
            request.setServerPort(80);
        }
        request.serverName().setChars(hostNameC, 0, valueL);
    } else {

        request.serverName().setChars(hostNameC, 0, colonPos);

        int port = 0;
        int mult = 1;
        for (int i = valueL - 1; i > colonPos; i--) {
            int charValue = HexUtils.DEC[(int) valueB[i + valueS]];
            if (charValue == -1) {
                // Invalid character
                error = true;
                // 400 - Bad request
                response.setStatus(400);
                break;
            }
            port = port + (charValue * mult);
            mult = 10 * mult;
        }
        request.setServerPort(port);

    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:74,代码来源:AjpProcessor.java

示例13: parseHost

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Parse host.
 */
protected void parseHost(MessageBytes valueMB) {

	if (valueMB == null || valueMB.isNull()) {
		// HTTP/1.0
		request.setServerPort(request.getLocalPort());
		try {
			request.serverName().duplicate(request.localName());
		} catch (IOException e) {
			response.setStatus(400);
			setErrorState(ErrorState.CLOSE_CLEAN, e);
		}
		return;
	}

	ByteChunk valueBC = valueMB.getByteChunk();
	byte[] valueB = valueBC.getBytes();
	int valueL = valueBC.getLength();
	int valueS = valueBC.getStart();
	int colonPos = -1;
	if (hostNameC.length < valueL) {
		hostNameC = new char[valueL];
	}

	boolean ipv6 = (valueB[valueS] == '[');
	boolean bracketClosed = false;
	for (int i = 0; i < valueL; i++) {
		char b = (char) valueB[i + valueS];
		hostNameC[i] = b;
		if (b == ']') {
			bracketClosed = true;
		} else if (b == ':') {
			if (!ipv6 || bracketClosed) {
				colonPos = i;
				break;
			}
		}
	}

	if (colonPos < 0) {
		if (request.scheme().equalsIgnoreCase("https")) {
			// 443 - Default HTTPS port
			request.setServerPort(443);
		} else {
			// 80 - Default HTTTP port
			request.setServerPort(80);
		}
		request.serverName().setChars(hostNameC, 0, valueL);
	} else {

		request.serverName().setChars(hostNameC, 0, colonPos);

		int port = 0;
		int mult = 1;
		for (int i = valueL - 1; i > colonPos; i--) {
			int charValue = HexUtils.getDec(valueB[i + valueS]);
			if (charValue == -1) {
				// Invalid character
				// 400 - Bad request
				response.setStatus(400);
				setErrorState(ErrorState.CLOSE_CLEAN, null);
				break;
			}
			port = port + (charValue * mult);
			mult = 10 * mult;
		}
		request.setServerPort(port);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:72,代码来源:AbstractAjpProcessor.java

示例14: parseHost

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Parse host.
 */
protected void parseHost(MessageBytes valueMB) {

	if (valueMB == null || valueMB.isNull()) {
		// HTTP/1.0
		// If no host header, use the port info from the endpoint
		// The host will be obtained lazily from the socket if required
		// using ActionCode#REQ_LOCAL_NAME_ATTRIBUTE
		request.setServerPort(endpoint.getPort());
		return;
	}

	ByteChunk valueBC = valueMB.getByteChunk();
	byte[] valueB = valueBC.getBytes();
	int valueL = valueBC.getLength();
	int valueS = valueBC.getStart();
	int colonPos = -1;
	if (hostNameC.length < valueL) {
		hostNameC = new char[valueL];
	}

	boolean ipv6 = (valueB[valueS] == '[');
	boolean bracketClosed = false;
	for (int i = 0; i < valueL; i++) {
		char b = (char) valueB[i + valueS];
		hostNameC[i] = b;
		if (b == ']') {
			bracketClosed = true;
		} else if (b == ':') {
			if (!ipv6 || bracketClosed) {
				colonPos = i;
				break;
			}
		}
	}

	if (colonPos < 0) {
		if (!endpoint.isSSLEnabled()) {
			// 80 - Default HTTP port
			request.setServerPort(80);
		} else {
			// 443 - Default HTTPS port
			request.setServerPort(443);
		}
		request.serverName().setChars(hostNameC, 0, valueL);
	} else {
		request.serverName().setChars(hostNameC, 0, colonPos);

		int port = 0;
		int mult = 1;
		for (int i = valueL - 1; i > colonPos; i--) {
			int charValue = HexUtils.getDec(valueB[i + valueS]);
			if (charValue == -1 || charValue > 9) {
				// Invalid character
				// 400 - Bad request
				response.setStatus(400);
				setErrorState(ErrorState.CLOSE_CLEAN, null);
				break;
			}
			port = port + (charValue * mult);
			mult = 10 * mult;
		}
		request.setServerPort(port);
	}

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

示例15: parseHost

import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
 * Parse host.
 */
public void parseHost(MessageBytes valueMB) {

    if (valueMB == null || valueMB.isNull()) {
        // HTTP/1.0
        // Default is what the socket tells us. Overriden if a host is
        // found/parsed
        request.setServerPort(socket.getLocalPort());
        InetAddress localAddress = socket.getLocalAddress();
        // Setting the socket-related fields. The adapter doesn't know
        // about socket.
        request.serverName().setString(localAddress.getHostName());
        return;
    }

    ByteChunk valueBC = valueMB.getByteChunk();
    byte[] valueB = valueBC.getBytes();
    int valueL = valueBC.getLength();
    int valueS = valueBC.getStart();
    int colonPos = -1;
    if (hostNameC.length < valueL) {
        hostNameC = new char[valueL];
    }

    boolean ipv6 = (valueB[valueS] == '[');
    boolean bracketClosed = false;
    for (int i = 0; i < valueL; i++) {
        char b = (char) valueB[i + valueS];
        hostNameC[i] = b;
        if (b == ']') {
            bracketClosed = true;
        } else if (b == ':') {
            if (!ipv6 || bracketClosed) {
                colonPos = i;
                break;
            }
        }
    }

    if (colonPos < 0) {
        if (sslSupport == null) {
            // 80 - Default HTTP port
            request.setServerPort(80);
        } else {
            // 443 - Default HTTPS port
            request.setServerPort(443);
        }
        request.serverName().setChars(hostNameC, 0, valueL);
    } else {

        request.serverName().setChars(hostNameC, 0, colonPos);

        int port = 0;
        int mult = 1;
        for (int i = valueL - 1; i > colonPos; i--) {
            int charValue = HexUtils.DEC[valueB[i + valueS]];
            if (charValue == -1) {
                // Invalid character
                error = true;
                // 400 - Bad request
                response.setStatus(400);
                break;
            }
            port = port + (charValue * mult);
            mult = 10 * mult;
        }
        request.setServerPort(port);

    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:74,代码来源:Http11Processor.java


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