org.apache.tomcat.modules.server
Class Ajp13

java.lang.Object
  extended byorg.apache.tomcat.modules.server.Ajp13

public class Ajp13
extends java.lang.Object

Represents a single, persistent connection between the web server and the servlet container. Uses the Apache JServ Protocol version 1.3 for communication. Because this protocal does not multiplex requests, this connection can only be associated with a single request-handling cycle at a time.

This class contains knowledge about how an individual packet is laid out (via the internal Ajp13Packet class), and also about the stages of communicaton between the server and the servlet container. It translates from Tomcat's internal servlet support methods (e.g. doWrite) to the correct packets to send to the web server.

Author:
Dan Milstein [danmil@shore.net], Keith Wannamaker [Keith@Wannamaker.org]
See Also:
Ajp13Interceptor

Field Summary
static int H_SIZE
           
static java.lang.String[] headerTransArray
           
static int JK_AJP13_BAD_BODY
           
static int JK_AJP13_BAD_HEADER
           
static int JK_AJP13_COMM_BROKEN
           
static int JK_AJP13_COMM_CLOSED
           
static byte JK_AJP13_END_RESPONSE
           
static byte JK_AJP13_FORWARD_REQUEST
           
static byte JK_AJP13_GET_BODY_CHUNK
           
static int JK_AJP13_INCOMPLETE_BODY
           
static int JK_AJP13_NO_HEADER
           
static byte JK_AJP13_SEND_BODY_CHUNK
           
static byte JK_AJP13_SEND_HEADERS
           
static byte JK_AJP13_SHUTDOWN
           
static int MAX_PACKET_SIZE
           
static int MAX_READ_SIZE
           
static int MAX_SEND_SIZE
           
static java.lang.String[] methodTransArray
           
static byte SC_A_ARE_DONE
           
static byte SC_A_AUTH_TYPE
           
static byte SC_A_CONTEXT
           
static byte SC_A_JVM_ROUTE
           
static byte SC_A_QUERY_STRING
           
static byte SC_A_REMOTE_USER
           
static byte SC_A_REQ_ATTRIBUTE
           
static byte SC_A_SECRET
           
static byte SC_A_SERVLET_PATH
           
static byte SC_A_SSL_CERT
           
static byte SC_A_SSL_CIPHER
           
static byte SC_A_SSL_SESSION
           
static int SC_RESP_CONTENT_LANGUAGE
           
static int SC_RESP_CONTENT_LENGTH
           
static int SC_RESP_CONTENT_TYPE
           
static int SC_RESP_DATE
           
static int SC_RESP_LAST_MODIFIED
           
static int SC_RESP_LOCATION
           
static int SC_RESP_SERVLET_ENGINE
           
static int SC_RESP_SET_COOKIE
           
static int SC_RESP_SET_COOKIE2
           
static int SC_RESP_STATUS
           
static int SC_RESP_WWW_AUTHENTICATE
           
 
Constructor Summary
Ajp13()
           
 
Method Summary
 void close()
          Close the socket connection to the web server.
 int doRead()
          Return the next byte of request body data (to a servlet).
 int doRead(byte[] b, int off, int len)
          Store a chunk of request data into the passed-in byte buffer.
 void doWrite(byte[] b, int off, int len)
          Send a chunk of response body data to the web server and on to the browser.
 void finish()
          Signal the web server that the servlet has finished handling this request, and that the connection can be reused.
 java.lang.String getSecret()
           
protected  int headerNameToSc(java.lang.String name)
          Translate an HTTP response header name to an integer code if possible.
 boolean isTomcatAuthentication()
           
 int receiveNextRequest(Request req)
          Read a new packet from the web server and decode it.
 void recycle()
           
 void sendHeaders(int status, MimeHeaders headers)
          Send the HTTP headers back to the web server and on to the browser.
 void setDebug(int i)
           
 void setSocket(java.net.Socket socket)
          Associate an open socket with this instance.
 void setTomcatAuthentication(boolean newTomcatAuthentication)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PACKET_SIZE

public static final int MAX_PACKET_SIZE
See Also:
Constant Field Values

H_SIZE

public static final int H_SIZE
See Also:
Constant Field Values

MAX_READ_SIZE

public static final int MAX_READ_SIZE
See Also:
Constant Field Values

MAX_SEND_SIZE

public static final int MAX_SEND_SIZE
See Also:
Constant Field Values

JK_AJP13_FORWARD_REQUEST

public static final byte JK_AJP13_FORWARD_REQUEST
See Also:
Constant Field Values

JK_AJP13_SHUTDOWN

public static final byte JK_AJP13_SHUTDOWN
See Also:
Constant Field Values

JK_AJP13_BAD_HEADER

public static final int JK_AJP13_BAD_HEADER
See Also:
Constant Field Values

JK_AJP13_NO_HEADER

public static final int JK_AJP13_NO_HEADER
See Also:
Constant Field Values

JK_AJP13_COMM_CLOSED

public static final int JK_AJP13_COMM_CLOSED
See Also:
Constant Field Values

JK_AJP13_COMM_BROKEN

public static final int JK_AJP13_COMM_BROKEN
See Also:
Constant Field Values

JK_AJP13_BAD_BODY

public static final int JK_AJP13_BAD_BODY
See Also:
Constant Field Values

JK_AJP13_INCOMPLETE_BODY

public static final int JK_AJP13_INCOMPLETE_BODY
See Also:
Constant Field Values

JK_AJP13_SEND_BODY_CHUNK

public static final byte JK_AJP13_SEND_BODY_CHUNK
See Also:
Constant Field Values

JK_AJP13_SEND_HEADERS

public static final byte JK_AJP13_SEND_HEADERS
See Also:
Constant Field Values

JK_AJP13_END_RESPONSE

public static final byte JK_AJP13_END_RESPONSE
See Also:
Constant Field Values

JK_AJP13_GET_BODY_CHUNK

public static final byte JK_AJP13_GET_BODY_CHUNK
See Also:
Constant Field Values

SC_RESP_CONTENT_TYPE

public static final int SC_RESP_CONTENT_TYPE
See Also:
Constant Field Values

SC_RESP_CONTENT_LANGUAGE

public static final int SC_RESP_CONTENT_LANGUAGE
See Also:
Constant Field Values

SC_RESP_CONTENT_LENGTH

public static final int SC_RESP_CONTENT_LENGTH
See Also:
Constant Field Values

SC_RESP_DATE

public static final int SC_RESP_DATE
See Also:
Constant Field Values

SC_RESP_LAST_MODIFIED

public static final int SC_RESP_LAST_MODIFIED
See Also:
Constant Field Values

SC_RESP_LOCATION

public static final int SC_RESP_LOCATION
See Also:
Constant Field Values

SC_RESP_SET_COOKIE

public static final int SC_RESP_SET_COOKIE
See Also:
Constant Field Values

SC_RESP_SET_COOKIE2

public static final int SC_RESP_SET_COOKIE2
See Also:
Constant Field Values

SC_RESP_SERVLET_ENGINE

public static final int SC_RESP_SERVLET_ENGINE
See Also:
Constant Field Values

SC_RESP_STATUS

public static final int SC_RESP_STATUS
See Also:
Constant Field Values

SC_RESP_WWW_AUTHENTICATE

public static final int SC_RESP_WWW_AUTHENTICATE
See Also:
Constant Field Values

SC_A_CONTEXT

public static final byte SC_A_CONTEXT
See Also:
Constant Field Values

SC_A_SERVLET_PATH

public static final byte SC_A_SERVLET_PATH
See Also:
Constant Field Values

SC_A_REMOTE_USER

public static final byte SC_A_REMOTE_USER
See Also:
Constant Field Values

SC_A_AUTH_TYPE

public static final byte SC_A_AUTH_TYPE
See Also:
Constant Field Values

SC_A_QUERY_STRING

public static final byte SC_A_QUERY_STRING
See Also:
Constant Field Values

SC_A_JVM_ROUTE

public static final byte SC_A_JVM_ROUTE
See Also:
Constant Field Values

SC_A_SSL_CERT

public static final byte SC_A_SSL_CERT
See Also:
Constant Field Values

SC_A_SSL_CIPHER

public static final byte SC_A_SSL_CIPHER
See Also:
Constant Field Values

SC_A_SSL_SESSION

public static final byte SC_A_SSL_SESSION
See Also:
Constant Field Values

SC_A_SECRET

public static final byte SC_A_SECRET
See Also:
Constant Field Values

SC_A_REQ_ATTRIBUTE

public static final byte SC_A_REQ_ATTRIBUTE
See Also:
Constant Field Values

SC_A_ARE_DONE

public static final byte SC_A_ARE_DONE
See Also:
Constant Field Values

methodTransArray

public static final java.lang.String[] methodTransArray

headerTransArray

public static final java.lang.String[] headerTransArray
Constructor Detail

Ajp13

public Ajp13()
Method Detail

recycle

public void recycle()

isTomcatAuthentication

public boolean isTomcatAuthentication()

setTomcatAuthentication

public void setTomcatAuthentication(boolean newTomcatAuthentication)

setSocket

public void setSocket(java.net.Socket socket)
               throws java.io.IOException
Associate an open socket with this instance.

Throws:
java.io.IOException

getSecret

public java.lang.String getSecret()

receiveNextRequest

public int receiveNextRequest(Request req)
                       throws java.io.IOException
Read a new packet from the web server and decode it. If it's a forwarded request, store its properties in the passed-in Request object.

Parameters:
req - An empty (newly-recycled) request object.
Returns:
200 in case of a successful read of a forwarded request, 500 if there were errors in the reading of the request, and -2 if the server is asking the container to shut itself down.
Throws:
java.io.IOException

doRead

public int doRead()
           throws java.io.IOException
Return the next byte of request body data (to a servlet).

Throws:
java.io.IOException
See Also:
Ajp13Request#doRead

doRead

public int doRead(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Store a chunk of request data into the passed-in byte buffer.

Parameters:
b - A buffer to fill with data from the request.
off - The offset in the buffer at which to start filling.
len - The number of bytes to copy into the buffer.
Returns:
The number of bytes actually copied into the buffer, or -1 if the end of the stream has been reached.
Throws:
java.io.IOException
See Also:
Ajp13Request#doRead

sendHeaders

public void sendHeaders(int status,
                        MimeHeaders headers)
                 throws java.io.IOException
Send the HTTP headers back to the web server and on to the browser.

Parameters:
status - The HTTP status code to send.
headers - The set of all headers.
Throws:
java.io.IOException

headerNameToSc

protected int headerNameToSc(java.lang.String name)
Translate an HTTP response header name to an integer code if possible. Case is ignored.

Parameters:
name - The name of the response header to translate.
Returns:
The code for that header name, or -1 if no code exists.

finish

public void finish()
            throws java.io.IOException
Signal the web server that the servlet has finished handling this request, and that the connection can be reused.

Throws:
java.io.IOException

doWrite

public void doWrite(byte[] b,
                    int off,
                    int len)
             throws java.io.IOException
Send a chunk of response body data to the web server and on to the browser.

Parameters:
b - A huffer of bytes to send.
off - The offset into the buffer from which to start sending.
len - The number of bytes to send.
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the socket connection to the web server. In general, sockets are maintained across many requests, so this will not be called after finish().

Throws:
java.io.IOException
See Also:
Ajp13Interceptor.processConnection(org.apache.tomcat.util.net.TcpConnection, java.lang.Object[])

setDebug

public void setDebug(int i)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.