AjpProcessor (Apache Tomcat 10.1.5 API Documentation)

Package org.apache.coyote.ajp

## Class AjpProcessor

- java.lang.Object
- - org.apache.coyote.AbstractProcessorLight
  - - org.apache.coyote.AbstractProcessor
    - - org.apache.coyote.ajp.AjpProcessor

- All Implemented Interfaces:
    `ActionHook`, `Processor`

      public class AjpProcessor
      extends AbstractProcessor

  AJP Processor implementation.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected class` | `AjpProcessor.SocketInputBuffer` | This class is an input buffer which will read its data from an input stream.
    `protected class` | `AjpProcessor.SocketOutputBuffer` | 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

    Constructors
    Constructor | Description
    --- | ---
    `AjpProcessor​(AbstractAjpProtocol<?> 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` | `dispatchNonBlockingRead()` | Perform any necessary processing for a non-blocking read before dispatching to the adapter.
    `protected void` | `finishResponse()` | Finish AJP response.
    `protected void` | `flush()` | Callback to write data from the buffer.
    `protected boolean` | `flushBufferedWrite()` | Flush any pending writes.
    `protected Log` | `getLog()` |
    `protected boolean` | `getPopulateRequestAttributesFromSocket()` | Processors that populate request attributes directly (e.g.
    `protected ServletConnection` | `getServletConnection()` | Protocols must override this method and return an appropriate ServletConnection instance
    `protected boolean` | `isReadyForWrite()` |
    `protected boolean` | `isRequestBodyFullyRead()` |
    `protected boolean` | `isTrailerFieldsReady()` |
    `void` | `pause()` | Informs the processor that the underlying I/O layer has stopped accepting new connections.
    `protected void` | `populateHost()` | Called when a host header is not present in the request (e.g.
    `protected void` | `populatePort()` | Called when a host header is not present or is empty in the request (e.g.
    `protected void` | `populateRequestAttributeRemoteHost()` | Populate the remote host request attribute.
    `protected void` | `populateSslRequestAttributes()` | Populate the TLS related request attributes from the `SSLSupport` instance associated with this processor.
    `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 boolean` | `refillReadBuffer​(boolean block)` | Get more request body data from the web server and store it in the internal buffer.
    `protected void` | `registerReadInterest()` |
    `AbstractEndpoint.Handler.SocketState` | `service​(SocketWrapperBase<?> socket)` | Service a 'standard' HTTP request.
    `protected void` | `setRequestBody​(ByteChunk body)` |
    `protected void` | `setSwallowResponse()` |

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

      `action, asyncPostProcess, checkAsyncTimeoutGeneration, dispatch, doHttpUpgrade, doPush, execute, executeDispatches, getAdapter, getAsyncTimeout, getErrorState, getLeftoverInput, getProtocolRequestId, getRequest, getSocketWrapper, getUpgradeToken, isAsync, isPushSupported, isReadyForRead, isTrailerFieldsSupported, isUpgrade, logAccess, parseHost, processSocketEvent, setAsyncTimeout, setErrorState, setSocketWrapper, setSslSupport, sslReHandShake, 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`

- - ### Constructor Detail

    - #### AjpProcessor

          public AjpProcessor​(AbstractAjpProtocol<?> protocol,
                              Adapter adapter)

  - ### Method Detail

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

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

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

    - #### service

          public AbstractEndpoint.Handler.SocketState service​(SocketWrapperBase<?> socket)
                                                       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:
        `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 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.

    - #### refillReadBuffer

          protected boolean refillReadBuffer​(boolean block)
                                      throws IOException

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

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

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

    - #### flush

          protected final void flush()
                              throws IOException

      Callback to write data from the buffer.
      Specified by:
        `flush` in class `AbstractProcessor`
      Throws:
        `IOException`

    - #### finishResponse

          protected final void finishResponse()
                                       throws IOException

      Finish AJP response.
      Specified by:
        `finishResponse` in class `AbstractProcessor`
      Throws:
        `IOException`

    - #### ack

          protected final void ack​(ContinueResponseTiming continueResponseTiming)

      Specified by:
        `ack` in class `AbstractProcessor`

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

    - #### 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 return `false`.
      Overrides:
        `getPopulateRequestAttributesFromSocket` in class `AbstractProcessor`
      Returns:
        `true` if the SocketWrapper should be used to populate the request attributes, otherwise `false`.

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

    - #### populateSslRequestAttributes

          protected final void populateSslRequestAttributes()

      Description copied from class: `AbstractProcessor`
      Populate the TLS related request attributes from the `SSLSupport` instance associated with this processor. Protocols that populate TLS attributes from a different source (e.g. AJP) should override this method.
      Overrides:
        `populateSslRequestAttributes` 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`

    - #### isReadyForWrite

          protected final boolean isReadyForWrite()

      Specified by:
        `isReadyForWrite` in class `AbstractProcessor`

    - #### isTrailerFieldsReady

          protected boolean isTrailerFieldsReady()

      Specified by:
        `isTrailerFieldsReady` in class `AbstractProcessor`

    - #### getLog

          protected Log getLog()

      Specified by:
        `getLog` in class `AbstractProcessorLight`

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