Package org.apache.coyote.http11
Class Http11Processor
- java.lang.Object
-
- org.apache.coyote.AbstractProcessorLight
-
- org.apache.coyote.AbstractProcessor
-
- org.apache.coyote.http11.Http11Processor
-
- All Implemented Interfaces:
ActionHook
,Processor
public class Http11Processor extends AbstractProcessor
-
-
Field Summary
-
Fields inherited from class org.apache.coyote.AbstractProcessor
adapter, asyncStateMachine, request, response, socketWrapper, sslSupport, userDataHelper
-
-
Constructor Summary
Constructors Constructor Description Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
ack(ContinueResponseTiming continueResponseTiming)
protected int
available(boolean doRead)
protected void
disableSwallowRequest()
protected AbstractEndpoint.Handler.SocketState
dispatchEndRequest()
Perform any necessary clean-up processing if the dispatch resulted in the completion of processing for the current request.protected void
doHttpUpgrade(UpgradeToken upgradeToken)
Process an HTTP upgrade.protected void
finishResponse()
protected void
flush()
protected boolean
flushBufferedWrite()
Flush any pending writes.java.nio.ByteBuffer
getLeftoverInput()
Allows retrieving additional input during the upgrade process.protected Log
getLog()
UpgradeToken
getUpgradeToken()
Generate an upgrade token.protected boolean
isReadyForWrite()
protected boolean
isRequestBodyFullyRead()
protected boolean
isTrailerFieldsReady()
protected boolean
isTrailerFieldsSupported()
Protocols that support trailer fields should override this method and returntrue
.boolean
isUpgrade()
Processors that implement HTTP upgrade must override this method.void
pause()
Informs the processor that the underlying I/O layer has stopped accepting new connections.protected void
populatePort()
Called when a host header is not present or is empty in the request (e.g.protected void
prepareResponse()
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 void
registerReadInterest()
AbstractEndpoint.Handler.SocketState
service(SocketWrapperBase<?> socketWrapper)
Service a 'standard' HTTP request.protected void
setRequestBody(ByteChunk body)
protected void
setSocketWrapper(SocketWrapperBase<?> socketWrapper)
Set the socket wrapper being used.protected void
setSwallowResponse()
protected void
sslReHandShake()
Processors that can perform a TLS re-handshake (e.g.-
Methods inherited from class org.apache.coyote.AbstractProcessor
action, asyncPostProcess, checkAsyncTimeoutGeneration, dispatch, dispatchNonBlockingRead, doPush, execute, executeDispatches, getAdapter, getAsyncTimeout, getConnectionID, getErrorState, getPopulateRequestAttributesFromSocket, getRequest, getSocketWrapper, getStreamID, isAsync, isPushSupported, isReadyForRead, logAccess, parseHost, populateHost, populateRequestAttributeRemoteHost, populateSslRequestAttributes, processSocketEvent, setAsyncTimeout, setErrorState, setSslSupport, timeoutAsync
-
Methods inherited from class org.apache.coyote.AbstractProcessorLight
addDispatch, clearDispatches, getIteratorAndClearDispatches, process
-
-
-
-
Constructor Detail
-
Http11Processor
public Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter)
-
-
Method Detail
-
service
public AbstractEndpoint.Handler.SocketState service(SocketWrapperBase<?> socketWrapper) throws java.io.IOException
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:
socketWrapper
- The connection 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
-
setSocketWrapper
protected final void setSocketWrapper(SocketWrapperBase<?> socketWrapper)
Description copied from class:AbstractProcessor
Set the socket wrapper being used.- Overrides:
setSocketWrapper
in classAbstractProcessor
- Parameters:
socketWrapper
- The socket wrapper
-
prepareResponse
protected final void prepareResponse() throws java.io.IOException
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:
java.io.IOException
-
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 provides the server port from the local port.
- Overrides:
populatePort
in classAbstractProcessor
-
flushBufferedWrite
protected boolean flushBufferedWrite() throws java.io.IOException
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:
java.io.IOException
- If an I/O error occurs while attempting to flush the data
-
dispatchEndRequest
protected AbstractEndpoint.Handler.SocketState 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
-
getLog
protected Log getLog()
- Specified by:
getLog
in classAbstractProcessorLight
-
finishResponse
protected final void finishResponse() throws java.io.IOException
- Specified by:
finishResponse
in classAbstractProcessor
- Throws:
java.io.IOException
-
ack
protected final void ack(ContinueResponseTiming continueResponseTiming)
- Specified by:
ack
in classAbstractProcessor
-
flush
protected final void flush() throws java.io.IOException
- Specified by:
flush
in classAbstractProcessor
- Throws:
java.io.IOException
-
available
protected final int available(boolean doRead)
- Specified by:
available
in classAbstractProcessor
-
setRequestBody
protected final void setRequestBody(ByteChunk body)
- Specified by:
setRequestBody
in classAbstractProcessor
-
setSwallowResponse
protected final void setSwallowResponse()
- Specified by:
setSwallowResponse
in classAbstractProcessor
-
disableSwallowRequest
protected final void disableSwallowRequest()
- Specified by:
disableSwallowRequest
in classAbstractProcessor
-
sslReHandShake
protected final void sslReHandShake() throws java.io.IOException
Description copied from class:AbstractProcessor
Processors that can perform a TLS re-handshake (e.g. HTTP/1.1) should override this method and implement the re-handshake.- Overrides:
sslReHandShake
in classAbstractProcessor
- 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
-
isRequestBodyFullyRead
protected final boolean isRequestBodyFullyRead()
- Specified by:
isRequestBodyFullyRead
in classAbstractProcessor
-
registerReadInterest
protected final void registerReadInterest()
- Specified by:
registerReadInterest
in classAbstractProcessor
-
isReadyForWrite
protected final boolean isReadyForWrite()
- Specified by:
isReadyForWrite
in classAbstractProcessor
-
getUpgradeToken
public UpgradeToken getUpgradeToken()
Description copied from class:AbstractProcessor
Generate an upgrade token. Processors that implement HTTP upgrade must override this method and provide the necessary token.- Specified by:
getUpgradeToken
in interfaceProcessor
- Overrides:
getUpgradeToken
in classAbstractProcessor
- Returns:
- An upgrade token encapsulating the information required to process the upgrade request
-
doHttpUpgrade
protected final void doHttpUpgrade(UpgradeToken upgradeToken)
Description copied from class:AbstractProcessor
Process an HTTP upgrade. Processors that support HTTP upgrade should override this method and process the provided token.- Overrides:
doHttpUpgrade
in classAbstractProcessor
- Parameters:
upgradeToken
- Contains all the information necessary for the Processor to process the upgrade
-
getLeftoverInput
public java.nio.ByteBuffer getLeftoverInput()
Description copied from class:AbstractProcessor
Allows retrieving additional input during the upgrade process. Processors that implement HTTP upgrade must override this method.- Specified by:
getLeftoverInput
in interfaceProcessor
- Overrides:
getLeftoverInput
in classAbstractProcessor
- Returns:
- leftover bytes
-
isUpgrade
public boolean isUpgrade()
Description copied from class:AbstractProcessor
Processors that implement HTTP upgrade must override this method.- Specified by:
isUpgrade
in interfaceProcessor
- Overrides:
isUpgrade
in classAbstractProcessor
- Returns:
true
if the Processor is currently processing an upgrade request, otherwisefalse
-
isTrailerFieldsReady
protected boolean isTrailerFieldsReady()
- Specified by:
isTrailerFieldsReady
in classAbstractProcessor
-
isTrailerFieldsSupported
protected boolean isTrailerFieldsSupported()
Description copied from class:AbstractProcessor
Protocols that support trailer fields should override this method and returntrue
.- Overrides:
isTrailerFieldsSupported
in classAbstractProcessor
- Returns:
true
if trailer fields are supported by this processor, otherwisefalse
.
-
recycle
public final 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.
-
-