# 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
Processor for HTTP/1.1 requests and responses.

## Field Summary

### Fields inherited from class AbstractProcessor

`adapter, asyncStateMachine, request, response, socketWrapper, sslSupport, userDataHelper`

## Constructor Summary

Constructors
Constructor
Description
`Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter)`
Creates a new HTTP/1.1 processor.

## Method Summary

Modifier and Type
Method
Description
`protected 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`
`disableSwallowRequest()`
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`
`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 upgradeToken)`
Process an HTTP upgrade.
`protected void`
`earlyHints()`
Process early hints (103 Early Hints).
`protected final void`
`finishResponse()`
Finish the current response.
`protected final void`
`flush()`
Callback to write data from the buffer.
`protected boolean`
`flushBufferedWrite()`
Flush any pending writes.
`ByteBuffer`
`getLeftoverInput()`
Allows retrieving additional input during the upgrade process.
`protected Log`
`getLog()`
Returns the logger associated with this processor type.
`protected ServletConnection`
`getServletConnection()`
Protocols must override this method and return an appropriate ServletConnection instance
`UpgradeToken`
`getUpgradeToken()`
Generate an upgrade token.
`protected final boolean`
`isReadyForWrite()`
Checks if the processor is ready for writing.
`protected final boolean`
`isRequestBodyFullyRead()`
Checks if the request body has been fully read.
`protected boolean`
`isTrailerFieldsReady()`
Checks if trailer fields are ready.
`protected boolean`
`isTrailerFieldsSupported()`
Protocols that support trailer fields should override this method and return `true`.
`boolean`
`isUpgrade()`
Checks if the Processor is processing an upgrade request.
`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 final void`
`prepareResponse()`
When committing the response, we have to validate the set of headers, as well as set up the response filters.
`final void`
`recycle()`
Recycle the processor, ready for the next request which may be on the same connection or a different connection.
`protected final void`
`registerReadInterest()`
When using non blocking IO, register to get a callback when polling determines that bytes are available for reading.
`AbstractEndpoint.Handler.SocketState`
`service(SocketWrapperBase<?> socketWrapper)`
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`
`setSocketWrapper(SocketWrapperBase<?> socketWrapper)`
Set the socket wrapper being used.
`protected final void`
`setSwallowResponse()`
The response is finished and no additional bytes need to be sent to the client.
`protected final void`
`sslReHandShake()`
Processors that can perform a TLS re-handshake (e.g.

### Methods inherited from class AbstractProcessor

`action, asyncPostProcess, checkAsyncTimeoutGeneration, dispatch, dispatchNonBlockingRead, doPush, execute, executeDispatches, getAdapter, getAsyncTimeout, getErrorState, getPopulateRequestAttributesFromSocket, getProtocolRequestId, getRequest, getSocketWrapper, isAsync, isPushSupported, isReadyForRead, logAccess, parseHost, populateHost, populateRequestAttributeRemoteHost, populateSslRequestAttributes, processSocketEvent, setAsyncTimeout, setErrorState, setSslSupport, timeoutAsync`

### Methods inherited from class AbstractProcessorLight

`addDispatch, clearDispatches, getIteratorAndClearDispatches, process`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Http11Processor

public Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter adapter)
Creates a new HTTP/1.1 processor.

Parameters:
  `protocol` - the protocol handler
  `adapter` - the adapter to pass requests to

## Method Details

### service

public AbstractEndpoint.Handler.SocketState service(SocketWrapperBase<?> socketWrapper) throws 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 to `AbstractProcessorLight.dispatch(SocketEvent)`. Requests may be pipe-lined.

Specified by:
  `service` in class `AbstractProcessorLight`
Parameters:
  `socketWrapper` - 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

### setSocketWrapper

protected final void setSocketWrapper(SocketWrapperBase<?> socketWrapper)
Description copied from class: `AbstractProcessor`
Set the socket wrapper being used.

Overrides:
  `setSocketWrapper` in class `AbstractProcessor`
Parameters:
  `socketWrapper` - The socket wrapper

### prepareResponse

protected final void prepareResponse() throws IOException
Description copied from class: `AbstractProcessor`
When committing the response, we have to validate the set of headers, as well as set up the response filters.

Specified by:
  `prepareResponse` in class `AbstractProcessor`
Throws:
  `IOException` - IO exception during commit

### 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 class `AbstractProcessor`

### flushBufferedWrite

protected boolean flushBufferedWrite() throws 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 class `AbstractProcessor`
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

### 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 class `AbstractProcessor`
Returns:
  The state to return for the socket once the clean-up for the current request has completed

### getLog

protected Log getLog()
Description copied from class: `AbstractProcessorLight`
Returns the logger associated with this processor type.

Specified by:
  `getLog` in class `AbstractProcessorLight`
Returns:
  the logger associated with this processor type

### getServletConnection

protected ServletConnection getServletConnection()
Description copied from class: `AbstractProcessor`
Protocols must override this method and return an appropriate ServletConnection instance

Specified by:
  `getServletConnection` in class `AbstractProcessor`
Returns:
  the ServletConnection instance associated with the current request.

### finishResponse

protected final void finishResponse() throws IOException
Description copied from class: `AbstractProcessor`
Finish the current response.

Specified by:
  `finishResponse` in class `AbstractProcessor`
Throws:
  `IOException` - IO exception during the write

### ack

protected final void ack(ContinueResponseTiming continueResponseTiming)
Description copied from class: `AbstractProcessor`
Process acknowledgment of the request.

Specified by:
  `ack` in class `AbstractProcessor`
Parameters:
  `continueResponseTiming` - specifies when an acknowledgment should be sent

### earlyHints

protected void earlyHints() throws IOException
Description copied from class: `AbstractProcessor`
Process early hints (103 Early Hints).

Specified by:
  `earlyHints` in class `AbstractProcessor`
Throws:
  `IOException` - IO exception during processing

### flush

protected final void flush() throws IOException
Description copied from class: `AbstractProcessor`
Callback to write data from the buffer.

Specified by:
  `flush` in class `AbstractProcessor`
Throws:
  `IOException` - IO exception during the write

### available

protected final int available(boolean doRead)
Description copied from class: `AbstractProcessor`
Queries if bytes are available in buffers.

Specified by:
  `available` in class `AbstractProcessor`
Parameters:
  `doRead` - `true` to perform a read when no bytes are availble
Returns:
  the amount of bytes that are known to be available

### setRequestBody

protected final void setRequestBody(ByteChunk body)
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 class `AbstractProcessor`
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 class `AbstractProcessor`

### 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 class `AbstractProcessor`

### sslReHandShake

protected final void sslReHandShake() throws 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 class `AbstractProcessor`
Throws:
  `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()
Description copied from class: `AbstractProcessor`
Checks if the request body has been fully read.

Specified by:
  `isRequestBodyFullyRead` in class `AbstractProcessor`
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 class `AbstractProcessor`

### isReadyForWrite

protected final boolean isReadyForWrite()
Description copied from class: `AbstractProcessor`
Checks if the processor is ready for writing.

Specified by:
  `isReadyForWrite` in class `AbstractProcessor`
Returns:
  `true` if bytes can be written without blocking

### 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 interface `Processor`
Overrides:
  `getUpgradeToken` in class `AbstractProcessor`
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 class `AbstractProcessor`
Parameters:
  `upgradeToken` - Contains all the information necessary for the Processor to process the upgrade

### getLeftoverInput

public 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 interface `Processor`
Overrides:
  `getLeftoverInput` in class `AbstractProcessor`
Returns:
  leftover bytes

### isUpgrade

public boolean isUpgrade()
Description copied from class: `AbstractProcessor`
Checks if the Processor is processing an upgrade request. Processors that implement HTTP upgrade must override this method.

Specified by:
  `isUpgrade` in interface `Processor`
Overrides:
  `isUpgrade` in class `AbstractProcessor`
Returns:
  `true` if the Processor is currently processing an upgrade request, otherwise `false`

### isTrailerFieldsReady

protected boolean isTrailerFieldsReady()
Description copied from class: `AbstractProcessor`
Checks if trailer fields are ready.

Specified by:
  `isTrailerFieldsReady` in class `AbstractProcessor`
Returns:
  `true` if trailer fields are ready

### isTrailerFieldsSupported

protected boolean isTrailerFieldsSupported()
Description copied from class: `AbstractProcessor`
Protocols that support trailer fields should override this method and return `true`.

Overrides:
  `isTrailerFieldsSupported` in class `AbstractProcessor`
Returns:
  `true` if trailer fields are supported by this processor, otherwise `false`.

### 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 interface `Processor`
Overrides:
  `recycle` in class `AbstractProcessor`

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