session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY);
// fallthrough, process body immediately
} else {
LOG.debug("request without content");
session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
out.write(new HttpEndOfContent());
break;
}
}
case BODY:
LOG.debug("decoding BODY: {} bytes", msg.remaining());
final int chunkSize = msg.remaining();
// send the chunk of body
if (chunkSize != 0) {
final IoBuffer wb = IoBuffer.allocate(msg.remaining());
wb.put(msg);
wb.flip();
out.write(wb);
}
msg.position(msg.limit());
// do we have reach end of body ?
int remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES);
remaining -= chunkSize;
if (remaining <= 0) {
LOG.debug("end of HTTP body");
session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
session.removeAttribute(BODY_REMAINING_BYTES);
out.write(new HttpEndOfContent());
} else {
session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining));
}
break;