public void onRequest(IHttpExchange exchange) throws IOException {
boolean chunkedTest = exchange.getRequest().getBooleanParameter("chunked");
if (chunkedTest) {
HttpResponseHeader header = new HttpResponseHeader(200, "text/plain");
header.setHeader("connection", "close");
BodyDataSink bodyDataSink = exchange.send(header);
bodyDataSink.write("test123");
bodyDataSink.write("456\r\n");
bodyDataSink.close();
} else {
BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), 10);
bodyDataSink.write("test123\r\n");
bodyDataSink.write("456");
bodyDataSink.close();
}
}