Anonymous - 2011-11-08

I was able to recreate the java.nio.channels.NotYetConnectedException by downloading NanoHTTPD, compiling it, running it and connecting to it using curl. If I hit ^C just as the request is going through I get the exception.

I first saw the problem when a user was hitting the X button in a browser.

== Compiler ==
$ curl http://elonen.iki.fi/code/nanohttpd/NanoHTTPD.java > NanoHTTPD.java
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 33067 100 33067 0 0 48059 0 --:--:-- --:--:-- --:--:-- 135k
$ javac NanoHTTPD.java
Note: NanoHTTPD.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: NanoHTTPD.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
$

== Server ==
# jamvm NanoHTTPD
NanoHTTPD 1.24 (C) 2001,2005-2011 Jarno Elonen and (C) 2010 Konstantinos Togias
(Command line options: [-p port] [-d root-dir] [--licence])

Now serving files in port 80 from "/tmp/."
Hit Enter to stop.

GET '/'
HDR: 'accept' = '*/*'
HDR: 'host' = 'localhost'
HDR: 'user-agent' = 'curl/7.21.2 (powerpc-unknown-linux-gnu) libcurl/7.21.2 OpenSSL/1.0.0d zlib/1.2.5'
Exception in thread "Thread-6" java.nio.channels.NotYetConnectedException
at gnu.java.nio.SocketChannelImpl.write(SocketChannelImpl.java:240)
at gnu.java.net.PlainSocketImpl$SocketOutputStream.write(PlainSocketImpl.java:668)
at NanoHTTPD$HTTPSession.sendResponse(NanoHTTPD.java:794)
at NanoHTTPD$HTTPSession.run(NanoHTTPD.java:447)
at java.lang.Thread.run(Thread.java:745)

== Client ==
# curl http://localhost/

#