Top Description Inners Fields Constructors Methods
org.apache.catalina.connector

public Class CoyoteAdapter

extends Object
implements Adapter
Class Inheritance
All Implemented Interfaces
org.apache.coyote.Adapter
Imports
java.io.IOException, java.nio.charset.Charset, .StandardCharsets, java.util.EnumSet, java.util.concurrent.atomic.AtomicBoolean, jakarta.servlet.ReadListener, .RequestDispatcher, .ServletException, .SessionTrackingMode, .WriteListener, jakarta.servlet.http.HttpServletResponse, org.apache.catalina.Authenticator, .Context, .Host, .Wrapper, org.apache.catalina.authenticator.AuthenticatorBase, org.apache.catalina.core.AsyncContextImpl, org.apache.catalina.util.ServerInfo, .SessionConfig, .URLEncoder, org.apache.coyote.ActionCode, .Adapter, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.ExceptionUtils, org.apache.tomcat.util.buf.B2CConverter, .ByteChunk, .CharChunk, .HexUtils, .MessageBytes, org.apache.tomcat.util.http.ServerCookie, .ServerCookies, org.apache.tomcat.util.net.SSLSupport, .SocketEvent, org.apache.tomcat.util.res.StringManager

Implementation of a request processor which delegates the processing to a Coyote processor.
Authors
Craig R. McClanahan, Remy Maucherat

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final int
private final Connector
connector

The CoyoteConnector with which this processor is associated.

private static final Log
private static final String
protected static final StringManager
sm

The string manager for this package.

private static final EnumSet<SessionTrackingMode>

Constructor Summary

AccessConstructor and Description
public
CoyoteAdapter(Connector
CoyoteConnector that owns this processor
connector
)

Construct a new CoyoteProcessor associated with the specified connector.

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
checkRecycled(Request
Request
req
,
Response
Response
res
)

Implements org.apache.coyote.Adapter.checkRecycled.

Assert that request and response have been recycled.

private static boolean
protected void
convertMB(MessageBytes
The MessageBytes instance containing the bytes that should be converted to chars
mb
)

Character conversion of the a US-ASCII MessageBytes.

protected void
convertURI(MessageBytes
MessageBytes object containing the URI
uri
,
Request
The Servlet request object
request
)

Character conversion of the URI.

protected static void
copyBytes(byte[]
The bytes that should be copied
b
,
int
Destination offset
dest
,
int
Source offset
src
,
int
Length
len
)

Copy an array of bytes to a different position.

private void
public String
getDomain()

Implements org.apache.coyote.Adapter.getDomain.

Provide the name of the domain to use to register MBeans for components associated with the connector.

public void
log(Request req, Response res, long time)

Implements org.apache.coyote.Adapter.log.

public static boolean

Returns:

false if normalizing this URI would require going above the root, or if the URI contains a null byte, otherwise true
normalize
(MessageBytes
URI to be normalized
uriMB
,
boolean
true if backslash characters are allowed in URLs
allowBackslash
)

This method normalizes "\", "//", "/./" and "/../".

protected void
parsePathParameters(Request
The Coyote request object
req
,
Request
The Servlet request object
request
)

Extract the path parameters from the request.

protected void
parseSessionCookiesId(Request
The Servlet request object
request
)

Parse session id in Cookie.

protected void
parseSessionSslId(Request
The Servlet request object
request
)

Look for SSL session ID if required.

protected boolean

Returns:

true if the request should be passed on to the start of the container pipeline, otherwise false
postParseRequest
(Request
The coyote request object
req
,
Request
The catalina request object
request
,
Response
The coyote response object
res
,
Response
The catalina response object
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.

public boolean
prepare(Request
The request object
req
,
Response
The response object
res
)

Implements org.apache.coyote.Adapter.prepare.

Prepare the given request/response for processing.

public void
service(Request
The request object
req
,
Response
The response object
res
)

Implements org.apache.coyote.Adapter.service.

Call the service method, and notify all listeners

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ADAPTER_NOTESback to summary
public static final int ADAPTER_NOTES
connectorback to summary
private final Connector connector

The CoyoteConnector with which this processor is associated.

logback to summary
private static final Log log
POWERED_BYback to summary
private static final String POWERED_BY
smback to summary
protected static final StringManager sm

The string manager for this package.

SSL_ONLYback to summary
private static final EnumSet<SessionTrackingMode> SSL_ONLY

Constructor Detail

CoyoteAdapterback to summary
public CoyoteAdapter(Connector connector)

Construct a new CoyoteProcessor associated with the specified connector.

Parameters
connector:Connector

CoyoteConnector that owns this processor

Method Detail

asyncDispatchback to summary
public boolean asyncDispatch(Request req, Response res, SocketEvent status) throws Exception

Implements org.apache.coyote.Adapter.asyncDispatch.

Annotations
@Override
checkRecycledback to summary
public void checkRecycled(Request req, Response res)

Implements org.apache.coyote.Adapter.checkRecycled.

Doc from org.apache.coyote.Adapter.checkRecycled.

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.

Parameters
req:Request

Request

res:Response

Response

Annotations
@Override
checkSuspiciousURIsback to summary
private static boolean checkSuspiciousURIs(ByteChunk undecodedURI)
convertMBback to summary
protected void convertMB(MessageBytes mb)

Character conversion of the a US-ASCII MessageBytes.

Parameters
mb:MessageBytes

The MessageBytes instance containing the bytes that should be converted to chars

convertURIback to summary
protected void convertURI(MessageBytes uri, Request request) throws IOException

Character conversion of the URI.

Parameters
uri:MessageBytes

MessageBytes object containing the URI

request:Request

The Servlet request object

Exceptions
IOException:
if a IO exception occurs sending an error to the client
copyBytesback to summary
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:byte[]

The bytes that should be copied

dest:int

Destination offset

src:int

Source offset

len:int

Length

doConnectorAuthenticationAuthorizationback to summary
private void doConnectorAuthenticationAuthorization(Request req, Request request)
getDomainback to summary
public String getDomain()

Implements org.apache.coyote.Adapter.getDomain.

Doc from org.apache.coyote.Adapter.getDomain.

Provide the name of the domain to use to register MBeans for components associated with the connector.

Returns:String

The MBean domain name

Annotations
@Override
logback to summary
public void log(Request req, Response res, long time)

Implements org.apache.coyote.Adapter.log.

Annotations
@Override
normalizeback to summary
public static boolean normalize(MessageBytes uriMB, boolean allowBackslash)

This method normalizes "\", "//", "/./" and "/../".

Parameters
uriMB:MessageBytes

URI to be normalized

allowBackslash:boolean

true if backslash characters are allowed in URLs

Returns:boolean

false if normalizing this URI would require going above the root, or if the URI contains a null byte, otherwise true

parsePathParametersback to summary
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:Request

The Coyote request object

request:Request

The Servlet request object

parseSessionCookiesIdback to summary
protected void parseSessionCookiesId(Request request)

Parse session id in Cookie.

Parameters
request:Request

The Servlet request object

parseSessionSslIdback to summary
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:Request

The Servlet request object

postParseRequestback to summary
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:Request

The coyote request object

request:Request

The catalina request object

res:Response

The coyote response object

response:Response

The catalina response object

Returns:boolean

true if the request should be passed on to the start of the container pipeline, otherwise false

Annotations
@SuppressWarnings:deprecation
Exceptions
IOException:
If there is insufficient space in a buffer while processing headers
ServletException:
If the supported methods of the target servlet cannot be determined
prepareback to summary
public boolean prepare(Request req, Response res) throws IOException, ServletException

Implements org.apache.coyote.Adapter.prepare.

Doc from org.apache.coyote.Adapter.prepare.

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.

Parameters
req:Request

The request object

res:Response

The response object

Returns:boolean

true if processing can continue, otherwise false in which case an appropriate error will have been set on the response

Annotations
@Override
serviceback to summary
public void service(Request req, Response res) throws Exception

Implements org.apache.coyote.Adapter.service.

Doc from org.apache.coyote.Adapter.service.

Call the service method, and notify all listeners

Parameters
req:Request

The request object

res:Response

The response object

Annotations
@Override
Exceptions
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 )
updateWrapperErrorCountback to summary
private void updateWrapperErrorCount(Request request, Response response)
org.apache.catalina.connector back to summary

private Class CoyoteAdapter.RecycleRequiredException

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
private

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

RecycleRequiredExceptionback to summary
private RecycleRequiredException()