// Check connection header
MessageBytes connectionValueMB =
request.getMimeHeaders().getValue("connection");
if (connectionValueMB != null) {
ByteChunk connectionValueBC = connectionValueMB.getByteChunk();
if (findBytes(connectionValueBC, Constants.CLOSE_BYTES) != -1) {
keepAlive = false;
} else if (findBytes(connectionValueBC,
Constants.KEEPALIVE_BYTES) != -1) {
keepAlive = true;
}
}
MessageBytes expectMB = null;
if (http11)
expectMB = request.getMimeHeaders().getValue("expect");
if ((expectMB != null)
&& (expectMB.indexOfIgnoreCase("100-continue", 0) != -1)) {
inputBuffer.setSwallowInput(false);
expectation = true;
}
// Check user-agent header
if ((restrictedUserAgents != null) && ((http11) || (keepAlive))) {
MessageBytes userAgentValueMB =
request.getMimeHeaders().getValue("user-agent");
// Check in the restricted list, and adjust the http11
// and keepAlive flags accordingly
if(userAgentValueMB != null) {
String userAgentValue = userAgentValueMB.toString();
for (int i = 0; i < restrictedUserAgents.length; i++) {
if (restrictedUserAgents[i].match(userAgentValue)) {
http11 = false;
keepAlive = false;
break;
}
}
}
}
// Check for a full URI (including protocol://host:port/)
ByteChunk uriBC = request.requestURI().getByteChunk();
if (uriBC.startsWithIgnoreCase("http", 0)) {
int pos = uriBC.indexOf("://", 0, 3, 4);
int uriBCStart = uriBC.getStart();
int slashPos = -1;
if (pos != -1) {
byte[] uriB = uriBC.getBytes();
slashPos = uriBC.indexOf('/', pos + 3);
if (slashPos == -1) {
slashPos = uriBC.getLength();
// Set URI as "/"
request.requestURI().setBytes
(uriB, uriBCStart + pos + 1, 1);
} else {
request.requestURI().setBytes
(uriB, uriBCStart + slashPos,
uriBC.getLength() - slashPos);
}
MessageBytes hostMB =
request.getMimeHeaders().setValue("host");
hostMB.setBytes(uriB, uriBCStart + pos + 3,
slashPos - pos - 3);