read(headerLength);
}
inputBuffer.get(message.getBuffer(), 0, headerLength);
- int messageLength = message.processHeader();
+ int messageLength = message.processHeader(true);
if (messageLength < 0) {
// Invalid AJP header signature
// TODO: Throw some exception and close the connection to frontend.
return buf.length;
}
-
+ @Deprecated
public int processHeader() {
+ return processHeader(true);
+ }
+
+ public int processHeader(boolean toContainer) {
pos = 0;
int mark = getInt();
len = getInt();
// Verify message signature
- if ((mark != 0x1234) && (mark != 0x4142)) {
+ if ((toContainer && mark != 0x1234) ||
+ (!toContainer && mark != 0x4142)) {
log.error(sm.getString("ajpmessage.invalid", "" + mark));
if (log.isDebugEnabled()) {
dump("In: ");
return 0;
}
- int messageLength = message.processHeader();
+ int messageLength = message.processHeader(true);
if (messageLength < 0) {
// Invalid AJP header signature
throw new IOException(sm.getString("ajpmessage.invalidLength",
read(buf, 0, headerLength);
- int messageLength = message.processHeader();
+ int messageLength = message.processHeader(true);
if (messageLength < 0) {
// Invalid AJP header signature
// TODO: Throw some exception and close the connection to frontend.
read(is, buf, 0, headerLength);
- int messageLength = message.processHeader();
+ int messageLength = message.processHeader(false);
if (messageLength < 0) {
throw new IOException("Invalid AJP message length");
} else if (messageLength == 0) {
assertEquals((byte) 'B', message.buf[1]);
// Set the start position and read the length
- message.processHeader();
+ message.processHeader(false);
// Check the length
assertTrue(message.len > 0);
assertEquals((byte) 'B', message.buf[1]);
// Set the start position and read the length
- message.processHeader();
+ message.processHeader(false);
// Should be a body chunk message
assertEquals(0x03, message.readByte());
assertEquals((byte) 'A', message.buf[0]);
assertEquals((byte) 'B', message.buf[1]);
- message.processHeader();
+ message.processHeader(false);
// Should be an end body message
assertEquals(0x05, message.readByte());
return readString(len);
}
}
+
+ @Override
+ public void end() {
+ len = pos;
+ int dLen = len - 4;
+
+ buf[0] = (byte) 0x12;
+ buf[1] = (byte) 0x34;
+ buf[2] = (byte) ((dLen>>>8) & 0xFF);
+ buf[3] = (byte) (dLen & 0xFF);
+ }
+
+
}