CoyoteAdapter (Apache Tomcat 10.1.48 API Documentation)
Description: declaration: package: org.apache.catalina.connector, class: CoyoteAdapter

# Class CoyoteAdapter

java.lang.Object
org.apache.catalina.connector.CoyoteAdapter

All Implemented Interfaces:
  `Adapter`

public class CoyoteAdapter extends Object implements Adapter
Implementation of a request processor which delegates the processing to a Coyote processor.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ADAPTER_NOTES`
  `protected static final StringManager`
  `sm`
  The string manager for this package.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CoyoteAdapter(Connector connector)`
  Construct a new CoyoteProcessor associated with the specified connector.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `asyncDispatch(Request req, Response res, SocketEvent status)`
  Dispatch asynchronous event.
  `void`
  `checkRecycled(Request req, Response res)`
  Assert that request and response have been recycled.
  `protected void`
  `convertMB(MessageBytes mb)`
  Character conversion of the US-ASCII MessageBytes.
  `protected void`
  `convertURI(MessageBytes uri, Request request)`
  Character conversion of the URI.
  `protected static void`
  `copyBytes(byte[] b, int dest, int src, int len)`
  Copy an array of bytes to a different position.
  `String`
  `getDomain()`
  Provide the name of the domain to use to register MBeans for components associated with the connector.
  `void`
  `log(Request req, Response res, long time)`
  Callback to allow logging access outside of the execution of the regular service.
  `static boolean`
  `normalize(MessageBytes uriMB, boolean allowBackslash)`
  This method normalizes "\", "//", "/./" and "/../".
  `protected void`
  `parsePathParameters(Request req, Request request)`
  Extract the path parameters from the request.
  `protected void`
  `parseSessionCookiesId(Request request)`
  Parse session id in Cookie.
  `protected void`
  `parseSessionSslId(Request request)`
  Look for SSL session ID if required.
  `protected boolean`
  `postParseRequest(Request req, Request request, Response res, Response response)`
  Perform the necessary processing after the HTTP headers have been parsed to enable the request/response pair to be passed to the start of the container pipeline for processing.
  `boolean`
  `prepare(Request req, Response res)`
  Prepare the given request/response for processing.
  `void`
  `service(Request req, Response res)`
  Call the service method, and notify all listeners.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### ADAPTER_NOTES

    public static final int ADAPTER_NOTES
    See Also:
      - Constant Field Values

  - ### sm

    protected static final StringManager sm
    The string manager for this package.

- ## Constructor Details

  - ### CoyoteAdapter

    public CoyoteAdapter(Connector connector)
    Construct a new CoyoteProcessor associated with the specified connector.
    Parameters:
      `connector` - CoyoteConnector that owns this processor

- ## Method Details

  - ### asyncDispatch

    public boolean asyncDispatch(Request req, Response res, SocketEvent status) throws Exception
    Description copied from interface: `Adapter`
    Dispatch asynchronous event.
    Specified by:
      `asyncDispatch` in interface `Adapter`
    Parameters:
      `req` - the request object
      `res` - the response object
      `status` - the event being processed
    Returns:
      `true` if the dispatch was successful
    Throws:
      `Exception` - If the processing fails unexpectedly

  - ### service

    public void service(Request req, Response res) throws Exception
    Description copied from interface: `Adapter`
    Call the service method, and notify all listeners.
    Specified by:
      `service` in interface `Adapter`
    Parameters:
      `req` - The request object
      `res` - The response object
    Throws:
      `Exception` - if an error happens during handling of the request. Common errors are:
      - IOException if an input/output error occurs and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
      - ServletException if a servlet throws an exception and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
      Tomcat should be able to handle and log any other exception ( including runtime exceptions )

  - ### prepare

    public boolean prepare(Request req, Response res) throws IOException, ServletException
    Description copied from interface: `Adapter`
    Prepare the given request/response for processing. This method requires that the request object has been populated with the information available from the HTTP headers.
    Specified by:
      `prepare` in interface `Adapter`
    Parameters:
      `req` - The request object
      `res` - The response object
    Returns:
      `true` if processing can continue, otherwise `false` in which case an appropriate error will have been set on the response
    Throws:
      `IOException`
      `ServletException`

  - ### log

    public void log(Request req, Response res, long time)
    Description copied from interface: `Adapter`
    Callback to allow logging access outside of the execution of the regular service.
    Specified by:
      `log` in interface `Adapter`
    Parameters:
      `req` - the request object
      `res` - the response object
      `time` - time taken to process the request/response in milliseconds (use 0 if not known)

  - ### checkRecycled

    public void checkRecycled(Request req, Response res)
    Description copied from interface: `Adapter`
    Assert that request and response have been recycled. If they have not then log a warning and force a recycle. This method is called as a safety check when a processor is being recycled and may be returned to a pool for reuse.
    Specified by:
      `checkRecycled` in interface `Adapter`
    Parameters:
      `req` - Request
      `res` - Response

  - ### getDomain

    public String getDomain()
    Description copied from interface: `Adapter`
    Provide the name of the domain to use to register MBeans for components associated with the connector.
    Specified by:
      `getDomain` in interface `Adapter`
    Returns:
      The MBean domain name

  - ### postParseRequest

    protected boolean postParseRequest(Request req, Request request, Response res, Response response) throws IOException, ServletException
    Perform the necessary processing after the HTTP headers have been parsed to enable the request/response pair to be passed to the start of the container pipeline for processing.
    Parameters:
      `req` - The coyote request object
      `request` - The catalina request object
      `res` - The coyote response object
      `response` - The catalina response object
    Returns:
      `true` if the request should be passed on to the start of the container pipeline, otherwise `false`
    Throws:
      `IOException` - If there is insufficient space in a buffer while processing headers
      `ServletException` - If the supported methods of the target servlet cannot be determined

  - ### parsePathParameters

    protected void parsePathParameters(Request req, Request request)
    Extract the path parameters from the request. This assumes parameters are of the form /path;name=value;name2=value2/ etc. Currently only really interested in the session ID that will be in this form. Other parameters can safely be ignored.
    Parameters:
      `req` - The Coyote request object
      `request` - The Servlet request object

  - ### parseSessionSslId

    protected void parseSessionSslId(Request request)
    Look for SSL session ID if required. Only look for SSL Session ID if it is the only tracking method enabled.
    Parameters:
      `request` - The Servlet request object

  - ### parseSessionCookiesId

    protected void parseSessionCookiesId(Request request)
    Parse session id in Cookie.
    Parameters:
      `request` - The Servlet request object

  - ### convertURI

    protected void convertURI(MessageBytes uri, Request request) throws IOException
    Character conversion of the URI.
    Parameters:
      `uri` - MessageBytes object containing the URI
      `request` - The Servlet request object
    Throws:
      `IOException` - if a IO exception occurs sending an error to the client

  - ### convertMB

    protected void convertMB(MessageBytes mb)
    Character conversion of the US-ASCII MessageBytes.
    Parameters:
      `mb` - The MessageBytes instance containing the bytes that should be converted to chars

  - ### normalize

    public static boolean normalize(MessageBytes uriMB, boolean allowBackslash)
    This method normalizes "\", "//", "/./" and "/../".
    Parameters:
      `uriMB` - URI to be normalized
      `allowBackslash` - `true` if backslash characters are allowed in URLs
    Returns:
      `false` if normalizing this URI would require going above the root, or if the URI contains a null byte, otherwise `true`

  - ### copyBytes

    protected static void copyBytes(byte[] b, int dest, int src, int len)
    Copy an array of bytes to a different position. Used during normalization.
    Parameters:
      `b` - The bytes that should be copied
      `dest` - Destination offset
      `src` - Source offset
      `len` - Length