Package org.apache.coyote.ajp
Class AjpProcessor
java.lang.Object
org.apache.coyote.AbstractProcessorLight
org.apache.coyote.AbstractProcessor
org.apache.coyote.ajp.AjpProcessor
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
This class is an input buffer which will read its data from an input stream.protected class
This class is an output buffer which will write data to an output stream. -
Field Summary
Fields inherited from class org.apache.coyote.AbstractProcessor
adapter, asyncStateMachine, request, response, socketWrapper, sslSupport, userDataHelper
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
ack
(ContinueResponseTiming continueResponseTiming) Process acknowledgment of the request.protected final int
available
(boolean doRead) Queries if bytes are available in buffers.protected final void
Swallowing bytes is required for pipelining requests, so this allows to avoid doing extra operations in case an error occurs and the connection is to be closed instead.protected AbstractEndpoint.Handler.SocketState
Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.protected void
Perform any necessary processing for a non-blocking read before dispatching to the adapter.protected void
protected final void
Finish the current response.protected final void
flush()
Callback to write data from the buffer.protected boolean
Flush any pending writes.protected Log
getLog()
protected final boolean
Processors that populate request attributes directly (e.g.protected ServletConnection
Protocols must override this method and return an appropriate ServletConnection instanceprotected final boolean
protected final boolean
protected boolean
void
pause()
Informs the processor that the underlying I/O layer has stopped accepting new connections.protected void
Called when a host header is not present in the request (e.g.protected void
Called when a host header is not present or is empty in the request (e.g.protected final void
Populate the remote host request attribute.protected final void
Populate the TLS related request attributes from theSSLSupport
instance associated with this processor.protected final void
When committing the response, we have to validate the set of headers, as well as setup the response filters.void
recycle()
Recycle the processor, ready for the next request which may be on the same connection or a different connection.protected boolean
refillReadBuffer
(boolean block) Get more request body data from the web server and store it in the internal buffer.protected final void
When using non blocking IO, register to get a callback when polling determines that bytes are available for reading.service
(SocketWrapperBase<?> socket) Service a 'standard' HTTP request.protected final void
setRequestBody
(ByteChunk body) Set the specified byte chunk as the request body that will be read.protected final void
The response is finished and no additional bytes need to be sent to the client.Methods inherited from class org.apache.coyote.AbstractProcessor
action, asyncPostProcess, checkAsyncTimeoutGeneration, dispatch, doHttpUpgrade, execute, executeDispatches, getAdapter, getAsyncTimeout, getErrorState, getLeftoverInput, getProtocolRequestId, getRequest, getSocketWrapper, getUpgradeToken, isAsync, isReadyForRead, isTrailerFieldsSupported, isUpgrade, logAccess, parseHost, processSocketEvent, setAsyncTimeout, setErrorState, setSocketWrapper, setSslSupport, sslReHandShake, timeoutAsync
Methods inherited from class org.apache.coyote.AbstractProcessorLight
addDispatch, clearDispatches, getIteratorAndClearDispatches, process
-
Constructor Details
-
AjpProcessor
-
-
Method Details
-
flushBufferedWrite
Description copied from class:AbstractProcessor
Flush any pending writes. Used during non-blocking writes to flush any remaining data from a previous incomplete write.- Specified by:
flushBufferedWrite
in classAbstractProcessor
- Returns:
true
if data remains to be flushed at the end of method- Throws:
IOException
- If an I/O error occurs while attempting to flush the data
-
dispatchNonBlockingRead
protected void dispatchNonBlockingRead()Description copied from class:AbstractProcessor
Perform any necessary processing for a non-blocking read before dispatching to the adapter.- Overrides:
dispatchNonBlockingRead
in classAbstractProcessor
-
dispatchEndRequest
Description copied from class:AbstractProcessor
Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.- Specified by:
dispatchEndRequest
in classAbstractProcessor
- Returns:
- The state to return for the socket once the clean-up for the current request has completed
-
service
Description copied from class:AbstractProcessorLight
Service a 'standard' HTTP request. This method is called for both new requests and for requests that have partially read the HTTP request line or HTTP headers. Once the headers have been fully read this method is not called again until there is a new HTTP request to process. Note that the request type may change during processing which may result in one or more calls toAbstractProcessorLight.dispatch(SocketEvent)
. Requests may be pipe-lined.- Specified by:
service
in classAbstractProcessorLight
- Parameters:
socket
- The connection to process- Returns:
- The state the caller should put the socket in when this method returns
- Throws:
IOException
- If an I/O error occurs during the processing of the request
-
recycle
public void recycle()Description copied from interface:Processor
Recycle the processor, ready for the next request which may be on the same connection or a different connection.- Specified by:
recycle
in interfaceProcessor
- Overrides:
recycle
in classAbstractProcessor
-
pause
public void pause()Description copied from interface:Processor
Informs the processor that the underlying I/O layer has stopped accepting new connections. This is primarily intended to enable processors that use multiplexed connections to prevent further 'streams' being added to an existing multiplexed connection. -
refillReadBuffer
Get more request body data from the web server and store it in the internal buffer.- Parameters:
block
-true
if this is blocking IO- Returns:
true
if there is more data,false
if not.- Throws:
IOException
- An IO error occurred
-
populateHost
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.
This implementation populates the server name from the local name provided by the AJP message.
- Overrides:
populateHost
in classAbstractProcessor
-
populatePort
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.
This implementation populates the server port from the local port provided by the AJP message.
- Overrides:
populatePort
in classAbstractProcessor
-
prepareResponse
When committing the response, we have to validate the set of headers, as well as setup the response filters.- Specified by:
prepareResponse
in classAbstractProcessor
- Throws:
IOException
- IO exception during commit
-
flush
Description copied from class:AbstractProcessor
Callback to write data from the buffer.- Specified by:
flush
in classAbstractProcessor
- Throws:
IOException
- IO exception during the write
-
finishResponse
Description copied from class:AbstractProcessor
Finish the current response.- Specified by:
finishResponse
in classAbstractProcessor
- Throws:
IOException
- IO exception during the write
-
ack
Description copied from class:AbstractProcessor
Process acknowledgment of the request.- Specified by:
ack
in classAbstractProcessor
- Parameters:
continueResponseTiming
- specifies when an acknowledgment should be sent
-
earlyHints
- Specified by:
earlyHints
in classAbstractProcessor
- Throws:
IOException
-
available
protected final int available(boolean doRead) Description copied from class:AbstractProcessor
Queries if bytes are available in buffers.- Specified by:
available
in classAbstractProcessor
- Parameters:
doRead
-true
to perform a read when no bytes are availble- Returns:
- the amount of bytes that are known to be available
-
setRequestBody
Description copied from class:AbstractProcessor
Set the specified byte chunk as the request body that will be read. This allows saving and processing requests.- Specified by:
setRequestBody
in classAbstractProcessor
- Parameters:
body
- the byte chunk containing all the request bytes
-
setSwallowResponse
protected final void setSwallowResponse()Description copied from class:AbstractProcessor
The response is finished and no additional bytes need to be sent to the client.- Specified by:
setSwallowResponse
in classAbstractProcessor
-
disableSwallowRequest
protected final void disableSwallowRequest()Description copied from class:AbstractProcessor
Swallowing bytes is required for pipelining requests, so this allows to avoid doing extra operations in case an error occurs and the connection is to be closed instead.- Specified by:
disableSwallowRequest
in classAbstractProcessor
-
getPopulateRequestAttributesFromSocket
protected final boolean getPopulateRequestAttributesFromSocket()Description copied from class:AbstractProcessor
Processors that populate request attributes directly (e.g. AJP) should over-ride this method and returnfalse
.- Overrides:
getPopulateRequestAttributesFromSocket
in classAbstractProcessor
- Returns:
true
if the SocketWrapper should be used to populate the request attributes, otherwisefalse
.
-
populateRequestAttributeRemoteHost
protected final void populateRequestAttributeRemoteHost()Description copied from class:AbstractProcessor
Populate the remote host request attribute. Processors (e.g. AJP) that populate this from an alternative source should override this method.- Overrides:
populateRequestAttributeRemoteHost
in classAbstractProcessor
-
populateSslRequestAttributes
protected final void populateSslRequestAttributes()Description copied from class:AbstractProcessor
Populate the TLS related request attributes from theSSLSupport
instance associated with this processor. Protocols that populate TLS attributes from a different source (e.g. AJP) should override this method.- Overrides:
populateSslRequestAttributes
in classAbstractProcessor
-
isRequestBodyFullyRead
protected final boolean isRequestBodyFullyRead()- Specified by:
isRequestBodyFullyRead
in classAbstractProcessor
- Returns:
true
if it is known that the request body has been fully read
-
registerReadInterest
protected final void registerReadInterest()Description copied from class:AbstractProcessor
When using non blocking IO, register to get a callback when polling determines that bytes are available for reading.- Specified by:
registerReadInterest
in classAbstractProcessor
-
isReadyForWrite
protected final boolean isReadyForWrite()- Specified by:
isReadyForWrite
in classAbstractProcessor
- Returns:
true
if bytes can be written without blocking
-
isTrailerFieldsReady
protected boolean isTrailerFieldsReady()- Specified by:
isTrailerFieldsReady
in classAbstractProcessor
-
getLog
- Specified by:
getLog
in classAbstractProcessorLight
- Returns:
- the logger associated with this processor type
-
getServletConnection
Description copied from class:AbstractProcessor
Protocols must override this method and return an appropriate ServletConnection instance- Specified by:
getServletConnection
in classAbstractProcessor
- Returns:
- the ServletConnection instance associated with the current request.
-