@Override public void onData(Stream stream, DataInfo dataInfo) { HttpExchange exchange = getHttpExchange(); if (exchange == null) return; try { int length = dataInfo.length(); // TODO: avoid data copy here boolean process = responseContent(exchange, dataInfo.asByteBuffer(false)); dataInfo.consume(length); if (process) { if (dataInfo.isClose()) { responseSuccess(exchange); } } } catch (Exception x) { responseFailure(x); } }