org.apache.coyote.ajp

Class AjpProcessor

public class AjpProcessor extends Object implements ActionHook

Processes HTTP requests.

Author: Remy Maucherat Henri Gomez Dan Milstein Keith Wannamaker Kevin Seguin Costin Manolache Bill Barker

Nested Class Summary
protected classAjpProcessor.SocketInputBuffer
This class is an input buffer which will read its data from an input stream.
protected classAjpProcessor.SocketOutputBuffer
This class is an output buffer which will write data to an output stream.
Field Summary
protected Adapteradapter
Associated adapter.
protected MessageBytesbodyBytes
Body message.
protected AjpMessagebodyMessage
Body message.
protected MessageBytescertificates
Byte chunk for certs.
protected booleanempty
Body empty flag.
protected static byte[]endMessageArray
End message array.
protected booleanendOfStream
End of stream flag.
protected JIoEndpointendpoint
Associated endpoint.
protected booleanerror
Error flag.
protected booleanfinished
Finished response.
protected booleanfirst
First read.
protected static byte[]flushMessageArray
Flush message array.
protected byte[]getBodyMessageArray
Direct buffer used for sending right away a get body message.
protected char[]hostNameC
Host name (used to avoid useless B2C conversion on the host name).
protected InputStreaminput
Input stream.
protected intkeepAliveTimeout
The number of milliseconds Tomcat will wait for a subsequent request before closing the connection.
protected static Loglog
Logger.
protected OutputStreamoutput
Output stream.
protected intpacketSize
The socket timeout used when reading the first block of the request header.
protected static byte[]pongMessageArray
Direct buffer used for sending right away a pong message.
protected longreadTimeout
The socket timeout used when reading the first block of the request header.
protected booleanreplay
Replay read.
protected Requestrequest
Request object.
protected AjpMessagerequestHeaderMessage
Header message.
protected StringrequiredSecret
Required secret.
protected Responseresponse
Response object.
protected AjpMessageresponseHeaderMessage
Message used for response header composition.
protected static StringManagersm
The string manager for this package.
protected Socketsocket
Socket associated with the current connection.
protected booleanstarted
State flag.
protected MessageBytestmpMB
Temp message bytes used for processing.
protected booleantomcatAuthentication
Use Tomcat authentication ?
Constructor Summary
AjpProcessor(int packetSize, JIoEndpoint endpoint)
Method Summary
voidaction(ActionCode actionCode, Object param)
Send an action to the connector.
protected voidfinish()
Finish AJP response.
protected voidflush()
Callback to write data from the buffer.
AdaptergetAdapter()
Get the associated adapter.
intgetKeepAliveTimeout()
RequestgetRequest()
Get the request associated with this processor.
booleangetTomcatAuthentication()
voidparseHost(MessageBytes valueMB)
Parse host.
protected voidprepareRequest()
After reading the request headers, we have to setup the request filters.
protected voidprepareResponse()
When committing the response, we have to validate the set of headers, as well as setup the response filters.
voidprocess(Socket socket)
Process pipelined HTTP requests using the specified input and output streams.
protected booleanread(byte[] buf, int pos, int n)
Read at least the specified amount of bytes, and place them in the input buffer.
protected booleanreadMessage(AjpMessage message)
Read an AJP message.
booleanreceive()
Receive a chunk of data.
voidrecycle()
Recycle the processor.
voidsetAdapter(Adapter adapter)
Set the associated adapter.
voidsetKeepAliveTimeout(int timeout)
voidsetRequiredSecret(String requiredSecret)
voidsetTomcatAuthentication(boolean tomcatAuthentication)

Field Detail

adapter

protected Adapter adapter
Associated adapter.

bodyBytes

protected MessageBytes bodyBytes
Body message.

bodyMessage

protected AjpMessage bodyMessage
Body message.

certificates

protected MessageBytes certificates
Byte chunk for certs.

empty

protected boolean empty
Body empty flag.

endMessageArray

protected static final byte[] endMessageArray
End message array.

endOfStream

protected boolean endOfStream
End of stream flag.

endpoint

protected JIoEndpoint endpoint
Associated endpoint.

error

protected boolean error
Error flag.

finished

protected boolean finished
Finished response.

first

protected boolean first
First read.

flushMessageArray

protected static final byte[] flushMessageArray
Flush message array.

getBodyMessageArray

protected final byte[] getBodyMessageArray
Direct buffer used for sending right away a get body message.

hostNameC

protected char[] hostNameC
Host name (used to avoid useless B2C conversion on the host name).

input

protected InputStream input
Input stream.

keepAliveTimeout

protected int keepAliveTimeout
The number of milliseconds Tomcat will wait for a subsequent request before closing the connection. The default is the same as for Apache HTTP Server (15 000 milliseconds).

log

protected static Log log
Logger.

output

protected OutputStream output
Output stream.

packetSize

protected int packetSize
The socket timeout used when reading the first block of the request header.

pongMessageArray

protected static final byte[] pongMessageArray
Direct buffer used for sending right away a pong message.

readTimeout

protected long readTimeout
The socket timeout used when reading the first block of the request header.

replay

protected boolean replay
Replay read.

request

protected Request request
Request object.

requestHeaderMessage

protected AjpMessage requestHeaderMessage
Header message. Note that this header is merely the one used during the processing of the first message of a "request", so it might not be a request header. It will stay unchanged during the processing of the whole request.

requiredSecret

protected String requiredSecret
Required secret.

response

protected Response response
Response object.

responseHeaderMessage

protected AjpMessage responseHeaderMessage
Message used for response header composition.

sm

protected static StringManager sm
The string manager for this package.

socket

protected Socket socket
Socket associated with the current connection.

started

protected boolean started
State flag.

tmpMB

protected MessageBytes tmpMB
Temp message bytes used for processing.

tomcatAuthentication

protected boolean tomcatAuthentication
Use Tomcat authentication ?

Constructor Detail

AjpProcessor

public AjpProcessor(int packetSize, JIoEndpoint endpoint)

Method Detail

action

public void action(ActionCode actionCode, Object param)
Send an action to the connector.

Parameters: actionCode Type of the action param Action parameter

finish

protected void finish()
Finish AJP response.

flush

protected void flush()
Callback to write data from the buffer.

getAdapter

public Adapter getAdapter()
Get the associated adapter.

Returns: the associated adapter

getKeepAliveTimeout

public int getKeepAliveTimeout()

getRequest

public Request getRequest()
Get the request associated with this processor.

Returns: The request

getTomcatAuthentication

public boolean getTomcatAuthentication()

parseHost

public void parseHost(MessageBytes valueMB)
Parse host.

prepareRequest

protected void prepareRequest()
After reading the request headers, we have to setup the request filters.

prepareResponse

protected void prepareResponse()
When committing the response, we have to validate the set of headers, as well as setup the response filters.

process

public void process(Socket socket)
Process pipelined HTTP requests using the specified input and output streams.

Throws: IOException error during an I/O operation

read

protected boolean read(byte[] buf, int pos, int n)
Read at least the specified amount of bytes, and place them in the input buffer.

readMessage

protected boolean readMessage(AjpMessage message)
Read an AJP message.

Returns: true if the message has been read, false if the short read didn't return anything

Throws: IOException any other failure, including incomplete reads

receive

public boolean receive()
Receive a chunk of data. Called to implement the 'special' packet in ajp13 and to receive the data after we send a GET_BODY packet

recycle

public void recycle()
Recycle the processor.

setAdapter

public void setAdapter(Adapter adapter)
Set the associated adapter.

Parameters: adapter the new adapter

setKeepAliveTimeout

public void setKeepAliveTimeout(int timeout)

setRequiredSecret

public void setRequiredSecret(String requiredSecret)

setTomcatAuthentication

public void setTomcatAuthentication(boolean tomcatAuthentication)
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.