Il codice che sto usando ora:Come leggere correttamente il corpo della richiesta POST in un gestore?
Pooled<ByteBuffer> pooledByteBuffer = exchange.getConnection().getBufferPool().allocate();
ByteBuffer byteBuffer = pooledByteBuffer.getResource();
int limit = byteBuffer.limit();
byteBuffer.clear();
exchange.getRequestChannel().read(byteBuffer);
int pos = byteBuffer.position();
byteBuffer.rewind();
byte[] bytes = new byte[pos];
byteBuffer.get(bytes);
String requestBody = new String(bytes, Charset.forName("UTF-8"));
byteBuffer.clear();
pooledByteBuffer.free();
sembra funzionare male, ma non sono sicuro circa la necessità di clear()
ByteBuffer prima di tornare alla piscina. Non sono nemmeno sicuro di usare exchange.getConnection().getBufferPool().allocate();
. Non c'è molto a riguardo nella documentazione.