public void handle(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
BasicHttpEntity entity = new BasicHttpEntity() {
@Override
public void writeTo(
final OutputStream outstream) throws IOException {
byte[] tmp = new byte[5];
outstream.write(tmp);
outstream.flush();
// do something comletely ugly in order to trigger
// MalformedChunkCodingException
DefaultHttpServerConnection conn = (DefaultHttpServerConnection)
context.getAttribute(ExecutionContext.HTTP_CONNECTION);
try {
conn.sendResponseHeader(response);
} catch (HttpException ignore) {
}
}
} ;
entity.setChunked(true);
response.setEntity(entity);
}
});