| java.lang.Object org.apache.ajp.Ajp13Packet
Ajp13Packet | public class Ajp13Packet (Code) | | A single packet for communication between the web server and the
container. Designed to be reused many times with no creation of
garbage. Understands the format of data types for these packets.
Can be used (somewhat confusingly) for both incoming and outgoing
packets.
See Also: Ajp14/Ajp13Packet author: Henri Gomez [hgomez@apache.org] author: Dan Milstein [danmil@shore.net] author: Keith Wannamaker [Keith@Wannamaker.org] author: Kevin Seguin author: Costin Manolache |
Constructor Summary | |
public | Ajp13Packet(int size) Create a new packet with an internal buffer of given size. | public | Ajp13Packet(byte b) |
Method Summary | |
public MessageBytes | addHeader(MimeHeaders headers) | public void | appendBool(boolean val) | public void | appendByte(byte val) | public void | appendBytes(byte b, int off, int numBytes) Copy a chunk of bytes into the packet, starting at the current
write position. | public void | appendInt(int val) | public void | appendLongInt(int val) | public void | appendString(String str) Write a String out at the current write position. | public void | appendXBytes(byte[] b, int off, int numBytes) Copy a chunk of bytes into the packet, starting at the current
write position. | public int | checkIn() Parse the packet header for a packet sent from the web server to
the container. | public void | dump(String msg) | public void | end() For a packet to be sent to the web server, finish the process of
accumulating data and write the length of the data payload into
the header. | public boolean | getBool() | public byte[] | getBuff() | public byte | getByte() | public int | getByteOff() Get offset into internal buffer. | public int | getBytes(byte dest) Copy a chunk of bytes from the packet into an array and advance
the read position past the chunk. | public String | getEncoding() Get the encoding used for byte[] <-> string
conversions. | public int | getInt() Read an integer from packet, and advance the read position past
it. | public int | getLen() Get length.
length -- This actually means different things depending on whether thepacket is read or write. | public int | getLongInt() Read a 32 bits integer from packet, and advance the read position past
it. | public void | getMessageBytes(MessageBytes mb) | public String | getString() Read a String from the packet, and advance the read position
past it. | public int | getXBytes(byte[] dest, int length) Copy a chunk of bytes from the packet into an array and advance
the read position past the chunk. | public byte | peekByte() | public int | peekInt() Read an integer from the packet, but don't advance the read
position past it. | public int | peekLongInt() Read a 32 bits integer from the packet, but don't advance the read
position past it. | public void | reset() Prepare this packet for accumulating a message from the container to
the web server. | public void | setByteOff(int c) Set offset into internal buffer. | public void | setEncoding(String encoding) Set the encoding to use for byte[] <-> string
conversions. |
AJP13_SW_HEADER | final public static int AJP13_SW_HEADER(Code) | | |
AJP13_WS_HEADER | final public static int AJP13_WS_HEADER(Code) | | |
DEFAULT_CHAR_ENCODING | final public static String DEFAULT_CHAR_ENCODING(Code) | | |
buff | byte buff(Code) | | Holds the bytes of the packet
|
encoding | String encoding(Code) | | encoding to use when converting byte[] <-> string
|
len | int len(Code) | | This actually means different things depending on whether the
packet is read or write. For read, it's the length of the
payload (excluding the header). For write, it's the length of
the packet as a whole (counting the header). Oh, well.
|
pos | int pos(Code) | | The current read or write position in the buffer
|
Ajp13Packet | public Ajp13Packet(int size)(Code) | | Create a new packet with an internal buffer of given size.
Parameters: size - packet size |
Ajp13Packet | public Ajp13Packet(byte b)(Code) | | Create a new packet with given bytes
Parameters: b - this packet's bytes. |
appendBool | public void appendBool(boolean val)(Code) | | |
appendByte | public void appendByte(byte val)(Code) | | |
appendBytes | public void appendBytes(byte b, int off, int numBytes)(Code) | | Copy a chunk of bytes into the packet, starting at the current
write position. The chunk of bytes is encoded with the length
in two bytes first, then the data itself, and finally a
terminating \0 (which is not included in the encoded
length).
Parameters: b - The array from which to copy bytes. Parameters: off - The offset into the array at which to start copying Parameters: len - The number of bytes to copy. |
appendInt | public void appendInt(int val)(Code) | | |
appendLongInt | public void appendLongInt(int val)(Code) | | |
appendString | public void appendString(String str) throws UnsupportedEncodingException(Code) | | Write a String out at the current write position. Strings are
encoded with the length in two bytes first, then the string, and
then a terminating \0 (which is not included in the
encoded length). The terminator is for the convenience of the C
code, where it saves a round of copying. A null string is
encoded as a string with length 0.
|
appendXBytes | public void appendXBytes(byte[] b, int off, int numBytes)(Code) | | Copy a chunk of bytes into the packet, starting at the current
write position. The chunk of bytes IS NOT ENCODED with ANY length
header.
Parameters: b - The array from which to copy bytes. Parameters: off - The offset into the array at which to start copying Parameters: len - The number of bytes to copy. |
checkIn | public int checkIn()(Code) | | Parse the packet header for a packet sent from the web server to
the container. Set the read position to immediately after
the header.
The length of the packet payload, as encoded in theheader, or -1 if the packet doesn't have a valid header. |
end | public void end()(Code) | | For a packet to be sent to the web server, finish the process of
accumulating data and write the length of the data payload into
the header.
|
getBool | public boolean getBool()(Code) | | |
getBuff | public byte[] getBuff()(Code) | | Get the internal buffer
internal buffer |
getByte | public byte getByte()(Code) | | |
getByteOff | public int getByteOff()(Code) | | Get offset into internal buffer.
offset |
getBytes | public int getBytes(byte dest)(Code) | | Copy a chunk of bytes from the packet into an array and advance
the read position past the chunk. See appendBytes() for details
on the encoding.
The number of bytes copied. |
getEncoding | public String getEncoding()(Code) | | Get the encoding used for byte[] <-> string
conversions.
the encoding used. |
getInt | public int getInt()(Code) | | Read an integer from packet, and advance the read position past
it. Integers are encoded as two unsigned bytes with the
high-order byte first, and, as far as I can tell, in
little-endian order within each byte.
|
getLen | public int getLen()(Code) | | Get length.
length -- This actually means different things depending on whether thepacket is read or write. For read, it's the length of thepayload (excluding the header). For write, it's the length ofthe packet as a whole (counting the header). Oh, well. |
getLongInt | public int getLongInt()(Code) | | Read a 32 bits integer from packet, and advance the read position past
it. Integers are encoded as four unsigned bytes with the
high-order byte first, and, as far as I can tell, in
little-endian order within each byte.
|
getXBytes | public int getXBytes(byte[] dest, int length)(Code) | | Copy a chunk of bytes from the packet into an array and advance
the read position past the chunk. See appendXBytes() for details
on the encoding.
The number of bytes copied. |
peekByte | public byte peekByte()(Code) | | |
peekInt | public int peekInt()(Code) | | Read an integer from the packet, but don't advance the read
position past it.
|
peekLongInt | public int peekLongInt()(Code) | | Read a 32 bits integer from the packet, but don't advance the read
position past it.
|
reset | public void reset()(Code) | | Prepare this packet for accumulating a message from the container to
the web server. Set the write position to just after the header
(but leave the length unwritten, because it is as yet unknown).
|
setByteOff | public void setByteOff(int c)(Code) | | Set offset into internal buffer.
Parameters: c - new offset |
setEncoding | public void setEncoding(String encoding)(Code) | | Set the encoding to use for byte[] <-> string
conversions.
Parameters: encoding - the encoding to use. |
|
|