/**
+ * Comet used.
+ */
+ protected boolean comet = false;
+
+
+ /**
* Regular expression that defines the restricted user agents.
*/
protected Pattern restrictedUserAgents = null;
}
+ public abstract SocketState event(SocketStatus status) throws IOException;
+
+
/**
* Provides a mechanism for those connector implementations (currently only
* NIO) that need to reset timeouts from Async timeouts to standard HTTP
/**
- * Comet used.
- */
- protected boolean comet = false;
-
-
- /**
* Socket associated with the current connection.
*/
protected SocketWrapper<Long> socket = null;
*
* @throws IOException error during an I/O operation
*/
+ @Override
public SocketState event(SocketStatus status)
throws IOException {
@Override
public SocketState process(SocketWrapper<Long> socket,
SocketStatus status) {
- Http11AprProcessor processor =
- connections.remove(socket.getSocket());
+ Http11AprProcessor processor = connections.remove(socket.getSocket());
socket.setAsync(false);
processor = createProcessor();
}
+ initSsl(socket, processor);
+
SocketState state = SocketState.CLOSED;
do {
if (processor.isAsync() || state == SocketState.ASYNC_END) {
recycledProcessors.offer(processor);
}
return state;
-
} catch (java.net.SocketException e) {
// SocketExceptions are normal
log.debug(sm.getString(
return SocketState.CLOSED;
}
+ private void initSsl(SocketWrapper<Long> socket,
+ Http11AprProcessor processor) {
+ // NOOP for APR
+ }
+
protected Http11AprProcessor createProcessor() {
Http11AprProcessor processor = new Http11AprProcessor(
proto.getMaxHttpHeaderSize(), (AprEndpoint)proto.endpoint,
protected NioEndpoint.SendfileData sendfileData = null;
/**
- * Comet used.
- */
- protected boolean comet = false;
-
- /**
* Closed flag, a Comet async thread can
* signal for this Nio processor to be closed and recycled instead
* of waiting for a timeout.
*
* @throws IOException error during an I/O operation
*/
+ @Override
public SocketState event(SocketStatus status)
throws IOException {
processor = createProcessor();
}
- if (proto.isSSLEnabled() &&
- (proto.sslImplementation != null)
- && (socket.getSocket() instanceof SecureNioChannel)) {
- SecureNioChannel ch = (SecureNioChannel)socket.getSocket();
- processor.setSslSupport(
- proto.sslImplementation.getSSLSupport(
- ch.getSslEngine().getSession()));
- } else {
- processor.setSslSupport(null);
- }
+ initSsl(socket, processor);
SocketState state = SocketState.CLOSED;
do {
release(socket, processor);
}
return state;
-
} catch (java.net.SocketException e) {
// SocketExceptions are normal
log.debug(sm.getString(
return SocketState.CLOSED;
}
+ private void initSsl(SocketWrapper<NioChannel> socket,
+ Http11NioProcessor processor) {
+ if (proto.isSSLEnabled() &&
+ (proto.sslImplementation != null)
+ && (socket.getSocket() instanceof SecureNioChannel)) {
+ SecureNioChannel ch = (SecureNioChannel)socket.getSocket();
+ processor.setSslSupport(
+ proto.sslImplementation.getSSLSupport(
+ ch.getSslEngine().getSession()));
+ } else {
+ processor.setSslSupport(null);
+ }
+
+ }
+
public Http11NioProcessor createProcessor() {
Http11NioProcessor processor = new Http11NioProcessor(
proto.getMaxHttpHeaderSize(), (NioEndpoint)proto.endpoint,
}
+ @Override
+ public SocketState event(SocketStatus status) throws IOException {
+ // Should never reach this code but in case we do...
+ throw new IOException(
+ sm.getString("http11processor.comet.notsupported"));
+ }
+
// ----------------------------------------------------- ActionHook Methods
}
@Override
- public SocketState process(SocketWrapper<Socket> socket, SocketStatus status) {
+ public SocketState process(SocketWrapper<Socket> socket,
+ SocketStatus status) {
Http11Processor processor = connections.remove(socket);
+
+ socket.setAsync(false); //no longer check for timeout
+
try {
if (processor == null) {
processor = recycledProcessors.poll();
processor = createProcessor();
}
- if (proto.isSSLEnabled() && (proto.sslImplementation != null)) {
- processor.setSSLSupport(
- proto.sslImplementation.getSSLSupport(
- socket.getSocket()));
- } else {
- processor.setSSLSupport(null);
- }
+ initSsl(socket,processor);
SocketState state = SocketState.CLOSED;
do {
if (processor.isAsync() || state == SocketState.ASYNC_END) {
state = processor.asyncDispatch(status);
+ } else if (processor.comet) {
+ state = processor.event(status);
} else {
state = processor.process(socket);
}
state = processor.asyncPostProcess();
}
} while (state == SocketState.ASYNC_END);
- // TODO Better to add a new state to the AsyncStateMachine and
- // remove ASYNC_END entirely
if (state == SocketState.LONG) {
+ // In the middle of processing a request/response. Keep the
+ // socket associated with the processor.
connections.put(socket, processor);
+ } else if (state == SocketState.OPEN){
+ // In keep-alive but between requests. OK to recycle
+ // processor. Continue to poll for the next request.
+ processor.recycle();
+ recycledProcessors.offer(processor);
} else {
+ // Connection closed. OK to recycle the processor.
processor.recycle();
recycledProcessors.offer(processor);
}
return SocketState.CLOSED;
}
+ private void initSsl(SocketWrapper<Socket> socket,
+ Http11Processor processor) {
+ if (proto.isSSLEnabled() && (proto.sslImplementation != null)) {
+ processor.setSSLSupport(
+ proto.sslImplementation.getSSLSupport(
+ socket.getSocket()));
+ } else {
+ processor.setSSLSupport(null);
+ }
+
+ }
+
protected Http11Processor createProcessor() {
Http11Processor processor = new Http11Processor(
proto.getMaxHttpHeaderSize(), (JIoEndpoint)proto.endpoint,
http11processor.socket.ssl=Exception getting SSL attributes
http11processor.socket.sslreneg=Exception re-negotiating SSL connection
http11processor.socket.timeout=Error setting socket timeout
+http11processor.comet.notsupported=The Comet protocol is not supported by this connector
iib.eof.error=Unexpected EOF read on the socket
iib.requestheadertoolarge.error=Request header is too large