}
private void decodeHeaders( MsgContext ep, Msg msg, Request req,
MessageBytes tmpMB ) {
// Decode headers
MimeHeaders headers = req.getMimeHeaders();
int hCount = msg.getInt();
for(int i = 0 ; i < hCount ; i++) {
String hName = null;
// Header names are encoded as either an integer code starting
// with 0xA0, or as a normal string (in which case the first
// two bytes are the length).
int isc = msg.peekInt();
int hId = isc & 0xFF;
MessageBytes vMB=null;
isc &= 0xFF00;
if(0xA000 == isc) {
msg.getInt(); // To advance the read position
hName = AjpConstants.headerTransArray[hId - 1];
vMB=headers.addValue( hName );
} else {
// reset hId -- if the header currently being read
// happens to be 7 or 8 bytes long, the code below
// will think it's the content-type header or the
// content-length header - SC_REQ_CONTENT_TYPE=7,
// SC_REQ_CONTENT_LENGTH=8 - leading to unexpected
// behaviour. see bug 5861 for more information.
hId = -1;
msg.getBytes( tmpMB );
ByteChunk bc=tmpMB.getByteChunk();
vMB=headers.addValue( bc.getBuffer(),
bc.getStart(), bc.getLength() );
}
msg.getBytes(vMB);