本文整理汇总了Java中org.apache.tomcat.util.buf.MessageBytes.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBytes.isNull方法的具体用法?Java MessageBytes.isNull怎么用?Java MessageBytes.isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.util.buf.MessageBytes
的用法示例。
在下文中一共展示了MessageBytes.isNull方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentLengthLong
import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public long getContentLengthLong() {
if( contentLength > -1 ) return contentLength;
MessageBytes clB = headers.getUniqueValue("content-length");
contentLength = (clB == null || clB.isNull()) ? -1 : clB.getLong();
return contentLength;
}
示例2: map
import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
* Map the specified host name and URI, mutating the given mapping data.
*
* @param host Virtual host name
* @param uri URI
* @param mappingData This structure will contain the result of the mapping
* operation
*/
public void map(MessageBytes host, MessageBytes uri, String version,
MappingData mappingData)
throws Exception {
if (host.isNull()) {
host.getCharChunk().append(defaultHostName);
}
host.toChars();
uri.toChars();
internalMap(host.getCharChunk(), uri.getCharChunk(), version,
mappingData);
}
示例3: getContentLengthLong
import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
public long getContentLengthLong() {
if (contentLength > -1)
return contentLength;
MessageBytes clB = headers.getUniqueValue("content-length");
contentLength = (clB == null || clB.isNull()) ? -1 : clB.getLong();
return contentLength;
}
示例4: 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;
}
// Uncomment to test the new parsing code
if( cookieValue.getType() == MessageBytes.T_BYTES ) {
if( dbg>0 ) log( "Parsing b[]: " + cookieValue.toString());
ByteChunk bc=cookieValue.getByteChunk();
processCookieHeader( bc.getBytes(),
bc.getOffset(),
bc.getLength());
} else {
if( dbg>0 ) log( "Parsing S: " + cookieValue.toString());
processCookieHeader( cookieValue.toString() );
}
pos++;// search from the next position
}
}
示例5: map
import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
* Map the specified host name and URI, mutating the given mapping data.
*
* @param host Virtual host name
* @param uri URI
* @param mappingData This structure will contain the result of the mapping
* operation
*/
public void map(MessageBytes host, MessageBytes uri,
MappingData mappingData)
throws Exception {
if (host.isNull()) {
host.getCharChunk().append(defaultHostName);
}
host.toChars();
uri.toChars();
internalMap(host.getCharChunk(), uri.getCharChunk(), mappingData);
}
示例6: 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);
}
}
示例7: 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
}
}
示例8: 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
}
}
示例9: 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(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 (!ssl) {
// 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);
}
}
示例10: 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);
}
}
示例11: 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);
}
}
示例12: 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);
}
}
示例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);
}
}
示例14: map
import org.apache.tomcat.util.buf.MessageBytes; //导入方法依赖的package包/类
/**
* Map the specified host name and URI, mutating the given mapping data.
*
* @param host
* Virtual host name
* @param uri
* URI
* @param mappingData
* This structure will contain the result of the mapping
* operation
*/
public void map(MessageBytes host, MessageBytes uri, String version, MappingData mappingData) throws Exception {
if (host.isNull()) {
host.getCharChunk().append(defaultHostName);
}
host.toChars();
uri.toChars();
internalMap(host.getCharChunk(), uri.getCharChunk(), version, mappingData);
}