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
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.
H_SIZE
public static final int H_SIZE
- 4
JK_AJP13_BAD_BODY
public static final int JK_AJP13_BAD_BODY
- -104
JK_AJP13_BAD_HEADER
public static final int JK_AJP13_BAD_HEADER
- -100
JK_AJP13_COMM_BROKEN
public static final int JK_AJP13_COMM_BROKEN
- -103
JK_AJP13_COMM_CLOSED
public static final int JK_AJP13_COMM_CLOSED
- -102
JK_AJP13_INCOMPLETE_BODY
public static final int JK_AJP13_INCOMPLETE_BODY
- -105
JK_AJP13_NO_HEADER
public static final int JK_AJP13_NO_HEADER
- -101
MAX_PACKET_SIZE
public static final int MAX_PACKET_SIZE
- 8192
MAX_READ_SIZE
public static final int MAX_READ_SIZE
- 8186
MAX_SEND_SIZE
public static final int MAX_SEND_SIZE
- 8184
available
public int available()
throws IOException
-- Will use reqHandler, make sure nobody else
calls this
beginSendHeaders
public void beginSendHeaders(int status,
String statusMessage,
int numHeaders)
throws IOException
close
public void close()
throws 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().
Ajp13Interceptor.processConnection
doRead
public int doRead()
throws IOException
doRead
public int doRead(byte[] b,
int off,
int len)
throws IOException
doWrite
public void doWrite(b[] ,
int off,
int len)
throws IOException
endSendHeaders
public void endSendHeaders()
throws IOException
finish
public void finish()
throws IOException
getSecret
public String getSecret()
handleMessage
public int handleMessage(int type,
Ajp13Packet hBuf,
BaseRequest req)
throws IOException
Override for ajp14, temporary
initBuf
public void initBuf()
Will be overriden
isLogged
public boolean isLogged()
receive
public int receive(Ajp13Packet msg)
throws IOException
Read in a packet from the web server and store it in the passed-in
Ajp13Packet
object.
msg
- The object into which to store the incoming packet -- any
current contents will be overwritten.
- The number of bytes read on a successful read or -1 if there
was an error.
receiveNextRequest
public int receiveNextRequest(BaseRequest req)
throws 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 AjpRequest
object.
req
- An empty (newly-recycled) request object.
- 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.
recycle
public void recycle()
registerMessageType
public int registerMessageType(int id,
String name,
AjpHandler h,
sig[] )
send
public void send(Ajp13Packet msg)
throws IOException
Send a packet to the web server. Works for any type of message.
msg
- A packet with accumulated data to send to the server --
this method will write out the length in the header.
sendHeader
public void sendHeader(String name,
String value)
throws IOException
sendHeaders
public void sendHeaders(int status,
String statusMessage,
MimeHeaders headers)
throws IOException
sendHeaders
public void sendHeaders(int status,
MimeHeaders headers)
throws IOException
setBackward
public void setBackward(boolean b)
Backward compat mode, no login needed
setDebug
public void setDebug(int debug)
setLogger
public void setLogger(Logger l)
setSecret
public void setSecret(String s)
setSocket
public void setSocket(Socket socket)
throws IOException
Associate an open socket with this instance.