KtoHTTPD does not stop handler on some errors. The current version (2010-11-12) does not stop a thread if an error occurred in the methods decodeHeader() and decodeMultipartData(). There are a comments in the source code about stopping the thread but the code does not work this way. The reason is that the Exceptions thrown by sendError() are not forwarded to the calling run(). Therefore the thread will continue doing not needed work (because the connection was already closed) and maybe fail somewhere else. For the client this there is no difference.
In the original NanoHTTP they fixed this with the following changes:
442c442
< private void decodeHeader(BufferedReader in, Properties pre, Properties parms, Properties header)
---
> private void decodeHeader(BufferedReader in, Properties pre, Properties parms, Properties header) throws InterruptedException
495,498d494
< catch ( InterruptedException ie )
< {
< // Thrown by sendError, ignore and exit the thread.
< }
507c503
< private void decodeMultipartData(String boundary, byte[] fbuf, BufferedReader in, Properties parms, Properties files)
---
> private void decodeMultipartData(String boundary, byte[] fbuf, BufferedReader in, Properties parms, Properties files) throws InterruptedException
583,586d578
< catch ( InterruptedException ie )
< {
< // Thrown by sendError, ignore and exit the thread.
< }