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
    Modifier and Type | Field and Description
    --- | ---
    `protected String[]` | `compressableMimeTypes` List of MIMES for which compression may be enabled.
    `protected int` | `compressionLevel` Allowed compression level.
    `protected int` | `compressionMinSize` Minimum content size to make compression.
    `protected int` | `connectionUploadTimeout` Maximum timeout on uploads. 5 minutes as in Apache HTTPD server.
    `protected boolean` | `contentDelimitation` Content delimiter for the request (if false, the connection will be closed at the end of the request).
    `protected boolean` | `disableUploadTimeout` Flag to disable setting a different time-out on uploads.
    `protected char[]` | `hostNameC` Host name (used to avoid useless B2C conversion on the host name).
    `protected boolean` | `http09` HTTP/0.9 flag.
    `protected boolean` | `http11` HTTP/1.1 flag.
    `protected Http11InputBuffer` | `inputBuffer` Input.
    `protected boolean` | `keepAlive` Keep-alive.
    `protected int` | `maxKeepAliveRequests` Maximum number of Keep-Alive requests to honor.
    `protected int` | `maxSavePostSize` Max saved post size.
    `protected Pattern` | `noCompressionUserAgents` Regular expression that defines the user agents to not use gzip with
    `protected boolean` | `openSocket` Flag used to indicate that the socket should be kept open (e.g. for keep alive or send file.
    `protected Http11OutputBuffer` | `outputBuffer` Output.
    `protected boolean` | `readComplete` Flag that indicates if the request headers have been completely read.
    `protected Pattern` | `restrictedUserAgents` Regular expression that defines the restricted user agents.
    `protected SendfileDataBase` | `sendfileData` Sendfile data.
    `protected UpgradeToken` | `upgradeToken` Instance of the new protocol to use after the HTTP connection has been upgraded.

    - ### Fields inherited from class org.apache.coyote.AbstractProcessor

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Http11Processor(int maxHttpHeaderSize, AbstractEndpoint<?> endpoint, int maxTrailerSize, Set<String> allowedTrailerHeaders, int maxExtensionSize, int maxSwallowSize, Map<String,UpgradeProtocol> httpUpgradeProtocols, boolean sendReasonPhrase)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `ack()`
    `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.
    `String` | `getCompression()` Return compression level.
    `int` | `getConnectionUploadTimeout()` Get the upload timeout.
    `boolean` | `getDisableUploadTimeout()` Get the flag that controls upload time-outs.
    `ByteBuffer` | `getLeftoverInput()` Allows retrieving additional input during the upgrade process.
    `protected Log` | `getLog()`
    `int` | `getMaxKeepAliveRequests()` Get the maximum number of Keep-Alive requests allowed.
    `int` | `getMaxSavePostSize()` Return the maximum size of a POST which will be buffered in SSL mode.
    `UpgradeToken` | `getUpgradeToken()` Generate an upgrade token.
    `protected boolean` | `isReady()`
    `protected boolean` | `isRequestBodyFullyRead()`
    `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` | `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.
    `void` | `setCompressableMimeTypes(String[] compressibleMimeTypes)` Deprecated. Use `setCompressibleMimeTypes(String[])`
    `void` | `setCompressibleMimeTypes(String[] compressibleMimeTypes)` Set compressible mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).
    `void` | `setCompression(String compression)` Set compression level.
    `void` | `setCompressionMinSize(int compressionMinSize)` Set Minimum size to trigger compression.
    `void` | `setConnectionUploadTimeout(int timeout)` Set the upload timeout.
    `void` | `setDisableUploadTimeout(boolean isDisabled)` Set the flag to control whether a separate connection timeout is used during upload of a request body.
    `void` | `setMaxKeepAliveRequests(int mkar)` Set the maximum number of Keep-Alive requests to allow.
    `void` | `setMaxSavePostSize(int msps)` Set the maximum size of a POST which will be buffered in SSL mode.
    `void` | `setNoCompressionUserAgents(String noCompressionUserAgents)` Set no compression user agent pattern.
    `protected void` | `setRequestBody(ByteChunk body)`
    `void` | `setRestrictedUserAgents(String restrictedUserAgents)` Set restricted user agent list (which will downgrade the connector to HTTP/1.0 mode).
    `void` | `setServer(String server)` Set the server header name.
    `void` | `setServerRemoveAppProvidedValues(boolean serverRemoveAppProvidedValues)`
    `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, dispatch, dispatchNonBlockingRead, doPush, executeDispatches, getAdapter, getAsyncTimeout, getErrorState, getExecutor, getPopulateRequestAttributesFromSocket, getRequest, getSocketWrapper, isAsync, isPushSupported, populateRequestAttributeRemoteHost, populateSslRequestAttributes, processSocketEvent, setAdapter, setAsyncTimeout, setErrorState, setSocketWrapper, setSslSupport, timeoutAsync`

    - ### Methods inherited from class org.apache.coyote.AbstractProcessorLight

      `addDispatch, clearDispatches, getIteratorAndClearDispatches, process`

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### inputBuffer

          protected final Http11InputBuffer inputBuffer

      Input.

    - #### outputBuffer

          protected final Http11OutputBuffer outputBuffer

      Output.

    - #### keepAlive

          protected volatile boolean keepAlive

      Keep-alive.

    - #### openSocket

          protected boolean openSocket

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

    - #### readComplete

          protected boolean readComplete

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

    - #### http11

          protected boolean http11

      HTTP/1.1 flag.

    - #### http09

          protected boolean http09

      HTTP/0.9 flag.

    - #### contentDelimitation

          protected boolean contentDelimitation

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

    - #### restrictedUserAgents

          protected Pattern restrictedUserAgents

      Regular expression that defines the restricted user agents.

    - #### maxKeepAliveRequests

          protected int maxKeepAliveRequests

      Maximum number of Keep-Alive requests to honor.

    - #### connectionUploadTimeout

          protected int connectionUploadTimeout

      Maximum timeout on uploads. 5 minutes as in Apache HTTPD server.

    - #### disableUploadTimeout

          protected boolean disableUploadTimeout

      Flag to disable setting a different time-out on uploads.

    - #### compressionLevel

          protected int compressionLevel

      Allowed compression level.

    - #### compressionMinSize

          protected int compressionMinSize

      Minimum content size to make compression.

    - #### maxSavePostSize

          protected int maxSavePostSize

      Max saved post size.

    - #### noCompressionUserAgents

          protected Pattern noCompressionUserAgents

      Regular expression that defines the user agents to not use gzip with

    - #### compressableMimeTypes

          protected String[] compressableMimeTypes

      List of MIMES for which compression may be enabled. Note: This is not spelled correctly but can't be changed without breaking compatibility

    - #### hostNameC

          protected char[] hostNameC

      Host name (used to avoid useless B2C conversion on the host name).

    - #### upgradeToken

          protected UpgradeToken upgradeToken

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

    - #### sendfileData

          protected SendfileDataBase sendfileData

      Sendfile data.

  - ### Constructor Detail

    - #### Http11Processor

          public Http11Processor(int maxHttpHeaderSize,
                         AbstractEndpoint<?> endpoint,
                         int maxTrailerSize,
                         Set<String> allowedTrailerHeaders,
                         int maxExtensionSize,
                         int maxSwallowSize,
                         Map<String,UpgradeProtocol> httpUpgradeProtocols,
                         boolean sendReasonPhrase)

  - ### Method Detail

    - #### setCompression

          public void setCompression(String compression)

      Set compression level.
      Parameters:
        `compression` - One of `on`, `force`, `off` or the minimum compression size in bytes which implies `on`

    - #### setCompressionMinSize

          public void setCompressionMinSize(int compressionMinSize)

      Set Minimum size to trigger compression.
      Parameters:
        `compressionMinSize` - The minimum content length required for compression in bytes

    - #### setNoCompressionUserAgents

          public void setNoCompressionUserAgents(String noCompressionUserAgents)

      Set no compression user agent pattern. Regular expression as supported by `Pattern`. e.g.: `gorilla|desesplorer|tigrus`.
      Parameters:
        `noCompressionUserAgents` - The regular expression for user agent strings for which compression should not be applied

    - #### setCompressableMimeTypes

          @Deprecated
          public void setCompressableMimeTypes(String[] compressibleMimeTypes)

      Deprecated. Use `setCompressibleMimeTypes(String[])`
      Parameters:
        `compressibleMimeTypes` - See `setCompressibleMimeTypes(String[])`

    - #### setCompressibleMimeTypes

          public void setCompressibleMimeTypes(String[] compressibleMimeTypes)

      Set compressible mime-type list (this method is best when used with a large number of connectors, where it would be better to have all of them referenced a single array).
      Parameters:
        `compressibleMimeTypes` - MIME types for which compression should be enabled

    - #### getCompression

          public String getCompression()

      Return compression level.
      Returns:
        The current compression level in string form (off/on/force)

    - #### setRestrictedUserAgents

          public void setRestrictedUserAgents(String restrictedUserAgents)

      Set restricted user agent list (which will downgrade the connector to HTTP/1.0 mode). Regular expression as supported by `Pattern`.
      Parameters:
        `restrictedUserAgents` - The regular expression as supported by `Pattern` for the user agents e.g. "gorilla|desesplorer|tigrus"

    - #### setMaxKeepAliveRequests

          public void setMaxKeepAliveRequests(int mkar)

      Set the maximum number of Keep-Alive requests to allow. This is to safeguard from DoS attacks. Setting to a negative value disables the limit.
      Parameters:
        `mkar` - The new maximum number of Keep-Alive requests allowed

    - #### getMaxKeepAliveRequests

          public int getMaxKeepAliveRequests()

      Get the maximum number of Keep-Alive requests allowed. A negative value means there is no limit.
      Returns:
        the number of Keep-Alive requests that we will allow.

    - #### setMaxSavePostSize

          public void setMaxSavePostSize(int msps)

      Set the maximum size of a POST which will be buffered in SSL mode. When a POST is received where the security constraints require a client certificate, the POST body needs to be buffered while an SSL handshake takes place to obtain the certificate.
      Parameters:
        `msps` - The maximum size POST body to buffer in bytes

    - #### getMaxSavePostSize

          public int getMaxSavePostSize()

      Return the maximum size of a POST which will be buffered in SSL mode.
      Returns:
        The size in bytes

    - #### setDisableUploadTimeout

          public void setDisableUploadTimeout(boolean isDisabled)

      Set the flag to control whether a separate connection timeout is used during upload of a request body.
      Parameters:
        `isDisabled` - `true` if the separate upload timeout should be disabled

    - #### getDisableUploadTimeout

          public boolean getDisableUploadTimeout()

      Get the flag that controls upload time-outs.
      Returns:
        `true` if the separate upload timeout is disabled

    - #### setConnectionUploadTimeout

          public void setConnectionUploadTimeout(int timeout)

      Set the upload timeout.
      Parameters:
        `timeout` - Upload timeout in milliseconds

    - #### getConnectionUploadTimeout

          public int getConnectionUploadTimeout()

      Get the upload timeout.
      Returns:
        Upload timeout in milliseconds

    - #### setServer

          public void setServer(String server)

      Set the server header name.
      Parameters:
        `server` - The new value to use for the server header

    - #### setServerRemoveAppProvidedValues

          public void setServerRemoveAppProvidedValues(boolean serverRemoveAppProvidedValues)

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

    - #### prepareResponse

          protected final void prepareResponse()
                                        throws IOException

      When committing the response, we have to validate the set of headers, as well as setup the response filters.
      Specified by:
        `prepareResponse` in class `AbstractProcessor`
      Throws:
        `IOException`

    - #### 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()

      Specified by:
        `getLog` in class `AbstractProcessorLight`

    - #### finishResponse

          protected final void finishResponse()
                                       throws IOException

      Specified by:
        `finishResponse` in class `AbstractProcessor`
      Throws:
        `IOException`

    - #### ack

          protected final void ack()

      Specified by:
        `ack` in class `AbstractProcessor`

    - #### flush

          protected final void flush()
                              throws IOException

      Specified by:
        `flush` in class `AbstractProcessor`
      Throws:
        `IOException`

    - #### available

          protected final int available(boolean doRead)

      Specified by:
        `available` in class `AbstractProcessor`

    - #### setRequestBody

          protected final void setRequestBody(ByteChunk body)

      Specified by:
        `setRequestBody` in class `AbstractProcessor`

    - #### setSwallowResponse

          protected final void setSwallowResponse()

      Specified by:
        `setSwallowResponse` in class `AbstractProcessor`

    - #### disableSwallowRequest

          protected final void disableSwallowRequest()

      Specified by:
        `disableSwallowRequest` in class `AbstractProcessor`

    - #### sslReHandShake

          protected final void sslReHandShake()

      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`

    - #### isRequestBodyFullyRead

          protected final boolean isRequestBodyFullyRead()

      Specified by:
        `isRequestBodyFullyRead` in class `AbstractProcessor`

    - #### registerReadInterest

          protected final void registerReadInterest()

      Specified by:
        `registerReadInterest` in class `AbstractProcessor`

    - #### isReady

          protected final boolean isReady()

      Specified by:
        `isReady` in class `AbstractProcessor`

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

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

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.