/**
+ * Defines how a connector handles an incomplete request line read.
+ *
+ * @returns <code>true</code> if the processor should break out of the
+ * processing loop, otherwise <code>false</code>.
+ */
+ protected abstract boolean handleIncompleteRequestLineRead();
+
+ /**
* After reading the request headers, we have to setup the request filters.
*/
protected void prepareRequest() {
setRequestLineReadTimeout();
if (!inputBuffer.parseRequestLine(keptAlive)) {
- // This means that no data is available right now
- // (long keepalive), so that the processor should be recycled
- // and the method should return true
- openSocket = true;
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
+ if (handleIncompleteRequestLineRead()) {
break;
}
}
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // This means that no data is available right now
+ // (long keepalive), so that the processor should be recycled
+ // and the method should return true
+ openSocket = true;
+ if (endpoint.isPaused()) {
+ // 503 - Service unavailable
+ response.setStatus(503);
+ adapter.log(request, response, 0);
+ error = true;
+ } else {
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<Long> socketWrapper) {
// NO-OP for APR/native
- return;
}
setRequestLineReadTimeout();
if (!inputBuffer.parseRequestLine(keptAlive)) {
- // Haven't finished reading the request so keep the socket
- // open
- openSocket = true;
- // Check to see if we have read any of the request line yet
- if (inputBuffer.getParsingRequestLinePhase()<2) {
- // No data read, OK to recycle the processor
- // Continue to use keep alive timeout
- if (keepAliveTimeout>0) {
- socketWrapper.setTimeout(keepAliveTimeout);
- }
- } else {
- // Started to read request line. Need to keep processor
- // associated with socket
- readComplete = false;
- }
- if (endpoint.isPaused()) {
- // 503 - Service unavailable
- response.setStatus(503);
- adapter.log(request, response, 0);
- error = true;
- } else {
+ if (handleIncompleteRequestLineRead()) {
break;
}
}
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // Haven't finished reading the request so keep the socket
+ // open
+ openSocket = true;
+ // Check to see if we have read any of the request line yet
+ if (inputBuffer.getParsingRequestLinePhase()<2) {
+ // No data read, OK to recycle the processor
+ // Continue to use keep alive timeout
+ if (keepAliveTimeout>0) {
+ socket.setTimeout(keepAliveTimeout);
+ }
+ } else {
+ // Started to read request line. Need to keep processor
+ // associated with socket
+ readComplete = false;
+ }
+ if (endpoint.isPaused()) {
+ // 503 - Service unavailable
+ response.setStatus(503);
+ adapter.log(request, response, 0);
+ error = true;
+ } else {
+ return true;
+ }
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<NioChannel> socketWrapper) {
// Comet support
SelectionKey key = socketWrapper.getSocket().getIOChannel().keyFor(
keptAlive = socketWrapper.isKeptAlive();
}
- int soTimeout = endpoint.getSoTimeout();
-
if (disableKeepAlive()) {
socketWrapper.setKeepAliveLeft(0);
}
try {
setRequestLineReadTimeout();
- inputBuffer.parseRequestLine(false);
+ if (!inputBuffer.parseRequestLine(false)) {
+ if (handleIncompleteRequestLineRead()) {
+ break;
+ }
+ }
+
if (endpoint.isPaused()) {
// 503 - Service unavailable
response.setStatus(503);
request.setStartTime(System.currentTimeMillis());
keptAlive = true;
// Reset timeout for reading headers
- socket.getSocket().setSoTimeout(soTimeout);
+ socket.getSocket().setSoTimeout(endpoint.getSoTimeout());
inputBuffer.parseHeaders();
if (!disableUploadTimeout) {
socket.getSocket().setSoTimeout(connectionUploadTimeout);
@Override
+ protected boolean handleIncompleteRequestLineRead() {
+ // Not used with BIO since it uses blocking reads
+ return false;
+ }
+
+
+ @Override
protected void setCometTimeouts(SocketWrapper<Socket> socketWrapper) {
// NO-OP for BIO
- return;
}