Top Fields Constructors Methods
org.apache.coyote.http11

public Class Http11Processor

extends AbstractProcessor
Class Inheritance
Imports
java.io.IOException, .InterruptedIOException, java.nio.ByteBuffer, java.util.ArrayList, .HashSet, .List, .Set, java.util.regex.Pattern, jakarta.servlet.ServletConnection, jakarta.servlet.http.HttpServletResponse, org.apache.coyote.AbstractProcessor, .ActionCode, .Adapter, .ContinueResponseTiming, .ErrorState, .Request, .RequestInfo, .UpgradeProtocol, .UpgradeToken, org.apache.coyote.http11.filters.BufferedInputFilter, .ChunkedInputFilter, .ChunkedOutputFilter, .GzipOutputFilter, .IdentityInputFilter, .IdentityOutputFilter, .SavedRequestInputFilter, .VoidInputFilter, .VoidOutputFilter, org.apache.coyote.http11.upgrade.InternalHttpUpgradeHandler, .UpgradeApplicationBufferHandler, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.ByteChunk, .MessageBytes, org.apache.tomcat.util.http.FastHttpDateFormat, .MimeHeaders, org.apache.tomcat.util.http.parser.HttpParser, .TokenList, org.apache.tomcat.util.log.UserDataHelper, org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState, .ApplicationBufferHandler, .SSLSupport, .SendfileDataBase, .SendfileKeepAliveState, .SendfileState, .SocketWrapperBase, org.apache.tomcat.util.res.StringManager

Field Summary

Modifier and TypeField and Description
private boolean
contentDelimitation

Content delimiter for the request (if false, the connection will be closed at the end of the request).

private boolean
http09

HTTP/0.9 flag.

private boolean
http11

HTTP/1.1 flag.

private final HttpParser
private final Http11InputBuffer
private volatile boolean
keepAlive

Keep-alive.

private static final Log
private volatile boolean
openSocket

Flag used to indicate that the socket should be kept open (e.g. for keep alive or send file).

private final Http11OutputBuffer
outputBuffer

Output.

private int
pluggableFilterIndex

Tracks how many internal filters are in the filter library so they are skipped when looking for pluggable filters.

private final AbstractHttp11Protocol<?>
private volatile boolean
readComplete

Flag that indicates if the request headers have been completely read.

private SendfileDataBase
sendfileData

Sendfile data.

private static final StringManager
sm

Hides org.apache.coyote.AbstractProcessor.sm.

The string manager for this package.
private UpgradeToken
upgradeToken

Instance of the new protocol to use after the HTTP connection has been upgraded.

Inherited from org.apache.coyote.AbstractProcessor:
adapterasyncStateMachinerequestresponsesocketWrappersslSupportuserDataHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Implements abstract org.apache.coyote.AbstractProcessor.ack.

private void
addInputFilter(InputFilter[] inputFilters, String encodingName)

Add an input filter to the current request.

protected final int
available(boolean doRead)

Implements abstract org.apache.coyote.AbstractProcessor.available.

private void
badRequest(String errorKey)

private void
private void
private Request
protected final void
protected AbstractEndpoint.Handler.SocketState
dispatchEndRequest()

Implements abstract org.apache.coyote.AbstractProcessor.dispatchEndRequest.

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

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

Overrides org.apache.coyote.AbstractProcessor.doHttpUpgrade.

Process an HTTP upgrade.

private void
protected final void
protected final void
protected boolean
flushBufferedWrite()

Implements abstract org.apache.coyote.AbstractProcessor.flushBufferedWrite.

Flush any pending writes.

public ByteBuffer
getLeftoverInput()

Overrides org.apache.coyote.AbstractProcessor.getLeftoverInput.

Implements org.apache.coyote.Processor.getLeftoverInput.

Allows retrieving additional input during the upgrade process.

protected Log
protected ServletConnection
getServletConnection()

Implements abstract org.apache.coyote.AbstractProcessor.getServletConnection.

Protocols must override this method and return an appropriate ServletConnection instance

public UpgradeToken
private boolean
private static boolean
protected final boolean
protected final boolean
protected boolean
protected boolean
isTrailerFieldsSupported()

Overrides org.apache.coyote.AbstractProcessor.isTrailerFieldsSupported.

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

public boolean
isUpgrade()

Overrides org.apache.coyote.AbstractProcessor.isUpgrade.

Implements org.apache.coyote.Processor.isUpgrade.

Processors that implement HTTP upgrade must override this method.

public void
pause()

Implements org.apache.coyote.Processor.pause.

Informs the processor that the underlying I/O layer has stopped accepting new connections.

protected void
populatePort()

Overrides org.apache.coyote.AbstractProcessor.populatePort.

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

private void
private void
private void
prepareRequest()

After reading the request headers, we have to setup the request filters.

private void
protected final void
prepareResponse()

Implements abstract org.apache.coyote.AbstractProcessor.prepareResponse.

When committing the response, we have to validate the set of headers, as well as setup the response filters.

private void
prepareSendfile(OutputFilter[] outputFilters)

private SendfileState

Returns:

The state of send file processing
processSendfile
(SocketWrapperBase<?> socketWrapper)

Trigger sendfile processing if required.

public final void
recycle()

Overrides org.apache.coyote.AbstractProcessor.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 final void
public AbstractEndpoint.Handler.SocketState
service(SocketWrapperBase<?>
The connection to process
socketWrapper
)

Implements abstract org.apache.coyote.AbstractProcessorLight.service.

Service a 'standard' HTTP request.

protected final void
protected final void
setSocketWrapper(SocketWrapperBase<?>
The socket wrapper
socketWrapper
)

Overrides org.apache.coyote.AbstractProcessor.setSocketWrapper.

Set the socket wrapper being used.

protected final void
protected final void
sslReHandShake()

Overrides org.apache.coyote.AbstractProcessor.sslReHandShake.

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

private static boolean
statusDropsConnection(int status)

Determine if we must drop the connection because of the HTTP status code.

Inherited from org.apache.coyote.AbstractProcessor:
actionasyncPostProcesscheckAsyncTimeoutGenerationdispatchdispatchNonBlockingReaddoPushexecuteexecuteDispatchesgetAdaptergetAsyncTimeoutgetErrorStategetPopulateRequestAttributesFromSocketgetProtocolRequestIdgetRequestgetSocketWrapperisAsyncisPushSupportedisReadyForReadlogAccessparseHostpopulateHostpopulateRequestAttributeRemoteHostpopulateSslRequestAttributesprocessSocketEventsetAsyncTimeoutsetErrorStatesetSslSupporttimeoutAsync

Field Detail

contentDelimitationback to summary
private boolean contentDelimitation

Content delimiter for the request (if false, the connection will be closed at the end of the request).

http09back to summary
private boolean http09

HTTP/0.9 flag.

http11back to summary
private boolean http11

HTTP/1.1 flag.

httpParserback to summary
private final HttpParser httpParser
inputBufferback to summary
private final Http11InputBuffer inputBuffer

Input.

keepAliveback to summary
private volatile boolean keepAlive

Keep-alive.

logback to summary
private static final Log log
openSocketback to summary
private volatile boolean openSocket

Flag used to indicate that the socket should be kept open (e.g. for keep alive or send file).

outputBufferback to summary
private final Http11OutputBuffer outputBuffer

Output.

pluggableFilterIndexback to summary
private int pluggableFilterIndex

Tracks how many internal filters are in the filter library so they are skipped when looking for pluggable filters.

protocolback to summary
private final AbstractHttp11Protocol<?> protocol
readCompleteback to summary
private volatile boolean readComplete

Flag that indicates if the request headers have been completely read.

sendfileDataback to summary
private SendfileDataBase sendfileData

Sendfile data.

smback to summary
private static final StringManager sm

Hides org.apache.coyote.AbstractProcessor.sm.

The string manager for this package.

upgradeTokenback to summary
private UpgradeToken upgradeToken

Instance of the new protocol to use after the HTTP connection has been upgraded.

Constructor Detail

Http11Processorback to summary
public Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter)
Annotations
@SuppressWarnings:deprecation

Method Detail

ackback to summary
protected final void ack(ContinueResponseTiming continueResponseTiming)

Implements abstract org.apache.coyote.AbstractProcessor.ack.

Annotations
@Override
addInputFilterback to summary
private void addInputFilter(InputFilter[] inputFilters, String encodingName)

Add an input filter to the current request. If the encoding is not supported, a 501 response will be returned to the client.

availableback to summary
protected final int available(boolean doRead)

Implements abstract org.apache.coyote.AbstractProcessor.available.

Annotations
@Override
badRequestback to summary
private void badRequest(String errorKey)
checkExpectationAndResponseStatusback to summary
private void checkExpectationAndResponseStatus()
checkMaxSwallowSizeback to summary
private void checkMaxSwallowSize()
cloneRequestback to summary
private Request cloneRequest(Request source) throws IOException
disableSwallowRequestback to summary
protected final void disableSwallowRequest()

Implements abstract org.apache.coyote.AbstractProcessor.disableSwallowRequest.

Annotations
@Override
dispatchEndRequestback to summary
protected AbstractEndpoint.Handler.SocketState dispatchEndRequest()

Implements abstract org.apache.coyote.AbstractProcessor.dispatchEndRequest.

Doc from org.apache.coyote.AbstractProcessor.dispatchEndRequest.

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

Annotations
@Override
doHttpUpgradeback to summary
protected final void doHttpUpgrade(UpgradeToken upgradeToken)

Overrides org.apache.coyote.AbstractProcessor.doHttpUpgrade.

Doc from org.apache.coyote.AbstractProcessor.doHttpUpgrade.

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

Annotations
@Override
endRequestback to summary
private void endRequest()
finishResponseback to summary
protected final void finishResponse() throws IOException

Implements abstract org.apache.coyote.AbstractProcessor.finishResponse.

Annotations
@Override
flushback to summary
protected final void flush() throws IOException

Implements abstract org.apache.coyote.AbstractProcessor.flush.

Annotations
@Override
flushBufferedWriteback to summary
protected boolean flushBufferedWrite() throws IOException

Implements abstract org.apache.coyote.AbstractProcessor.flushBufferedWrite.

Doc from org.apache.coyote.AbstractProcessor.flushBufferedWrite.

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

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs while attempting to flush the data
getLeftoverInputback to summary
public ByteBuffer getLeftoverInput()

Overrides org.apache.coyote.AbstractProcessor.getLeftoverInput.

Implements org.apache.coyote.Processor.getLeftoverInput.

Doc from org.apache.coyote.AbstractProcessor.getLeftoverInput.

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

Returns:ByteBuffer

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

leftover bytes

Annotations
@Override
getLogback to summary
protected Log getLog()

Implements abstract org.apache.coyote.AbstractProcessorLight.getLog.

Annotations
@Override
getServletConnectionback to summary
protected ServletConnection getServletConnection()

Implements abstract org.apache.coyote.AbstractProcessor.getServletConnection.

Doc from org.apache.coyote.AbstractProcessor.getServletConnection.

Protocols must override this method and return an appropriate ServletConnection instance

Returns:ServletConnection

the ServletConnection instance associated with the current request.

Annotations
@Override
getUpgradeTokenback to summary
public UpgradeToken getUpgradeToken()

Overrides org.apache.coyote.AbstractProcessor.getUpgradeToken.

Implements org.apache.coyote.Processor.getUpgradeToken.

Doc from org.apache.coyote.AbstractProcessor.getUpgradeToken.

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

Returns:UpgradeToken

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

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

Annotations
@Override
handleIncompleteRequestLineReadback to summary
private boolean handleIncompleteRequestLineRead()
isConnectionTokenback to summary
private static boolean isConnectionToken(MimeHeaders headers, String token) throws IOException
isReadyForWriteback to summary
protected final boolean isReadyForWrite()

Implements abstract org.apache.coyote.AbstractProcessor.isReadyForWrite.

Annotations
@Override
isRequestBodyFullyReadback to summary
protected final boolean isRequestBodyFullyRead()

Implements abstract org.apache.coyote.AbstractProcessor.isRequestBodyFullyRead.

Annotations
@Override
isTrailerFieldsReadyback to summary
protected boolean isTrailerFieldsReady()

Implements abstract org.apache.coyote.AbstractProcessor.isTrailerFieldsReady.

Annotations
@Override
isTrailerFieldsSupportedback to summary
protected boolean isTrailerFieldsSupported()

Overrides org.apache.coyote.AbstractProcessor.isTrailerFieldsSupported.

Doc from org.apache.coyote.AbstractProcessor.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.

Annotations
@Override
isUpgradeback to summary
public boolean isUpgrade()

Overrides org.apache.coyote.AbstractProcessor.isUpgrade.

Implements org.apache.coyote.Processor.isUpgrade.

Doc from org.apache.coyote.AbstractProcessor.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
pauseback to summary
public void pause()

Implements org.apache.coyote.Processor.pause.

Doc from org.apache.coyote.Processor.pause.

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.

Annotations
@Override
populatePortback to summary
protected void populatePort()

Overrides org.apache.coyote.AbstractProcessor.populatePort.

Doc from org.apache.coyote.AbstractProcessor.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.

Annotations
@Override
prepareExpectationback to summary
private void prepareExpectation(MimeHeaders headers)
prepareInputFiltersback to summary
private void prepareInputFilters(MimeHeaders headers) throws IOException
prepareRequestback to summary
private void prepareRequest() throws IOException

After reading the request headers, we have to setup the request filters.

Annotations
@SuppressWarnings:deprecation
prepareRequestProtocolback to summary
private void prepareRequestProtocol()
prepareResponseback to summary
protected final void prepareResponse() throws IOException

Implements abstract org.apache.coyote.AbstractProcessor.prepareResponse.

When committing the response, we have to validate the set of headers, as well as setup the response filters.

Annotations
@Override
prepareSendfileback to summary
private void prepareSendfile(OutputFilter[] outputFilters)
processSendfileback to summary
private SendfileState processSendfile(SocketWrapperBase<?> socketWrapper)

Trigger sendfile processing if required.

Returns:SendfileState

The state of send file processing

recycleback to summary
public final void recycle()

Overrides org.apache.coyote.AbstractProcessor.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 final void registerReadInterest()

Implements abstract org.apache.coyote.AbstractProcessor.registerReadInterest.

Annotations
@Override
serviceback to summary
public AbstractEndpoint.Handler.SocketState service(SocketWrapperBase<?> socketWrapper) throws IOException

Implements abstract org.apache.coyote.AbstractProcessorLight.service.

Doc from org.apache.coyote.AbstractProcessorLight.service.

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 to dispatch(SocketEvent). Requests may be pipe-lined.

Parameters
socketWrapper:SocketWrapperBase<?>

The connection 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
setRequestBodyback to summary
protected final void setRequestBody(ByteChunk body)

Implements abstract org.apache.coyote.AbstractProcessor.setRequestBody.

Annotations
@Override
setSocketWrapperback to summary
protected final void setSocketWrapper(SocketWrapperBase<?> socketWrapper)

Overrides org.apache.coyote.AbstractProcessor.setSocketWrapper.

Doc from org.apache.coyote.AbstractProcessor.setSocketWrapper.

Set the socket wrapper being used.

Parameters
socketWrapper:SocketWrapperBase<?>

The socket wrapper

Annotations
@Override
setSwallowResponseback to summary
protected final void setSwallowResponse()

Implements abstract org.apache.coyote.AbstractProcessor.setSwallowResponse.

Annotations
@Override
sslReHandShakeback to summary
protected final void sslReHandShake() throws IOException

Overrides org.apache.coyote.AbstractProcessor.sslReHandShake.

Doc from org.apache.coyote.AbstractProcessor.sslReHandShake.

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

Annotations
@Override
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
statusDropsConnectionback to summary
private static boolean statusDropsConnection(int status)

Determine if we must drop the connection because of the HTTP status code. Use the same list of codes as Apache/httpd.