Top Description Fields Constructors Methods
org.apache.coyote

public abstract Class AbstractProcessor

extends AbstractProcessorLight
implements ActionHook
Class Inheritance
All Implemented Interfaces
org.apache.coyote.ActionHook
Known Direct Subclasses
org.apache.coyote.http2.StreamProcessor, org.apache.coyote.ajp.AjpProcessor, org.apache.coyote.http11.Http11Processor
Imports
java.io.IOException, .InterruptedIOException, java.nio.ByteBuffer, java.util.Iterator, java.util.concurrent.RejectedExecutionException, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, java.util.concurrent.locks.Lock, jakarta.servlet.RequestDispatcher, .ServletConnection, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.ByteChunk, .MessageBytes, org.apache.tomcat.util.http.parser.Host, org.apache.tomcat.util.log.UserDataHelper, org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState, .DispatchType, .SSLSupport, .SocketEvent, .SocketWrapperBase, org.apache.tomcat.util.res.StringManager

Provides functionality and attributes common to all supported protocols (currently HTTP and AJP) for processing a single request/response.

Field Summary

Modifier and TypeField and Description
protected final Adapter
protected final AsyncStateMachine
private volatile long
private volatile long
private ErrorState
errorState

Error state for the request/response currently being processed.

private char[]
protected final Request
protected final Response
private static final StringManager
protected volatile SocketWrapperBase<?>
protected volatile SSLSupport
protected final UserDataHelper

Constructor Summary

AccessConstructor and Description
public
protected
AbstractProcessor(Adapter adapter, Request coyoteRequest, Response coyoteResponse)

Method Summary

Modifier and TypeMethod and Description
protected abstract void
ack(ContinueResponseTiming continueResponseTiming)

public final void
action(ActionCode
Type of the action
actionCode
,
Object
Action parameter
param
)

Implements org.apache.coyote.ActionHook.action.

Send an action to the connector.

public AbstractEndpoint.Handler.SocketState
protected abstract int
available(boolean doRead)

public boolean
checkAsyncTimeoutGeneration()

Implements org.apache.coyote.Processor.checkAsyncTimeoutGeneration.

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 void
public final AbstractEndpoint.Handler.SocketState
dispatch(SocketEvent
The event to process
status
)

Implements abstract org.apache.coyote.AbstractProcessorLight.dispatch.

Process an in-progress request that is not longer in standard HTTP mode.

protected abstract AbstractEndpoint.Handler.SocketState

Returns:

The state to return for the socket once the clean-up for the current request has completed
dispatchEndRequest
()

Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.

protected void
dispatchNonBlockingRead()

Perform any necessary processing for a non-blocking read before dispatching to the adapter.

protected void
doHttpUpgrade(UpgradeToken
Contains all the information necessary for the Processor to process the upgrade
upgradeToken
)

Process an HTTP upgrade.

protected void
doPush(Request
Contains all the information necessary for the Processor to process the push request
pushTarget
)

Process a push.

private void
protected void
execute(Runnable
The task representing the processing that needs to take place on a container thread
runnable
)

Provides a mechanism to trigger processing on a container thread.

protected void
protected abstract void
protected abstract void
protected abstract boolean

Returns:

true if data remains to be flushed at the end of method
flushBufferedWrite
()

Flush any pending writes.

public Adapter

Returns:

the associated adapter
getAdapter
()

Get the associated adapter.

public long
protected ErrorState
public ByteBuffer
getLeftoverInput()

Implements org.apache.coyote.Processor.getLeftoverInput.

Allows retrieving additional input during the upgrade process.

protected boolean

Returns:

true if the SocketWrapper should be used to populate the request attributes, otherwise false.
getPopulateRequestAttributesFromSocket
()

Processors that populate request attributes directly (e.g. AJP) should over-ride this method and return false.

protected Object

Returns:

The ID associated with this request or the empty string if no such ID is defined
getProtocolRequestId
()

Protocols that provide per HTTP request IDs (e.g. Stream ID for HTTP/2) should override this method and return the appropriate ID.

public Request
protected abstract ServletConnection

Returns:

the ServletConnection instance associated with the current request.
getServletConnection
()

Protocols must override this method and return an appropriate ServletConnection instance

protected final SocketWrapperBase<?>

Returns:

the socket wrapper being used.
getSocketWrapper
()

public UpgradeToken
getUpgradeToken()

Implements org.apache.coyote.Processor.getUpgradeToken.

Generate an upgrade token.

private void
public boolean
protected boolean

Returns:

true if push is supported by this processor, otherwise false.
isPushSupported
()

Protocols that support push should override this method and return true.

protected boolean
protected abstract boolean
protected abstract boolean
protected abstract boolean
protected boolean

Returns:

true if trailer fields are supported by this processor, otherwise false.
isTrailerFieldsSupported
()

Protocols that support trailer fields should override this method and return true.

public boolean
isUpgrade()

Implements org.apache.coyote.Processor.isUpgrade.

Processors that implement HTTP upgrade must override this method.

protected final void
logAccess(SocketWrapperBase<?>
The connection to process
socketWrapper
)

Overrides org.apache.coyote.AbstractProcessorLight.logAccess.

Add an entry to the access log for a failed connection attempt.

protected void
protected void
populateHost()

Called when a host header is not present in the request (e.g. HTTP/1.0).

protected void
populatePort()

Called when a host header is not present or is empty in the request (e.g. HTTP/1.0).

protected void
populateRequestAttributeRemoteHost()

Populate the remote host request attribute.

protected void
populateSslRequestAttributes()

Populate the TLS related request attributes from the SSLSupport instance associated with this processor.

protected abstract void
protected void
processSocketEvent(SocketEvent event, boolean dispatch)

public void
recycle()

Implements org.apache.coyote.Processor.recycle.

Recycle the processor, ready for the next request which may be on the same connection or a different connection.

protected abstract void
public void
setAsyncTimeout(long timeout)

protected void
setErrorState(ErrorState
The error status details
errorState
,
Throwable
The error which occurred
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 void
protected void
setSocketWrapper(SocketWrapperBase<?>
The socket wrapper
socketWrapper
)

Set the socket wrapper being used.

public final void
setSslSupport(SSLSupport
The SSL support object to use for this connection
sslSupport
)

Implements org.apache.coyote.Processor.setSslSupport.

Set the SSL information for this HTTP connection.

protected abstract void
protected void
sslReHandShake()

Processors that can perform a TLS re-handshake (e.g. HTTP/1.1) should override this method and implement the re-handshake.

public void
timeoutAsync(long
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.
now
)

Implements org.apache.coyote.Processor.timeoutAsync.

Check this processor to see if the timeout has expired and process a timeout if that is that case.

Inherited from org.apache.coyote.AbstractProcessorLight:
addDispatchclearDispatchesgetIteratorAndClearDispatchesgetLogprocessservice

Field Detail

adapterback to summary
protected final Adapter adapter
asyncStateMachineback to summary
protected final AsyncStateMachine asyncStateMachine
asyncTimeoutback to summary
private volatile long asyncTimeout
asyncTimeoutGenerationback to summary
private volatile long asyncTimeoutGeneration
errorStateback to summary
private ErrorState errorState

Error state for the request/response currently being processed.

hostNameCback to summary
private char[] hostNameC
requestback to summary
protected final Request request
responseback to summary
protected final Response response
smback to summary
private static final StringManager sm
socketWrapperback to summary
protected volatile SocketWrapperBase<?> socketWrapper
sslSupportback to summary
protected volatile SSLSupport sslSupport
userDataHelperback to summary
protected final UserDataHelper userDataHelper

Constructor Detail

AbstractProcessorback to summary
public AbstractProcessor(Adapter adapter)
AbstractProcessorback to summary
protected AbstractProcessor(Adapter adapter, Request coyoteRequest, Response coyoteResponse)

Method Detail

ackback to summary
protected abstract void ack(ContinueResponseTiming continueResponseTiming)
actionback to summary
public final void action(ActionCode actionCode, Object param)

Implements org.apache.coyote.ActionHook.action.

Doc from org.apache.coyote.ActionHook.action.

Send an action to the connector.

Parameters
actionCode:ActionCode

Type of the action

param:Object

Action parameter

Annotations
@Override
asyncPostProcessback to summary
public AbstractEndpoint.Handler.SocketState asyncPostProcess()

Implements abstract org.apache.coyote.AbstractProcessorLight.asyncPostProcess.

Annotations
@Override
availableback to summary
protected abstract int available(boolean doRead)
checkAsyncTimeoutGenerationback to summary
public boolean checkAsyncTimeoutGeneration()

Implements org.apache.coyote.Processor.checkAsyncTimeoutGeneration.

Doc from org.apache.coyote.Processor.checkAsyncTimeoutGeneration.

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. This is intended to be used to avoid unnecessary processing.

Returns:boolean

true If the async generation has not changed since the async timeout was triggered

Annotations
@Override
disableSwallowRequestback to summary
protected abstract void disableSwallowRequest()
dispatchback to summary
public final AbstractEndpoint.Handler.SocketState dispatch(SocketEvent status) throws IOException

Implements abstract org.apache.coyote.AbstractProcessorLight.dispatch.

Doc from org.apache.coyote.AbstractProcessorLight.dispatch.

Process 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.

Parameters
status:SocketEvent

The event to process

Returns:AbstractEndpoint.Handler.SocketState

The state the caller should put the socket in when this method returns

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs during the processing of the request
dispatchEndRequestback to summary
protected abstract AbstractEndpoint.Handler.SocketState dispatchEndRequest() throws IOException

Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.

Returns:AbstractEndpoint.Handler.SocketState

The state to return for the socket once the clean-up for the current request has completed

Exceptions
IOException:
If an I/O error occurs while attempting to end the request
dispatchNonBlockingReadback to summary
protected void dispatchNonBlockingRead()

Perform any necessary processing for a non-blocking read before dispatching to the adapter.

doHttpUpgradeback to summary
protected void doHttpUpgrade(UpgradeToken upgradeToken)

Process an HTTP upgrade. Processors that support HTTP upgrade should override this method and process the provided token.

Parameters
upgradeToken:UpgradeToken

Contains all the information necessary for the Processor to process the upgrade

Exceptions
UnsupportedOperationException:
if the protocol does not support HTTP upgrade
doPushback to summary
protected void doPush(Request pushTarget)

Process a push. Processors that support push should override this method and process the provided token.

Parameters
pushTarget:Request

Contains all the information necessary for the Processor to process the push request

Exceptions
UnsupportedOperationException:
if the protocol does not support push
doTimeoutAsyncback to summary
private void doTimeoutAsync()
executeback to summary
protected void execute(Runnable runnable)

Provides a mechanism to trigger processing on a container thread.

Parameters
runnable:Runnable

The task representing the processing that needs to take place on a container thread

executeDispatchesback to summary
protected void executeDispatches()
finishResponseback to summary
protected abstract void finishResponse() throws IOException
flushback to summary
protected abstract void flush() throws IOException
flushBufferedWriteback to summary
protected abstract boolean flushBufferedWrite() throws IOException

Flush any pending writes. Used during non-blocking writes to flush any remaining data from a previous incomplete write.

Returns:boolean

true if data remains to be flushed at the end of method

Exceptions
IOException:
If an I/O error occurs while attempting to flush the data
getAdapterback to summary
public Adapter getAdapter()

Get the associated adapter.

Returns:Adapter

the associated adapter

getAsyncTimeoutback to summary
public long getAsyncTimeout()
getErrorStateback to summary
protected ErrorState getErrorState()
getLeftoverInputback to summary
public ByteBuffer getLeftoverInput()

Implements org.apache.coyote.Processor.getLeftoverInput.

Doc from org.apache.coyote.Processor.getLeftoverInput.

Allows retrieving additional input during the upgrade process. Processors that implement HTTP upgrade must override this method.

Returns:ByteBuffer

leftover bytes

Annotations
@Override
getPopulateRequestAttributesFromSocketback to summary
protected boolean getPopulateRequestAttributesFromSocket()

Processors that populate request attributes directly (e.g. AJP) should over-ride this method and return false.

Returns:boolean

true if the SocketWrapper should be used to populate the request attributes, otherwise false.

getProtocolRequestIdback to summary
protected Object getProtocolRequestId()

Protocols that provide per HTTP request IDs (e.g. Stream ID for HTTP/2) should override this method and return the appropriate ID.

Returns:Object

The ID associated with this request or the empty string if no such ID is defined

getRequestback to summary
public Request getRequest()

Implements org.apache.coyote.Processor.getRequest.

Returns:Request

Doc from org.apache.coyote.Processor.getRequest.

The request associated with this processor.

Annotations
@Override
getServletConnectionback to summary
protected abstract ServletConnection getServletConnection()

Protocols must override this method and return an appropriate ServletConnection instance

Returns:ServletConnection

the ServletConnection instance associated with the current request.

getSocketWrapperback to summary
protected final SocketWrapperBase<?> getSocketWrapper()
Returns:SocketWrapperBase<?>

the socket wrapper being used.

getUpgradeTokenback to summary
public UpgradeToken getUpgradeToken()

Implements org.apache.coyote.Processor.getUpgradeToken.

Doc from org.apache.coyote.Processor.getUpgradeToken.

Generate an upgrade token. Processors that implement HTTP upgrade must override this method and provide the necessary token.

Returns:UpgradeToken

An upgrade token encapsulating the information required to process the upgrade request

Annotations
@Override
handleIOExceptionback to summary
private void handleIOException(IOException ioe)
isAsyncback to summary
public boolean isAsync()

Implements org.apache.coyote.Processor.isAsync.

Annotations
@Override
isPushSupportedback to summary
protected boolean isPushSupported()

Protocols that support push should override this method and return true.

Returns:boolean

true if push is supported by this processor, otherwise false.

isReadyForReadback to summary
protected boolean isReadyForRead()
isReadyForWriteback to summary
protected abstract boolean isReadyForWrite()
isRequestBodyFullyReadback to summary
protected abstract boolean isRequestBodyFullyRead()
isTrailerFieldsReadyback to summary
protected abstract boolean isTrailerFieldsReady()
isTrailerFieldsSupportedback to summary
protected boolean isTrailerFieldsSupported()

Protocols that support trailer fields should override this method and return true.

Returns:boolean

true if trailer fields are supported by this processor, otherwise false.

isUpgradeback to summary
public boolean isUpgrade()

Implements org.apache.coyote.Processor.isUpgrade.

Processors that implement HTTP upgrade must override this method.

Returns:boolean

Doc from org.apache.coyote.Processor.isUpgrade.

true if the Processor is currently processing an upgrade request, otherwise false

Annotations
@Override
logAccessback to summary
protected final void logAccess(SocketWrapperBase<?> socketWrapper) throws IOException

Overrides org.apache.coyote.AbstractProcessorLight.logAccess.

Doc from org.apache.coyote.AbstractProcessorLight.logAccess.

Add an entry to the access log for a failed connection attempt.

Parameters
socketWrapper:SocketWrapperBase<?>

The connection to process

Annotations
@SuppressWarnings:deprecation
@Override
Exceptions
IOException:
If an I/O error occurs during the processing of the request
parseHostback to summary
protected void parseHost(MessageBytes valueMB)
populateHostback to summary
protected 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.

populatePortback to summary
protected 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.

populateRequestAttributeRemoteHostback to summary
protected void populateRequestAttributeRemoteHost()

Populate the remote host request attribute. Processors (e.g. AJP) that populate this from an alternative source should override this method.

populateSslRequestAttributesback to summary
protected void populateSslRequestAttributes()

Populate the TLS related request attributes from the SSLSupport instance associated with this processor. Protocols that populate TLS attributes from a different source (e.g. AJP) should override this method.

prepareResponseback to summary
protected abstract void prepareResponse() throws IOException
processSocketEventback to summary
protected void processSocketEvent(SocketEvent event, boolean dispatch)
recycleback to summary
public void recycle()

Implements org.apache.coyote.Processor.recycle.

Doc from org.apache.coyote.Processor.recycle.

Recycle the processor, ready for the next request which may be on the same connection or a different connection.

Annotations
@Override
registerReadInterestback to summary
protected abstract void registerReadInterest()
setAsyncTimeoutback to summary
public void setAsyncTimeout(long timeout)
setErrorStateback to summary
protected void setErrorState(ErrorState errorState, 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:ErrorState

The error status details

t:Throwable

The error which occurred

Annotations
@SuppressWarnings:deprecation
setRequestBodyback to summary
protected abstract void setRequestBody(ByteChunk body)
setSocketWrapperback to summary
protected void setSocketWrapper(SocketWrapperBase<?> socketWrapper)

Set the socket wrapper being used.

Parameters
socketWrapper:SocketWrapperBase<?>

The socket wrapper

setSslSupportback to summary
public final void setSslSupport(SSLSupport sslSupport)

Implements org.apache.coyote.Processor.setSslSupport.

Doc from org.apache.coyote.Processor.setSslSupport.

Set the SSL information for this HTTP connection.

Parameters
sslSupport:SSLSupport

The SSL support object to use for this connection

Annotations
@Override
setSwallowResponseback to summary
protected abstract void setSwallowResponse()
sslReHandShakeback to summary
protected void sslReHandShake() throws IOException

Processors that can perform a TLS re-handshake (e.g. HTTP/1.1) should override this method and implement the re-handshake.

Exceptions
IOException:
If authentication is required then there will be I/O with the client and this exception will be thrown if that goes wrong
timeoutAsyncback to summary
public void timeoutAsync(long now)

Implements org.apache.coyote.Processor.timeoutAsync.

Doc from org.apache.coyote.Processor.timeoutAsync.

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.

Parameters
now:long

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.

Annotations
@Override