## org.apache.coyote.ajp
Class AjpProcessor

    java.lang.Object
      org.apache.coyote.ajp.AjpProcessor

All Implemented Interfaces:
  ActionHook

    public class AjpProcessor

extends java.lang.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 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
`protected Adapter` `adapter` Associated adapter.
`protected MessageBytes` `bodyBytes` Body message.
`protected AjpMessage` `bodyMessage` Body message.
`protected MessageBytes` `certificates` Byte chunk for certs.
`protected boolean` `empty` Body empty flag.
`protected static byte[]` `endMessageArray` End message array.
`protected boolean` `endOfStream` End of stream flag.
`protected JIoEndpoint` `endpoint` Associated endpoint.
`protected boolean` `error` Error flag.
`protected boolean` `finished` Finished response.
`protected boolean` `first` 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 java.io.InputStream` `input` Input stream.
`protected int` `keepAliveTimeout` The number of milliseconds Tomcat will wait for a subsequent request before closing the connection.
`protected static Log` `log` Logger.
`protected java.io.OutputStream` `output` Output stream.
`protected int` `packetSize` 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 long` `readTimeout` The socket timeout used when reading the first block of the request header.
`protected boolean` `replay` Replay read.
`protected Request` `request` Request object.
`protected AjpMessage` `requestHeaderMessage` Header message.
`protected java.lang.String` `requiredSecret` Required secret.
`protected Response` `response` Response object.
`protected AjpMessage` `responseHeaderMessage` Message used for response header composition.
`protected static StringManager` `sm` The string manager for this package.
`protected java.net.Socket` `socket` Socket associated with the current connection.
`protected boolean` `started` State flag.
`protected MessageBytes` `tmpMB` Temp message bytes used for processing.
`protected boolean` `tomcatAuthentication` Use Tomcat authentication ?

Constructor Summary
`AjpProcessor(int packetSize, JIoEndpoint endpoint)`

Method Summary
`void` `action(ActionCode actionCode, java.lang.Object param)` Send an action to the connector.
`protected void` `finish()` Finish AJP response.
`protected void` `flush()` Callback to write data from the buffer.
`Adapter` `getAdapter()` Get the associated adapter.
`int` `getKeepAliveTimeout()`
`Request` `getRequest()` Get the request associated with this processor.
`boolean` `getTomcatAuthentication()`
`void` `parseHost(MessageBytes valueMB)` Parse host.
`protected void` `prepareRequest()` After reading the request headers, we have to setup the request filters.
`protected void` `prepareResponse()` When committing the response, we have to validate the set of headers, as well as setup the response filters.
`void` `process(java.net.Socket socket)` Process pipelined HTTP requests using the specified input and output streams.
`protected boolean` `read(byte[] buf, int pos, int n)` Read at least the specified amount of bytes, and place them in the input buffer.
`protected boolean` `readMessage(AjpMessage message)` Read an AJP message.
`boolean` `receive()` Receive a chunk of data.
`void` `recycle()` Recycle the processor.
`void` `setAdapter(Adapter adapter)` Set the associated adapter.
`void` `setKeepAliveTimeout(int timeout)`
`void` `setRequiredSecret(java.lang.String requiredSecret)`
`void` `setTomcatAuthentication(boolean tomcatAuthentication)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    protected static Log log

  Logger.

### sm

    protected static StringManager sm

  The string manager for this package.

### adapter

    protected Adapter adapter

  Associated adapter.

### request

    protected Request request

  Request object.

### response

    protected Response response

  Response object.

### packetSize

    protected int packetSize

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

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

### responseHeaderMessage

    protected AjpMessage responseHeaderMessage

  Message used for response header composition.

### bodyMessage

    protected AjpMessage bodyMessage

  Body message.

### bodyBytes

    protected MessageBytes bodyBytes

  Body message.

### started

    protected boolean started

  State flag.

### error

    protected boolean error

  Error flag.

### socket

    protected java.net.Socket socket

  Socket associated with the current connection.

### input

    protected java.io.InputStream input

  Input stream.

### output

    protected java.io.OutputStream output

  Output stream.

### hostNameC

    protected char[] hostNameC

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

### endpoint

    protected JIoEndpoint endpoint

  Associated endpoint.

### readTimeout

    protected long readTimeout

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

### tmpMB

    protected MessageBytes tmpMB

  Temp message bytes used for processing.

### certificates

    protected MessageBytes certificates

  Byte chunk for certs.

### endOfStream

    protected boolean endOfStream

  End of stream flag.

### empty

    protected boolean empty

  Body empty flag.

### first

    protected boolean first

  First read.

### replay

    protected boolean replay

  Replay read.

### finished

    protected boolean finished

  Finished response.

### getBodyMessageArray

    protected final byte[] getBodyMessageArray

  Direct buffer used for sending right away a get body message.

### pongMessageArray

    protected static final byte[] pongMessageArray

  Direct buffer used for sending right away a pong message.

### endMessageArray

    protected static final byte[] endMessageArray

  End message array.

### flushMessageArray

    protected static final byte[] flushMessageArray

  Flush message array.

### tomcatAuthentication

    protected boolean tomcatAuthentication

  Use Tomcat authentication ?

### requiredSecret

    protected java.lang.String requiredSecret

  Required secret.

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

Constructor Detail

### AjpProcessor

    public AjpProcessor(int packetSize,
                        JIoEndpoint endpoint)

Method Detail

### getTomcatAuthentication

    public boolean getTomcatAuthentication()

### setTomcatAuthentication

    public void setTomcatAuthentication(boolean tomcatAuthentication)

### setRequiredSecret

    public void setRequiredSecret(java.lang.String requiredSecret)

### getKeepAliveTimeout

    public int getKeepAliveTimeout()

### setKeepAliveTimeout

    public void setKeepAliveTimeout(int timeout)

### getRequest

    public Request getRequest()

  Get the request associated with this processor.

  Returns:
    The request

### process

    public void process(java.net.Socket socket)
                 throws java.io.IOException

  Process pipelined HTTP requests using the specified input and output streams.

  Throws:
    `java.io.IOException` - error during an I/O operation

### action

    public void action(ActionCode actionCode,
                       java.lang.Object param)

  Send an action to the connector.

  Specified by:
    `action` in interface `ActionHook`
  Parameters:
    `actionCode` - Type of the action
    `param` - Action parameter

### setAdapter

    public void setAdapter(Adapter adapter)

  Set the associated adapter.

  Parameters:
    `adapter` - the new adapter

### getAdapter

    public Adapter getAdapter()

  Get the associated adapter.

  Returns:
    the associated adapter

### prepareRequest

    protected void prepareRequest()

  After reading the request headers, we have to setup the request filters.

### parseHost

    public void parseHost(MessageBytes valueMB)

  Parse host.

### prepareResponse

    protected void prepareResponse()
                            throws java.io.IOException

  When committing the response, we have to validate the set of headers, as well as setup the response filters.

  Throws:
    `java.io.IOException`

### finish

    protected void finish()
                   throws java.io.IOException

  Finish AJP response.

  Throws:
    `java.io.IOException`

### read

    protected boolean read(byte[] buf,
                           int pos,
                           int n)
                    throws java.io.IOException

  Read at least the specified amount of bytes, and place them in the input buffer.

  Throws:
    `java.io.IOException`

### receive

    public boolean receive()
                    throws java.io.IOException

  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

  Throws:
    `java.io.IOException`

### readMessage

    protected boolean readMessage(AjpMessage message)
                           throws java.io.IOException

  Read an AJP message.

  Returns:
    true if the message has been read, false if the short read didn't return anything
  Throws:
    `java.io.IOException` - any other failure, including incomplete reads

### recycle

    public void recycle()

  Recycle the processor.

### flush

    protected void flush()
                  throws java.io.IOException

  Callback to write data from the buffer.

  Throws:
    `java.io.IOException`

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