Package org.apache.coyote
Class AbstractProcessor
- java.lang.Object
- 
- org.apache.coyote.AbstractProcessorLight
- 
- org.apache.coyote.AbstractProcessor
 
 
- 
- All Implemented Interfaces:
- ActionHook,- Processor
 - Direct Known Subclasses:
- AjpProcessor,- Http11Processor
 
 public abstract class AbstractProcessor extends AbstractProcessorLight implements ActionHook Provides functionality and attributes common to all supported protocols (currently HTTP and AJP) for processing a single request/response.
- 
- 
Field SummaryFields Modifier and Type Field Description protected Adapteradapterprotected AsyncStateMachineasyncStateMachineprotected AbstractEndpoint<?,?>endpointprotected char[]hostNameCprotected Requestrequestprotected Responseresponseprotected SocketWrapperBase<?>socketWrapperprotected SSLSupportsslSupportprotected UserDataHelperuserDataHelper
 - 
Constructor SummaryConstructors Modifier Constructor Description AbstractProcessor(AbstractEndpoint<?,?> endpoint)protectedAbstractProcessor(AbstractEndpoint<?,?> endpoint, Request coyoteRequest, Response coyoteResponse)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidack()Deprecated.Unused.protected abstract voidack(ContinueResponseTiming continueResponseTiming)voidaction(ActionCode actionCode, java.lang.Object param)Send an action to the connector.AbstractEndpoint.Handler.SocketStateasyncPostProcess()protected abstract intavailable(boolean doRead)booleancheckAsyncTimeoutGeneration()Check to see if the async generation (each cycle of async increments the generation of the AsyncStateMachine) is the same as the generation when the most recent async timeout was triggered.protected abstract voiddisableSwallowRequest()AbstractEndpoint.Handler.SocketStatedispatch(SocketEvent status)Process an in-progress request that is not longer in standard HTTP mode.protected abstract AbstractEndpoint.Handler.SocketStatedispatchEndRequest()Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.protected voiddispatchNonBlockingRead()Perform any necessary processing for a non-blocking read before dispatching to the adapter.protected voiddoHttpUpgrade(UpgradeToken upgradeToken)Process an HTTP upgrade.protected voiddoPush(Request pushTarget)Process a push.protected voidexecuteDispatches()protected abstract voidfinishResponse()protected abstract voidflush()protected abstract booleanflushBufferedWrite()Flush any pending writes.AdaptergetAdapter()Get the associated adapter.longgetAsyncTimeout()protected java.lang.ObjectgetConnectionID()Protocols that support multiplexing (e.g.protected ErrorStategetErrorState()protected java.util.concurrent.ExecutorgetExecutor()java.nio.ByteBuffergetLeftoverInput()Allows retrieving additional input during the upgrade process.protected booleangetPopulateRequestAttributesFromSocket()Processors that populate request attributes directly (e.g.RequestgetRequest()protected SocketWrapperBase<?>getSocketWrapper()protected java.lang.ObjectgetStreamID()Protocols that support multiplexing (e.g.UpgradeTokengetUpgradeToken()Generate an upgrade token.booleanisAsync()protected booleanisPushSupported()Protocols that support push should override this method and returntrue.protected booleanisReadyForRead()protected abstract booleanisReadyForWrite()protected abstract booleanisRequestBodyFullyRead()booleanisUpgrade()Processors that implement HTTP upgrade must override this method.protected voidlogAccess(SocketWrapperBase<?> socketWrapper)Add an entry to the access log for a failed connection attempt.protected voidparseHost(MessageBytes valueMB)protected voidpopulateHost()Called when a host header is not present in the request (e.g.protected voidpopulatePort()Called when a host header is not present or is empty in the request (e.g.protected voidpopulateRequestAttributeRemoteHost()Populate the remote host request attribute.protected voidpopulateSslRequestAttributes()Populate the TLS related request attributes from theSSLSupportinstance associated with this processor.protected abstract voidprepareResponse()protected voidprocessSocketEvent(SocketEvent event, boolean dispatch)voidrecycle()Recycle the processor, ready for the next request which may be on the same connection or a different connection.protected abstract voidregisterReadInterest()voidsetAdapter(Adapter adapter)Set the associated adapter.voidsetAsyncTimeout(long timeout)protected voidsetErrorState(ErrorState errorState, java.lang.Throwable t)Update the current error state to the new error state if the new error state is more severe than the current error state.protected abstract voidsetRequestBody(ByteChunk body)protected voidsetSocketWrapper(SocketWrapperBase<?> socketWrapper)Set the socket wrapper being used.voidsetSslSupport(SSLSupport sslSupport)Set the SSL information for this HTTP connection.protected abstract voidsetSwallowResponse()protected voidsslReHandShake()Processors that can perform a TLS re-handshake (e.g.voidtimeoutAsync(long now)Check this processor to see if the timeout has expired and process a timeout if that is that case.- 
Methods inherited from class org.apache.coyote.AbstractProcessorLightaddDispatch, clearDispatches, getIteratorAndClearDispatches, getLog, process, service
 
- 
 
- 
- 
- 
Field Detail- 
hostNameCprotected char[] hostNameC 
 - 
adapterprotected Adapter adapter 
 - 
asyncStateMachineprotected final AsyncStateMachine asyncStateMachine 
 - 
endpointprotected final AbstractEndpoint<?,?> endpoint 
 - 
requestprotected final Request request 
 - 
responseprotected final Response response 
 - 
socketWrapperprotected volatile SocketWrapperBase<?> socketWrapper 
 - 
sslSupportprotected volatile SSLSupport sslSupport 
 - 
userDataHelperprotected final UserDataHelper userDataHelper 
 
- 
 - 
Constructor Detail- 
AbstractProcessorpublic AbstractProcessor(AbstractEndpoint<?,?> endpoint) 
 - 
AbstractProcessorprotected AbstractProcessor(AbstractEndpoint<?,?> endpoint, Request coyoteRequest, Response coyoteResponse) 
 
- 
 - 
Method Detail- 
setErrorStateprotected void setErrorState(ErrorState errorState, java.lang.Throwable t) Update the current error state to the new error state if the new error state is more severe than the current error state.- Parameters:
- errorState- The error status details
- t- The error which occurred
 
 - 
getErrorStateprotected ErrorState getErrorState() 
 - 
getRequestpublic Request getRequest() - Specified by:
- getRequestin interface- Processor
- Returns:
- The request associated with this processor.
 
 - 
setAdapterpublic void setAdapter(Adapter adapter) Set the associated adapter.- Parameters:
- adapter- the new adapter
 
 - 
getAdapterpublic Adapter getAdapter() Get the associated adapter.- Returns:
- the associated adapter
 
 - 
setSocketWrapperprotected void setSocketWrapper(SocketWrapperBase<?> socketWrapper) Set the socket wrapper being used.- Parameters:
- socketWrapper- The socket wrapper
 
 - 
getSocketWrapperprotected final SocketWrapperBase<?> getSocketWrapper() - Returns:
- the socket wrapper being used.
 
 - 
setSslSupportpublic final void setSslSupport(SSLSupport sslSupport) Description copied from interface:ProcessorSet the SSL information for this HTTP connection.- Specified by:
- setSslSupportin interface- Processor
- Parameters:
- sslSupport- The SSL support object to use for this connection
 
 - 
getExecutorprotected java.util.concurrent.Executor getExecutor() - Returns:
- the Executor used by the underlying endpoint.
 
 - 
asyncPostProcesspublic AbstractEndpoint.Handler.SocketState asyncPostProcess() - Specified by:
- asyncPostProcessin class- AbstractProcessorLight
 
 - 
dispatchpublic final AbstractEndpoint.Handler.SocketState dispatch(SocketEvent status) throws java.io.IOException Description copied from class:AbstractProcessorLightProcess an in-progress request that is not longer in standard HTTP mode. Uses currently include Servlet 3.0 Async and HTTP upgrade connections. Further uses may be added in the future. These will typically start as HTTP requests.- Specified by:
- dispatchin class- AbstractProcessorLight
- Parameters:
- status- The event to process
- Returns:
- The state the caller should put the socket in when this method returns
- Throws:
- java.io.IOException- If an I/O error occurs during the processing of the request
 
 - 
parseHostprotected void parseHost(MessageBytes valueMB) 
 - 
populateHostprotected void populateHost() Called when a host header is not present in the request (e.g. HTTP/1.0). It populates the server name with appropriate information. The source is expected to vary by protocol.The default implementation is a NO-OP. 
 - 
populatePortprotected void populatePort() Called when a host header is not present or is empty in the request (e.g. HTTP/1.0). It populates the server port with appropriate information. The source is expected to vary by protocol.The default implementation is a NO-OP. 
 - 
actionpublic final void action(ActionCode actionCode, java.lang.Object param) Description copied from interface:ActionHookSend an action to the connector.- Specified by:
- actionin interface- ActionHook
- Parameters:
- actionCode- Type of the action
- param- Action parameter
 
 - 
dispatchNonBlockingReadprotected void dispatchNonBlockingRead() Perform any necessary processing for a non-blocking read before dispatching to the adapter.
 - 
timeoutAsyncpublic void timeoutAsync(long now) Check this processor to see if the timeout has expired and process a timeout if that is that case.Note: The name of this method originated with the Servlet 3.0 asynchronous processing but evolved over time to represent a timeout that is triggered independently of the socket read/write timeouts. Sub-classes of this base class represent a single request/response pair. The timeout to be processed is, therefore, the Servlet asynchronous processing timeout. - Specified by:
- timeoutAsyncin interface- Processor
- Parameters:
- now- The time (as returned by- System.currentTimeMillis()to use as the current time to determine whether the timeout has expired. If negative, the timeout will always be treated as ifq it has expired.
 
 - 
checkAsyncTimeoutGenerationpublic boolean checkAsyncTimeoutGeneration() Description copied from interface:ProcessorCheck to see if the async generation (each cycle of async increments the generation of the AsyncStateMachine) is the same as the generation when the most recent async timeout was triggered. This is intended to be used to avoid unnecessary processing.- Specified by:
- checkAsyncTimeoutGenerationin interface- Processor
- Returns:
- trueIf the async generation has not changed since the async timeout was triggered
 
 - 
setAsyncTimeoutpublic void setAsyncTimeout(long timeout) 
 - 
getAsyncTimeoutpublic long getAsyncTimeout() 
 - 
recyclepublic void recycle() Description copied from interface:ProcessorRecycle the processor, ready for the next request which may be on the same connection or a different connection.
 - 
prepareResponseprotected abstract void prepareResponse() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
finishResponseprotected abstract void finishResponse() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
ack@Deprecated protected void ack() Deprecated.Unused. This will be removed in Tomcat 10 onwards. Useack(ContinueResponseTiming).
 - 
ackprotected abstract void ack(ContinueResponseTiming continueResponseTiming) 
 - 
flushprotected abstract void flush() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
availableprotected abstract int available(boolean doRead) 
 - 
setRequestBodyprotected abstract void setRequestBody(ByteChunk body) 
 - 
setSwallowResponseprotected abstract void setSwallowResponse() 
 - 
disableSwallowRequestprotected abstract void disableSwallowRequest() 
 - 
getPopulateRequestAttributesFromSocketprotected boolean getPopulateRequestAttributesFromSocket() Processors that populate request attributes directly (e.g. AJP) should over-ride this method and returnfalse.- Returns:
- trueif the SocketWrapper should be used to populate the request attributes, otherwise- false.
 
 - 
populateRequestAttributeRemoteHostprotected void populateRequestAttributeRemoteHost() Populate the remote host request attribute. Processors (e.g. AJP) that populate this from an alternative source should override this method.
 - 
populateSslRequestAttributesprotected void populateSslRequestAttributes() Populate the TLS related request attributes from theSSLSupportinstance associated with this processor. Protocols that populate TLS attributes from a different source (e.g. AJP) should override this method.
 - 
sslReHandShakeprotected void sslReHandShake() throws java.io.IOExceptionProcessors that can perform a TLS re-handshake (e.g. HTTP/1.1) should override this method and implement the re-handshake.- Throws:
- java.io.IOException- If authentication is required then there will be I/O with the client and this exception will be thrown if that goes wrong
 
 - 
processSocketEventprotected void processSocketEvent(SocketEvent event, boolean dispatch) 
 - 
isReadyForReadprotected boolean isReadyForRead() 
 - 
isRequestBodyFullyReadprotected abstract boolean isRequestBodyFullyRead() 
 - 
registerReadInterestprotected abstract void registerReadInterest() 
 - 
isReadyForWriteprotected abstract boolean isReadyForWrite() 
 - 
executeDispatchesprotected void executeDispatches() 
 - 
getUpgradeTokenpublic UpgradeToken getUpgradeToken() Generate an upgrade token. Processors that implement HTTP upgrade must override this method and provide the necessary token.- Specified by:
- getUpgradeTokenin interface- Processor
- Returns:
- An upgrade token encapsulating the information required to process the upgrade request
 
 - 
doHttpUpgradeprotected void doHttpUpgrade(UpgradeToken upgradeToken) Process an HTTP upgrade. Processors that support HTTP upgrade should override this method and process the provided token.- Parameters:
- upgradeToken- Contains all the information necessary for the Processor to process the upgrade
- Throws:
- java.lang.UnsupportedOperationException- if the protocol does not support HTTP upgrade
 
 - 
getLeftoverInputpublic java.nio.ByteBuffer getLeftoverInput() Allows retrieving additional input during the upgrade process. Processors that implement HTTP upgrade must override this method.- Specified by:
- getLeftoverInputin interface- Processor
- Returns:
- leftover bytes
 
 - 
isUpgradepublic boolean isUpgrade() Processors that implement HTTP upgrade must override this method.
 - 
isPushSupportedprotected boolean isPushSupported() Protocols that support push should override this method and returntrue.- Returns:
- trueif push is supported by this processor, otherwise- false.
 
 - 
doPushprotected void doPush(Request pushTarget) Process a push. Processors that support push should override this method and process the provided token.- Parameters:
- pushTarget- Contains all the information necessary for the Processor to process the push request
- Throws:
- java.lang.UnsupportedOperationException- if the protocol does not support push
 
 - 
getConnectionIDprotected java.lang.Object getConnectionID() Protocols that support multiplexing (e.g. HTTP/2) should override this method and return the appropriate ID.- Returns:
- The stream ID associated with this request or nullif a multiplexing protocol is not being used
 
 - 
getStreamIDprotected java.lang.Object getStreamID() Protocols that support multiplexing (e.g. HTTP/2) should override this method and return the appropriate ID.- Returns:
- The stream ID associated with this request or nullif a multiplexing protocol is not being used
 
 - 
flushBufferedWriteprotected abstract boolean flushBufferedWrite() throws java.io.IOExceptionFlush any pending writes. Used during non-blocking writes to flush any remaining data from a previous incomplete write.- Returns:
- trueif data remains to be flushed at the end of method
- Throws:
- java.io.IOException- If an I/O error occurs while attempting to flush the data
 
 - 
dispatchEndRequestprotected abstract AbstractEndpoint.Handler.SocketState dispatchEndRequest() throws java.io.IOException Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.- Returns:
- The state to return for the socket once the clean-up for the current request has completed
- Throws:
- java.io.IOException- If an I/O error occurs while attempting to end the request
 
 - 
logAccessprotected final void logAccess(SocketWrapperBase<?> socketWrapper) throws java.io.IOException Description copied from class:AbstractProcessorLightAdd an entry to the access log for a failed connection attempt.- Overrides:
- logAccessin class- AbstractProcessorLight
- Parameters:
- socketWrapper- The connection to process
- Throws:
- java.io.IOException- If an I/O error occurs during the processing of the request
 
 
- 
 
-